@ndla/util
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -10,3 +10,3 @@ /** | ||
const setRef = (ref, value) => { | ||
if (typeof ref === 'function') { | ||
if (typeof ref === "function") { | ||
ref(value); | ||
@@ -13,0 +13,0 @@ } else if (ref !== null && ref !== undefined) { |
@@ -15,6 +15,6 @@ /** | ||
if (expiration !== undefined) { | ||
if (typeof expiration === 'string') return `expires=${expiration}`;else return `expires=${expiration.toUTCString()}`; | ||
if (typeof expiration === "string") return `expires=${expiration}`;else return `expires=${expiration.toUTCString()}`; | ||
} | ||
if (removeCookie) { | ||
return 'Thu, 01 Jan 1970 00:00:01 GMT'; | ||
return "Thu, 01 Jan 1970 00:00:01 GMT"; | ||
} else { | ||
@@ -32,7 +32,7 @@ const d = new Date(); | ||
lax, | ||
path = '/', | ||
path = "/", | ||
expiration | ||
} = _ref; | ||
const expires = getCookieExpiration(expiration, removeCookie); | ||
return `${cookieName}=${cookieValue}; ${expires}; SameSite=${lax ? 'Lax' : 'Strict'}; path=${path}`; | ||
return `${cookieName}=${cookieValue}; ${expires}; SameSite=${lax ? "Lax" : "Strict"}; path=${path}`; | ||
}; | ||
@@ -46,7 +46,7 @@ | ||
export const getCookie = (cookieName, cookies) => { | ||
const parts = cookies.split(';').map(x => x.trim()); | ||
const parts = cookies.split(";").map(x => x.trim()); | ||
const cookiePart = parts.find(x => x.startsWith(cookieName)); | ||
if (cookiePart) { | ||
const values = cookiePart.split('='); | ||
return values.slice(1).join('='); | ||
const values = cookiePart.split("="); | ||
return values.slice(1).join("="); | ||
} | ||
@@ -64,5 +64,5 @@ return null; | ||
cookieName, | ||
cookieValue: '', | ||
cookieValue: "", | ||
removeCookie: true | ||
}); | ||
}; |
@@ -13,13 +13,13 @@ /** | ||
} | ||
const textArea = document.createElement('textarea'); | ||
textArea.style.position = 'fixed'; | ||
textArea.style.top = '0'; | ||
textArea.style.left = '0'; | ||
textArea.style.padding = '0'; | ||
textArea.style.border = 'none'; | ||
textArea.style.outline = 'none'; | ||
textArea.style.boxShadow = 'none'; | ||
textArea.style.background = 'transparent'; | ||
textArea.style.width = '2em'; | ||
textArea.style.height = '2em'; | ||
const textArea = document.createElement("textarea"); | ||
textArea.style.position = "fixed"; | ||
textArea.style.top = "0"; | ||
textArea.style.left = "0"; | ||
textArea.style.padding = "0"; | ||
textArea.style.border = "none"; | ||
textArea.style.outline = "none"; | ||
textArea.style.boxShadow = "none"; | ||
textArea.style.background = "transparent"; | ||
textArea.style.width = "2em"; | ||
textArea.style.height = "2em"; | ||
textArea.value = text; | ||
@@ -29,3 +29,3 @@ el.appendChild(textArea); | ||
try { | ||
const successful = document.execCommand('copy'); | ||
const successful = document.execCommand("copy"); | ||
el.removeChild(textArea); | ||
@@ -32,0 +32,0 @@ return successful; |
@@ -11,5 +11,5 @@ /** | ||
import ReactDOM from 'react-dom'; | ||
import ReactDOM from "react-dom"; | ||
import { jsx as _jsx } from "@emotion/react/jsx-runtime"; | ||
const canUseDOM = () => !!(typeof window !== 'undefined' && window.document && !window.document.hidden); // window.document.hidden === jsdom check | ||
const canUseDOM = () => !!(typeof window !== "undefined" && window.document && !window.document.hidden); // window.document.hidden === jsdom check | ||
@@ -16,0 +16,0 @@ export function createUniversalPortal(children, selector) { |
@@ -9,3 +9,3 @@ /** | ||
const getComponentName = component => component.displayName || component.name || 'Component'; | ||
const getComponentName = component => component.displayName || component.name || "Component"; | ||
export default getComponentName; |
@@ -10,14 +10,14 @@ /** | ||
const getCurrentBreakpoint = () => { | ||
const body = document.querySelector('body'); | ||
const body = document.querySelector("body"); | ||
if (!body) { | ||
return ''; | ||
return ""; | ||
} | ||
return window.getComputedStyle(body, ':before').getPropertyValue('content').replace(/"/g, ''); | ||
return window.getComputedStyle(body, ":before").getPropertyValue("content").replace(/"/g, ""); | ||
}; | ||
export default getCurrentBreakpoint; | ||
export const breakpoints = { | ||
mobile: 'mobile', | ||
tablet: 'tablet', | ||
desktop: 'desktop', | ||
wide: 'wide' | ||
mobile: "mobile", | ||
tablet: "tablet", | ||
desktop: "desktop", | ||
wide: "wide" | ||
}; |
@@ -9,19 +9,19 @@ /** | ||
export { default as uuid } from './uuid'; | ||
export { default as getComponentName } from './getComponentName'; | ||
export { copyTextToClipboard } from './copyTextToClipboard'; | ||
export { default as noScroll } from './noScroll'; | ||
export { default as getCurrentBreakpoint, breakpoints } from './getCurrentBreakpoint'; | ||
export { createUniversalPortal } from './createUniversalPortal'; | ||
export { isFunction } from './isFunction'; | ||
export { resizeObserver } from './resizeObserver'; | ||
export { setCookie, getCookie, deleteCookie, isValidCookie } from './cookieHandler'; | ||
export { printPage } from './printPage'; | ||
export { default as joinArrayWithConjunction } from './joinArrayWithConjunction'; | ||
export { validateTranslationFiles } from './translationValidation'; | ||
export { default as useForwardedRef } from './useForwardedRef'; | ||
export { default as NoSSR } from './nossr/NoSSR'; | ||
export { default as withNoSSR } from './nossr/withNoSSR'; | ||
export { default as usePrevious } from './usePrevious'; | ||
export { composeRefs } from './composeRefs'; | ||
export { polymorphicForwardRef } from './polymorphicForwardRef'; | ||
export { default as uuid } from "./uuid"; | ||
export { default as getComponentName } from "./getComponentName"; | ||
export { copyTextToClipboard } from "./copyTextToClipboard"; | ||
export { default as noScroll } from "./noScroll"; | ||
export { default as getCurrentBreakpoint, breakpoints } from "./getCurrentBreakpoint"; | ||
export { createUniversalPortal } from "./createUniversalPortal"; | ||
export { isFunction } from "./isFunction"; | ||
export { resizeObserver } from "./resizeObserver"; | ||
export { setCookie, getCookie, deleteCookie, isValidCookie } from "./cookieHandler"; | ||
export { printPage } from "./printPage"; | ||
export { default as joinArrayWithConjunction } from "./joinArrayWithConjunction"; | ||
export { validateTranslationFiles } from "./translationValidation"; | ||
export { default as useForwardedRef } from "./useForwardedRef"; | ||
export { default as NoSSR } from "./nossr/NoSSR"; | ||
export { default as withNoSSR } from "./nossr/withNoSSR"; | ||
export { default as usePrevious } from "./usePrevious"; | ||
export { composeRefs } from "./composeRefs"; | ||
export { polymorphicForwardRef } from "./polymorphicForwardRef"; |
@@ -10,3 +10,3 @@ /** | ||
export function isFunction(object) { | ||
return object && {}.toString.call(object) === '[object Function]'; | ||
return object && {}.toString.call(object) === "[object Function]"; | ||
} |
@@ -11,4 +11,4 @@ /** | ||
let { | ||
separator = ', ', | ||
conjunction = 'og' | ||
separator = ", ", | ||
conjunction = "og" | ||
} = _ref; | ||
@@ -15,0 +15,0 @@ if (list.length === 1) { |
@@ -14,8 +14,8 @@ /** | ||
} | ||
const scrollDiv = document.createElement('div'); | ||
scrollDiv.style.width = '100px'; | ||
scrollDiv.style.height = '100px'; | ||
scrollDiv.style.overflow = 'scroll'; | ||
scrollDiv.style.position = 'absolute'; | ||
scrollDiv.style.top = '-9999px'; | ||
const scrollDiv = document.createElement("div"); | ||
scrollDiv.style.width = "100px"; | ||
scrollDiv.style.height = "100px"; | ||
scrollDiv.style.overflow = "scroll"; | ||
scrollDiv.style.position = "absolute"; | ||
scrollDiv.style.top = "-9999px"; | ||
document.body.appendChild(scrollDiv); | ||
@@ -28,3 +28,3 @@ scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; | ||
const noScroll = (enable, uuid) => { | ||
const bodyElement = document.querySelector('html > body'); | ||
const bodyElement = document.querySelector("html > body"); | ||
if (bodyElement === null) { | ||
@@ -37,3 +37,3 @@ return; | ||
const scrollWidth = getScrollbarWidth(); | ||
bodyElement.style.overflow = 'hidden'; | ||
bodyElement.style.overflow = "hidden"; | ||
bodyElement.style.marginRight = `${scrollWidth}px`; | ||
@@ -46,4 +46,4 @@ } | ||
if (scrollTargets.length === 0) { | ||
bodyElement.style.marginRight = '0'; | ||
bodyElement.style.overflow = 'visible'; | ||
bodyElement.style.marginRight = "0"; | ||
bodyElement.style.overflow = "visible"; | ||
} | ||
@@ -50,0 +50,0 @@ } |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { useEffect, useState } from 'react'; | ||
import { useEffect, useState } from "react"; | ||
import { Fragment as _Fragment } from "@emotion/react/jsx-runtime"; | ||
@@ -11,0 +11,0 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime"; |
@@ -9,3 +9,3 @@ /** | ||
import NoSSR from './NoSSR'; | ||
import NoSSR from "./NoSSR"; | ||
@@ -12,0 +12,0 @@ /** Basic HoC to wrap your component in `NoSSR`, see `NoSSR.tsx` */ |
@@ -9,3 +9,3 @@ /** | ||
import { forwardRef } from 'react'; | ||
import { forwardRef } from "react"; | ||
@@ -12,0 +12,0 @@ /** |
@@ -20,3 +20,3 @@ /** | ||
export function printPage(url) { | ||
const iframe = document.createElement('iframe'); | ||
const iframe = document.createElement("iframe"); | ||
iframe.onload = setPrint; | ||
@@ -23,0 +23,0 @@ iframe.src = url; |
@@ -12,7 +12,7 @@ /** | ||
function fallbackResizeObserver(element, handler) { | ||
const CSS = 'position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;pointer-events:none;'; | ||
const frame = document.createElement('iframe'); | ||
const CSS = "position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;pointer-events:none;"; | ||
const frame = document.createElement("iframe"); | ||
const documentMode = document.documentMode || 12; | ||
const supportsPE = documentMode < 11 ? false : 'pointerEvents' in frame.style; | ||
frame.style.cssText = supportsPE ? CSS : CSS + 'visibility:hidden;'; | ||
const supportsPE = documentMode < 11 ? false : "pointerEvents" in frame.style; | ||
frame.style.cssText = supportsPE ? CSS : CSS + "visibility:hidden;"; | ||
element.appendChild(frame); | ||
@@ -49,3 +49,3 @@ if (frame.contentWindow) { | ||
// @ts-ignore ResizeObserver | ||
if (typeof ResizeObserver === 'function') { | ||
if (typeof ResizeObserver === "function") { | ||
return resizeObserverWrapper(element, handler); | ||
@@ -52,0 +52,0 @@ } |
@@ -10,8 +10,8 @@ /** | ||
const getAllKeys = function (o) { | ||
let prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
let prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; | ||
const keys = []; | ||
Object.entries(o).forEach(_ref => { | ||
let [key, value] = _ref; | ||
const path = prev + (prev ? '.' : '') + key; | ||
if (typeof value === 'object' && value !== null) { | ||
const path = prev + (prev ? "." : "") + key; | ||
if (typeof value === "object" && value !== null) { | ||
const nested = getAllKeys(value, path); | ||
@@ -61,4 +61,4 @@ keys.push(...nested); | ||
const anyError = langs.some(l => l.missingKeys.length > 0); | ||
if (logging === 'only-on-error' && anyError || logging === 'always') logTable(langs); | ||
if (logging === "only-on-error" && anyError || logging === "always") logTable(langs); | ||
return anyError; | ||
}; |
@@ -9,3 +9,3 @@ /** | ||
import { useEffect, useRef } from 'react'; | ||
import { useEffect, useRef } from "react"; | ||
const useForwardedRef = ref => { | ||
@@ -15,3 +15,3 @@ const innerRef = useRef(null); | ||
if (!ref) return; | ||
if (typeof ref === 'function') { | ||
if (typeof ref === "function") { | ||
ref(innerRef.current); | ||
@@ -18,0 +18,0 @@ } else { |
@@ -9,3 +9,3 @@ /** | ||
import { useEffect, useRef } from 'react'; | ||
import { useEffect, useRef } from "react"; | ||
const usePrevious = value => { | ||
@@ -12,0 +12,0 @@ const ref = useRef(undefined); |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Ref } from 'react'; | ||
import { Ref } from "react"; | ||
type PossibleRef<T> = Ref<T> | undefined; | ||
@@ -11,0 +11,0 @@ /** |
@@ -16,3 +16,3 @@ "use strict"; | ||
const setRef = (ref, value) => { | ||
if (typeof ref === 'function') { | ||
if (typeof ref === "function") { | ||
ref(value); | ||
@@ -19,0 +19,0 @@ } else if (ref !== null && ref !== undefined) { |
@@ -22,6 +22,6 @@ "use strict"; | ||
if (expiration !== undefined) { | ||
if (typeof expiration === 'string') return `expires=${expiration}`;else return `expires=${expiration.toUTCString()}`; | ||
if (typeof expiration === "string") return `expires=${expiration}`;else return `expires=${expiration.toUTCString()}`; | ||
} | ||
if (removeCookie) { | ||
return 'Thu, 01 Jan 1970 00:00:01 GMT'; | ||
return "Thu, 01 Jan 1970 00:00:01 GMT"; | ||
} else { | ||
@@ -39,7 +39,7 @@ const d = new Date(); | ||
lax, | ||
path = '/', | ||
path = "/", | ||
expiration | ||
} = _ref; | ||
const expires = getCookieExpiration(expiration, removeCookie); | ||
return `${cookieName}=${cookieValue}; ${expires}; SameSite=${lax ? 'Lax' : 'Strict'}; path=${path}`; | ||
return `${cookieName}=${cookieValue}; ${expires}; SameSite=${lax ? "Lax" : "Strict"}; path=${path}`; | ||
}; | ||
@@ -54,7 +54,7 @@ | ||
const getCookie = (cookieName, cookies) => { | ||
const parts = cookies.split(';').map(x => x.trim()); | ||
const parts = cookies.split(";").map(x => x.trim()); | ||
const cookiePart = parts.find(x => x.startsWith(cookieName)); | ||
if (cookiePart) { | ||
const values = cookiePart.split('='); | ||
return values.slice(1).join('='); | ||
const values = cookiePart.split("="); | ||
return values.slice(1).join("="); | ||
} | ||
@@ -74,3 +74,3 @@ return null; | ||
cookieName, | ||
cookieValue: '', | ||
cookieValue: "", | ||
removeCookie: true | ||
@@ -77,0 +77,0 @@ }); |
@@ -19,13 +19,13 @@ "use strict"; | ||
} | ||
const textArea = document.createElement('textarea'); | ||
textArea.style.position = 'fixed'; | ||
textArea.style.top = '0'; | ||
textArea.style.left = '0'; | ||
textArea.style.padding = '0'; | ||
textArea.style.border = 'none'; | ||
textArea.style.outline = 'none'; | ||
textArea.style.boxShadow = 'none'; | ||
textArea.style.background = 'transparent'; | ||
textArea.style.width = '2em'; | ||
textArea.style.height = '2em'; | ||
const textArea = document.createElement("textarea"); | ||
textArea.style.position = "fixed"; | ||
textArea.style.top = "0"; | ||
textArea.style.left = "0"; | ||
textArea.style.padding = "0"; | ||
textArea.style.border = "none"; | ||
textArea.style.outline = "none"; | ||
textArea.style.boxShadow = "none"; | ||
textArea.style.background = "transparent"; | ||
textArea.style.width = "2em"; | ||
textArea.style.height = "2em"; | ||
textArea.value = text; | ||
@@ -35,3 +35,3 @@ el.appendChild(textArea); | ||
try { | ||
const successful = document.execCommand('copy'); | ||
const successful = document.execCommand("copy"); | ||
el.removeChild(textArea); | ||
@@ -38,0 +38,0 @@ return successful; |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { ReactNode } from 'react'; | ||
import { ReactNode } from "react"; | ||
export declare function createUniversalPortal(children: ReactNode, selector: string): import("@emotion/react/jsx-runtime").JSX.Element; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const canUseDOM = () => !!(typeof window !== 'undefined' && window.document && !window.document.hidden); // window.document.hidden === jsdom check | ||
const canUseDOM = () => !!(typeof window !== "undefined" && window.document && !window.document.hidden); // window.document.hidden === jsdom check | ||
@@ -23,0 +23,0 @@ function createUniversalPortal(children, selector) { |
@@ -8,4 +8,4 @@ /** | ||
*/ | ||
import { ComponentClass } from 'react'; | ||
import { ComponentClass } from "react"; | ||
declare const getComponentName: (component: ComponentClass) => string; | ||
export default getComponentName; |
@@ -15,3 +15,3 @@ "use strict"; | ||
const getComponentName = component => component.displayName || component.name || 'Component'; | ||
const getComponentName = component => component.displayName || component.name || "Component"; | ||
var _default = exports.default = getComponentName; |
@@ -16,14 +16,14 @@ "use strict"; | ||
const getCurrentBreakpoint = () => { | ||
const body = document.querySelector('body'); | ||
const body = document.querySelector("body"); | ||
if (!body) { | ||
return ''; | ||
return ""; | ||
} | ||
return window.getComputedStyle(body, ':before').getPropertyValue('content').replace(/"/g, ''); | ||
return window.getComputedStyle(body, ":before").getPropertyValue("content").replace(/"/g, ""); | ||
}; | ||
var _default = exports.default = getCurrentBreakpoint; | ||
const breakpoints = exports.breakpoints = { | ||
mobile: 'mobile', | ||
tablet: 'tablet', | ||
desktop: 'desktop', | ||
wide: 'wide' | ||
mobile: "mobile", | ||
tablet: "tablet", | ||
desktop: "desktop", | ||
wide: "wide" | ||
}; |
@@ -8,20 +8,20 @@ /** | ||
*/ | ||
export { default as uuid } from './uuid'; | ||
export { default as getComponentName } from './getComponentName'; | ||
export { copyTextToClipboard } from './copyTextToClipboard'; | ||
export { default as noScroll } from './noScroll'; | ||
export { default as getCurrentBreakpoint, breakpoints } from './getCurrentBreakpoint'; | ||
export { createUniversalPortal } from './createUniversalPortal'; | ||
export { isFunction } from './isFunction'; | ||
export { resizeObserver } from './resizeObserver'; | ||
export { setCookie, getCookie, deleteCookie, isValidCookie } from './cookieHandler'; | ||
export { printPage } from './printPage'; | ||
export { default as joinArrayWithConjunction } from './joinArrayWithConjunction'; | ||
export { validateTranslationFiles } from './translationValidation'; | ||
export { default as useForwardedRef } from './useForwardedRef'; | ||
export { default as NoSSR } from './nossr/NoSSR'; | ||
export { default as withNoSSR } from './nossr/withNoSSR'; | ||
export { default as usePrevious } from './usePrevious'; | ||
export { composeRefs } from './composeRefs'; | ||
export { polymorphicForwardRef } from './polymorphicForwardRef'; | ||
export type { PolymorphicProps } from './polymorphicForwardRef'; | ||
export { default as uuid } from "./uuid"; | ||
export { default as getComponentName } from "./getComponentName"; | ||
export { copyTextToClipboard } from "./copyTextToClipboard"; | ||
export { default as noScroll } from "./noScroll"; | ||
export { default as getCurrentBreakpoint, breakpoints } from "./getCurrentBreakpoint"; | ||
export { createUniversalPortal } from "./createUniversalPortal"; | ||
export { isFunction } from "./isFunction"; | ||
export { resizeObserver } from "./resizeObserver"; | ||
export { setCookie, getCookie, deleteCookie, isValidCookie } from "./cookieHandler"; | ||
export { printPage } from "./printPage"; | ||
export { default as joinArrayWithConjunction } from "./joinArrayWithConjunction"; | ||
export { validateTranslationFiles } from "./translationValidation"; | ||
export { default as useForwardedRef } from "./useForwardedRef"; | ||
export { default as NoSSR } from "./nossr/NoSSR"; | ||
export { default as withNoSSR } from "./nossr/withNoSSR"; | ||
export { default as usePrevious } from "./usePrevious"; | ||
export { composeRefs } from "./composeRefs"; | ||
export { polymorphicForwardRef } from "./polymorphicForwardRef"; | ||
export type { PolymorphicProps } from "./polymorphicForwardRef"; |
@@ -16,3 +16,3 @@ "use strict"; | ||
function isFunction(object) { | ||
return object && {}.toString.call(object) === '[object Function]'; | ||
return object && {}.toString.call(object) === "[object Function]"; | ||
} |
@@ -17,4 +17,4 @@ "use strict"; | ||
let { | ||
separator = ', ', | ||
conjunction = 'og' | ||
separator = ", ", | ||
conjunction = "og" | ||
} = _ref; | ||
@@ -21,0 +21,0 @@ if (list.length === 1) { |
@@ -20,8 +20,8 @@ "use strict"; | ||
} | ||
const scrollDiv = document.createElement('div'); | ||
scrollDiv.style.width = '100px'; | ||
scrollDiv.style.height = '100px'; | ||
scrollDiv.style.overflow = 'scroll'; | ||
scrollDiv.style.position = 'absolute'; | ||
scrollDiv.style.top = '-9999px'; | ||
const scrollDiv = document.createElement("div"); | ||
scrollDiv.style.width = "100px"; | ||
scrollDiv.style.height = "100px"; | ||
scrollDiv.style.overflow = "scroll"; | ||
scrollDiv.style.position = "absolute"; | ||
scrollDiv.style.top = "-9999px"; | ||
document.body.appendChild(scrollDiv); | ||
@@ -34,3 +34,3 @@ scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; | ||
const noScroll = (enable, uuid) => { | ||
const bodyElement = document.querySelector('html > body'); | ||
const bodyElement = document.querySelector("html > body"); | ||
if (bodyElement === null) { | ||
@@ -43,3 +43,3 @@ return; | ||
const scrollWidth = getScrollbarWidth(); | ||
bodyElement.style.overflow = 'hidden'; | ||
bodyElement.style.overflow = "hidden"; | ||
bodyElement.style.marginRight = `${scrollWidth}px`; | ||
@@ -52,4 +52,4 @@ } | ||
if (scrollTargets.length === 0) { | ||
bodyElement.style.marginRight = '0'; | ||
bodyElement.style.overflow = 'visible'; | ||
bodyElement.style.marginRight = "0"; | ||
bodyElement.style.overflow = "visible"; | ||
} | ||
@@ -56,0 +56,0 @@ } |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { ReactNode } from 'react'; | ||
import { ReactNode } from "react"; | ||
interface Props { | ||
@@ -11,0 +11,0 @@ children: ReactNode; |
@@ -8,5 +8,5 @@ /** | ||
*/ | ||
import { ReactNode, ComponentType } from 'react'; | ||
import { ReactNode, ComponentType } from "react"; | ||
/** Basic HoC to wrap your component in `NoSSR`, see `NoSSR.tsx` */ | ||
declare function withNoSSR<TProps extends object>(WrappedComponent: ComponentType<any>, fallback?: ReactNode | null): ComponentType<TProps>; | ||
export default withNoSSR; |
@@ -8,5 +8,5 @@ /** | ||
*/ | ||
import { ComponentPropsWithRef, ElementType } from 'react'; | ||
import { ComponentPropsWithRef, ElementType } from "react"; | ||
type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any ? Omit<T, TOmitted> : never; | ||
export type PolymorphicProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithRef<T>, 'element'> & { | ||
export type PolymorphicProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithRef<T>, "element"> & { | ||
element?: T; | ||
@@ -13,0 +13,0 @@ }; |
@@ -26,3 +26,3 @@ "use strict"; | ||
function printPage(url) { | ||
const iframe = document.createElement('iframe'); | ||
const iframe = document.createElement("iframe"); | ||
iframe.onload = setPrint; | ||
@@ -29,0 +29,0 @@ iframe.src = url; |
@@ -18,7 +18,7 @@ "use strict"; | ||
function fallbackResizeObserver(element, handler) { | ||
const CSS = 'position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;pointer-events:none;'; | ||
const frame = document.createElement('iframe'); | ||
const CSS = "position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;pointer-events:none;"; | ||
const frame = document.createElement("iframe"); | ||
const documentMode = document.documentMode || 12; | ||
const supportsPE = documentMode < 11 ? false : 'pointerEvents' in frame.style; | ||
frame.style.cssText = supportsPE ? CSS : CSS + 'visibility:hidden;'; | ||
const supportsPE = documentMode < 11 ? false : "pointerEvents" in frame.style; | ||
frame.style.cssText = supportsPE ? CSS : CSS + "visibility:hidden;"; | ||
element.appendChild(frame); | ||
@@ -55,3 +55,3 @@ if (frame.contentWindow) { | ||
// @ts-ignore ResizeObserver | ||
if (typeof ResizeObserver === 'function') { | ||
if (typeof ResizeObserver === "function") { | ||
return resizeObserverWrapper(element, handler); | ||
@@ -58,0 +58,0 @@ } |
@@ -11,2 +11,2 @@ /** | ||
translationObject: object; | ||
}[], logging: 'disabled' | 'only-on-error' | 'always') => boolean; | ||
}[], logging: "disabled" | "only-on-error" | "always") => boolean; |
@@ -16,8 +16,8 @@ "use strict"; | ||
const getAllKeys = function (o) { | ||
let prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
let prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; | ||
const keys = []; | ||
Object.entries(o).forEach(_ref => { | ||
let [key, value] = _ref; | ||
const path = prev + (prev ? '.' : '') + key; | ||
if (typeof value === 'object' && value !== null) { | ||
const path = prev + (prev ? "." : "") + key; | ||
if (typeof value === "object" && value !== null) { | ||
const nested = getAllKeys(value, path); | ||
@@ -67,5 +67,5 @@ keys.push(...nested); | ||
const anyError = langs.some(l => l.missingKeys.length > 0); | ||
if (logging === 'only-on-error' && anyError || logging === 'always') logTable(langs); | ||
if (logging === "only-on-error" && anyError || logging === "always") logTable(langs); | ||
return anyError; | ||
}; | ||
exports.validateTranslationFiles = validateTranslationFiles; |
@@ -8,4 +8,4 @@ /** | ||
*/ | ||
import { ForwardedRef } from 'react'; | ||
import { ForwardedRef } from "react"; | ||
declare const useForwardedRef: <T>(ref?: ForwardedRef<T> | undefined) => import("react").MutableRefObject<T | null>; | ||
export default useForwardedRef; |
@@ -20,3 +20,3 @@ "use strict"; | ||
if (!ref) return; | ||
if (typeof ref === 'function') { | ||
if (typeof ref === "function") { | ||
ref(innerRef.current); | ||
@@ -23,0 +23,0 @@ } else { |
{ | ||
"name": "@ndla/util", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Collection of util functions used by NDLA", | ||
@@ -35,3 +35,3 @@ "license": "GPL-3.0", | ||
}, | ||
"gitHead": "5c65dfc8de95fb464182f86a40b74868ca30a29e" | ||
"gitHead": "9d844b2508b4268099ea16ef69f14c273c4b4033" | ||
} |
@@ -18,3 +18,3 @@ # ndla-util | ||
```js | ||
import uuid from '@ndla/util/uuid'; | ||
import uuid from "@ndla/util/uuid"; | ||
@@ -28,3 +28,3 @@ const unique = uuid(); | ||
```js | ||
import { uuid } from '@ndla/util'; | ||
import { uuid } from "@ndla/util"; | ||
@@ -73,4 +73,4 @@ const unique = uuid(); | ||
```js | ||
import { copyTextToClipboard } from '@ndla/util'; | ||
copyTextToClipboard('Hello world!'); | ||
import { copyTextToClipboard } from "@ndla/util"; | ||
copyTextToClipboard("Hello world!"); | ||
``` | ||
@@ -84,4 +84,4 @@ | ||
```js | ||
import { tagsI18N } from '@ndla/util'; | ||
tagsI18N(object, 'nb', false, ['nb', 'nn', 'en']); | ||
import { tagsI18N } from "@ndla/util"; | ||
tagsI18N(object, "nb", false, ["nb", "nn", "en"]); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0