Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down Expand Up @@ -41,7 +41,7 @@ on:

permissions:
attestations: write # Required for attestations
id-token: write # Required for OIDC
id-token: write # Required for OIDC

jobs:
build:
Expand Down Expand Up @@ -96,4 +96,3 @@ jobs:
with:
name: templates
path: artifacts/*

2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand Down
4 changes: 2 additions & 2 deletions .mono.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 Zensical and contributors
# Copyright (c) 2025-2026 Zensical and contributors

# SPDX-License-Identifier: MIT
# Third-party contributions licensed under DCO
Expand All @@ -21,7 +21,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

[changeset.scopes]
[scopes]
templates = "src/**"
scripts = "src/assets/javascripts/**"
modern = "src/assets/stylesheets/modern/**"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2025 Zensical and contributors
Copyright (c) 2025-2026 Zensical and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
Expand Down
2 changes: 1 addition & 1 deletion src/404.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2025 Zensical and contributors
Copyright (c) 2025-2026 Zensical and contributors

SPDX-License-Identifier: MIT
Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/_/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/asset/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/document/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
59 changes: 34 additions & 25 deletions src/assets/javascripts/browser/element/_/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down Expand Up @@ -38,17 +38,20 @@
* @returns Elements
*/
export function getElements<T extends keyof HTMLElementTagNameMap>(
selector: T, node?: ParentNode
): HTMLElementTagNameMap[T][]
selector: T,
node?: ParentNode,
): HTMLElementTagNameMap[T][];

export function getElements<T extends HTMLElement>(
selector: string, node?: ParentNode
): T[]
selector: string,
node?: ParentNode,
): T[];

export function getElements<T extends HTMLElement>(
selector: string, node: ParentNode = document
selector: string,
node: ParentNode = document,
): T[] {
return Array.from(node.querySelectorAll<T>(selector))
return Array.from(node.querySelectorAll<T>(selector));
}

/**
Expand All @@ -65,24 +68,27 @@ export function getElements<T extends HTMLElement>(
* @returns Element
*/
export function getElement<T extends keyof HTMLElementTagNameMap>(
selector: T, node?: ParentNode
): HTMLElementTagNameMap[T]
selector: T,
node?: ParentNode,
): HTMLElementTagNameMap[T];

export function getElement<T extends HTMLElement>(
selector: string, node?: ParentNode
): T
selector: string,
node?: ParentNode,
): T;

export function getElement<T extends HTMLElement>(
selector: string, node: ParentNode = document
selector: string,
node: ParentNode = document,
): T {
const el = getOptionalElement<T>(selector, node)
const el = getOptionalElement<T>(selector, node);
if (typeof el === "undefined")
throw new ReferenceError(
`Missing element: expected "${selector}" to be present`
)
`Missing element: expected "${selector}" to be present`,
);

// Return element
return el
return el;
}

// -------------------------------------------------------------------------
Expand All @@ -98,17 +104,20 @@ export function getElement<T extends HTMLElement>(
* @returns Element or nothing
*/
export function getOptionalElement<T extends keyof HTMLElementTagNameMap>(
selector: T, node?: ParentNode
): HTMLElementTagNameMap[T] | undefined
selector: T,
node?: ParentNode,
): HTMLElementTagNameMap[T] | undefined;

export function getOptionalElement<T extends HTMLElement>(
selector: string, node?: ParentNode
): T | undefined
selector: string,
node?: ParentNode,
): T | undefined;

export function getOptionalElement<T extends HTMLElement>(
selector: string, node: ParentNode = document
selector: string,
node: ParentNode = document,
): T | undefined {
return node.querySelector<T>(selector) || undefined
return node.querySelector<T>(selector) || undefined;
}

/**
Expand All @@ -118,8 +127,8 @@ export function getOptionalElement<T extends HTMLElement>(
*/
export function getActiveElement(): HTMLElement | undefined {
return (
document.activeElement?.shadowRoot?.activeElement as HTMLElement ??
document.activeElement as HTMLElement ??
(document.activeElement?.shadowRoot?.activeElement as HTMLElement) ??
(document.activeElement as HTMLElement) ??
undefined
)
);
}
36 changes: 16 additions & 20 deletions src/assets/javascripts/browser/element/focus/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down Expand Up @@ -31,10 +31,10 @@ import {
map,
merge,
shareReplay,
startWith
} from "rxjs"
startWith,
} from "rxjs";

import { getActiveElement } from "../_"
import { getActiveElement } from "../_";

/* ----------------------------------------------------------------------------
* Data
Expand All @@ -53,14 +53,13 @@ import { getActiveElement } from "../_"
*/
const observer$ = merge(
fromEvent(document.body, "focusin"),
fromEvent(document.body, "focusout")
)
.pipe(
debounceTime(1),
startWith(undefined),
map(() => getActiveElement() || document.body),
shareReplay(1)
)
fromEvent(document.body, "focusout"),
).pipe(
debounceTime(1),
startWith(undefined),
map(() => getActiveElement() || document.body),
shareReplay(1),
);

/* ----------------------------------------------------------------------------
* Functions
Expand All @@ -73,12 +72,9 @@ const observer$ = merge(
*
* @returns Element focus observable
*/
export function watchElementFocus(
el: HTMLElement
): Observable<boolean> {
return observer$
.pipe(
map(active => el.contains(active)),
distinctUntilChanged()
)
export function watchElementFocus(el: HTMLElement): Observable<boolean> {
return observer$.pipe(
map((active) => el.contains(active)),
distinctUntilChanged(),
);
}
25 changes: 13 additions & 12 deletions src/assets/javascripts/browser/element/hover/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down Expand Up @@ -32,8 +32,8 @@ import {
map,
merge,
startWith,
timer
} from "rxjs"
timer,
} from "rxjs";

/* ----------------------------------------------------------------------------
* Functions
Expand All @@ -53,28 +53,29 @@ import {
* @returns Element hover observable
*/
export function watchElementHover(
el: HTMLElement, timeout?: number
el: HTMLElement,
timeout?: number,
): Observable<boolean> {
const { matches: hover } = matchMedia("(hover)")
const { matches: hover } = matchMedia("(hover)");
return defer(() => {
const events = hover
? merge(
fromEvent(el, "mouseenter").pipe(map(() => true)),
fromEvent(el, "mouseleave").pipe(map(() => false))
fromEvent(el, "mouseleave").pipe(map(() => false)),
)
: merge (
: merge(
fromEvent(el, "touchstart").pipe(map(() => true)),
fromEvent(el, "touchend").pipe(map(() => false)),
fromEvent(el, "touchcancel").pipe(map(() => false)),
)
);

// Apply debounce if timeout is specified - we emit two times, to make sure
// that tooltips are synchronized. We'll refactor this in the future, but
// will move to an entirely new event system anyway, as we move on to a
// proper component system implementation.
return events.pipe(
timeout ? debounce(active => timer(+!active * timeout)) : identity,
startWith(true, el.matches(":hover"))
)
})
timeout ? debounce((active) => timer(+!active * timeout)) : identity,
startWith(true, el.matches(":hover")),
);
});
}
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/offset/_/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/offset/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/size/_/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/size/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/element/visibility/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/keyboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Zensical and contributors
* Copyright (c) 2025-2026 Zensical and contributors
*
* SPDX-License-Identifier: MIT
* Third-party contributions licensed under DCO
Expand Down
Loading