Merged in chore/remove-unused-code (pull request #2229)
Remove unused code * Remove unused scandic-web files * Remove unused exports Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -16,16 +16,6 @@ export function getLocalizedMonthName(monthIndex: number, lang: Lang) {
|
||||
return monthName.charAt(0).toUpperCase() + monthName.slice(1)
|
||||
}
|
||||
|
||||
export function getNights(start: string, end: string) {
|
||||
const range = []
|
||||
let current = d(start)
|
||||
while (current.isBefore(end)) {
|
||||
range.push(current)
|
||||
current = current.add(1, "days")
|
||||
}
|
||||
return range
|
||||
}
|
||||
|
||||
export function getNumberOfNights(startDate: Date, endDate: Date) {
|
||||
return d(endDate).diff(startDate, "day")
|
||||
}
|
||||
|
||||
@@ -100,16 +100,6 @@ export function generateLoyaltyConfigTag(
|
||||
return `${lang}:loyalty_config:${contentTypeUid}:${id}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate tags for service tokens
|
||||
*
|
||||
* @param serviceTokenScope scope of service token
|
||||
* @returns string
|
||||
*/
|
||||
export function generateServiceTokenTag(scopes: string[]) {
|
||||
return `service_token:${scopes.join("-")}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate tags for hotel page urls
|
||||
*
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export const isBrowser = typeof window !== "undefined" && !("Deno" in window)
|
||||
@@ -9,11 +9,3 @@ export async function safeTry<T>(func: Promise<T>): SafeTryResult<T> {
|
||||
return [undefined, err]
|
||||
}
|
||||
}
|
||||
|
||||
export function safeTrySync<T>(func: () => T): Awaited<SafeTryResult<T>> {
|
||||
try {
|
||||
return [func(), undefined]
|
||||
} catch (err) {
|
||||
return [undefined, err]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*!
|
||||
* Adapted from jQuery UI core
|
||||
*
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright 2014 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://api.jqueryui.com/category/ui-core/
|
||||
*/
|
||||
|
||||
const tabbableNode = /input|select|textarea|button|object/
|
||||
|
||||
function hidesContents(element: HTMLElement) {
|
||||
const zeroSize = element.offsetWidth <= 0 && element.offsetHeight <= 0
|
||||
|
||||
// If the node is empty, this is good enough
|
||||
if (zeroSize && !element.innerHTML) return true
|
||||
|
||||
// Otherwise we need to check some styles
|
||||
const style = window.getComputedStyle(element)
|
||||
return (
|
||||
style.getPropertyValue("display") === "none" ||
|
||||
(zeroSize && style.getPropertyValue("overflow") !== "visible")
|
||||
)
|
||||
}
|
||||
|
||||
function visible(element: any) {
|
||||
let parentElement = element
|
||||
while (parentElement) {
|
||||
if (parentElement === document.body) break
|
||||
if (hidesContents(parentElement)) return false
|
||||
parentElement = parentElement.parentNode
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function focusable(element: HTMLElement, isTabIndexNotNaN: boolean) {
|
||||
const nodeName = element.nodeName.toLowerCase()
|
||||
const res =
|
||||
//@ts-ignore
|
||||
(tabbableNode.test(nodeName) && !element.disabled) ||
|
||||
//@ts-ignore
|
||||
(nodeName === "a" ? element.href || isTabIndexNotNaN : isTabIndexNotNaN)
|
||||
return res && visible(element)
|
||||
}
|
||||
|
||||
export function tabbable(element: HTMLElement) {
|
||||
const tabIndexAttr = element.getAttribute("tabindex")
|
||||
const tabIndex = tabIndexAttr !== null ? Number(tabIndexAttr) : undefined
|
||||
const isTabIndexNaN = tabIndex === undefined || isNaN(tabIndex)
|
||||
|
||||
return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN)
|
||||
}
|
||||
|
||||
export default function findTabbableDescendants(
|
||||
element: HTMLElement | null | undefined
|
||||
): HTMLElement[] {
|
||||
if (!(element instanceof HTMLElement)) {
|
||||
return []
|
||||
}
|
||||
|
||||
return Array.from(element.querySelectorAll("*"))
|
||||
.filter((el): el is HTMLElement => el instanceof HTMLElement)
|
||||
.filter(tabbable)
|
||||
}
|
||||
Reference in New Issue
Block a user