@entur/utils 0.9.3 → 0.9.5

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.
@@ -1,7 +1,7 @@
1
- type ConditionalWrapperType = {
2
- condition: boolean;
3
- wrapper: any;
4
- children: any;
5
- };
6
- export declare const ConditionalWrapper: ({ condition, wrapper, children, }: ConditionalWrapperType) => any;
7
- export {};
1
+ type ConditionalWrapperType = {
2
+ condition: boolean;
3
+ wrapper: any;
4
+ children: any;
5
+ };
6
+ export declare const ConditionalWrapper: ({ condition, wrapper, children, }: ConditionalWrapperType) => any;
7
+ export {};
@@ -1,41 +1,41 @@
1
- /** These polymorphic types are derrived from Ben Ilegbodu's article available at the following link:
2
- * https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
3
- */
4
- import React from 'react';
5
- export type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;
6
- type AsProp<C extends React.ElementType> = {
7
- /**
8
- * An override of the default HTML tag.
9
- * Can also be another React component.
10
- */
11
- as?: C;
12
- };
13
- /**
14
- * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
15
- * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
16
- * set of props.
17
- */
18
- export type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
19
- /**
20
- * Allows for inheriting the props from the specified element type so that
21
- * props like children, className & style work, as well as element-specific
22
- * attributes like aria roles. The component (`C`) must be passed in.
23
- */
24
- export type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
25
- /**
26
- * A more sophisticated version of `InheritableElementProps` where
27
- * the passed in `as` prop will determine which props can be included
28
- */
29
- export type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
30
- /**
31
- * Utility type to extract the `ref` prop from a polymorphic component
32
- */
33
- export type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
34
- /**
35
- * A wrapper of `PolymorphicComponentProps` that also includes the `ref`
36
- * prop for the polymorphic component
37
- */
38
- export type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
39
- ref?: PolymorphicRef<C>;
40
- };
41
- export {};
1
+ /** These polymorphic types are derrived from Ben Ilegbodu's article available at the following link:
2
+ * https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
3
+ */
4
+ import React from 'react';
5
+ export type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;
6
+ type AsProp<C extends React.ElementType> = {
7
+ /**
8
+ * An override of the default HTML tag.
9
+ * Can also be another React component.
10
+ */
11
+ as?: C;
12
+ };
13
+ /**
14
+ * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
15
+ * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
16
+ * set of props.
17
+ */
18
+ export type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
19
+ /**
20
+ * Allows for inheriting the props from the specified element type so that
21
+ * props like children, className & style work, as well as element-specific
22
+ * attributes like aria roles. The component (`C`) must be passed in.
23
+ */
24
+ export type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
25
+ /**
26
+ * A more sophisticated version of `InheritableElementProps` where
27
+ * the passed in `as` prop will determine which props can be included
28
+ */
29
+ export type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
30
+ /**
31
+ * Utility type to extract the `ref` prop from a polymorphic component
32
+ */
33
+ export type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
34
+ /**
35
+ * A wrapper of `PolymorphicComponentProps` that also includes the `ref`
36
+ * prop for the polymorphic component
37
+ */
38
+ export type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
39
+ ref?: PolymorphicRef<C>;
40
+ };
41
+ export {};
@@ -1,13 +1,13 @@
1
- @import '~@entur/tokens/dist/styles.scss';
1
+ @use '~@entur/tokens/dist/styles.scss' as t;
2
2
 
3
3
  @mixin for-desktop {
4
- @media screen and (min-width: #{$breakpoints-large}) {
4
+ @media screen and (min-width: #{t.$breakpoints-large}) {
5
5
  @content;
6
6
  }
7
7
  }
8
8
 
9
9
  @mixin for-large-desktop {
10
- @media screen and (min-width: #{$breakpoints-extra-large}) {
10
+ @media screen and (min-width: #{t.$breakpoints-extra-large}) {
11
11
  @content;
12
12
  }
13
13
  }
@@ -1 +1 @@
1
- export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
1
+ export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './debounce';
2
- export * from './PolymorphicComponent';
3
- export * from './useRandomId';
4
- export * from './useOnMount';
5
- export * from './mergeRefs';
6
- export * from './useForceUpdate';
7
- export * from './useOnClickOutside';
8
- export * from './useOnEscape';
9
- export * from './useWindowDimensions';
10
- export * from './ConditionalWrapper';
11
- export * from './warnAboutMissingStyles';
1
+ export * from './debounce';
2
+ export * from './PolymorphicComponent';
3
+ export * from './useRandomId';
4
+ export * from './useOnMount';
5
+ export * from './mergeRefs';
6
+ export * from './useForceUpdate';
7
+ export * from './useOnClickOutside';
8
+ export * from './useOnEscape';
9
+ export * from './useWindowDimensions';
10
+ export * from './ConditionalWrapper';
11
+ export * from './warnAboutMissingStyles';
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const mergeRefs: <T extends HTMLElement>(...refs: (import("react").MutableRefObject<T> | import("react").ForwardedRef<T> | undefined)[]) => (node: T) => void;
1
+ /// <reference types="react" />
2
+ export declare const mergeRefs: <T extends HTMLElement>(...refs: (import("react").MutableRefObject<T> | import("react").ForwardedRef<T> | undefined)[]) => (node: T) => void;
@@ -1 +1 @@
1
- export declare const useForceUpdate: () => () => void;
1
+ export declare const useForceUpdate: () => () => void;
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const useOnClickOutside: (refs: React.RefObject<HTMLDivElement>[], handler: () => void) => void;
1
+ import React from 'react';
2
+ export declare const useOnClickOutside: (refs: React.RefObject<HTMLDivElement>[], handler: () => void) => void;
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const useOnEscape: (ref: React.RefObject<HTMLElement>, handler: () => void) => void;
1
+ import React from 'react';
2
+ export declare const useOnEscape: (ref: React.RefObject<HTMLElement>, handler: () => void) => void;
@@ -1 +1 @@
1
- export declare function useOnMount(callback: () => void): void;
1
+ export declare function useOnMount(callback: () => void): void;
@@ -1 +1 @@
1
- export declare const useRandomId: (prefix?: string) => string;
1
+ export declare const useRandomId: (prefix?: string) => string;
@@ -1,4 +1,6 @@
1
- export declare const useWindowDimensions: () => {
2
- width: number;
3
- height: number;
4
- };
1
+ type WindowDimensions = {
2
+ width: number | undefined;
3
+ height: number | undefined;
4
+ };
5
+ export declare const useWindowDimensions: () => WindowDimensions;
6
+ export {};
@@ -5,11 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
  var warning = require('tiny-warning');
7
7
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
- var warning__default = /*#__PURE__*/_interopDefaultLegacy(warning);
12
-
13
8
  function debounce(fn, delay) {
14
9
  var id;
15
10
  return function () {
@@ -24,13 +19,13 @@ function debounce(fn, delay) {
24
19
  }
25
20
 
26
21
  var useRandomId = function useRandomId(prefix) {
27
- var ref = React__default["default"].useRef(String(Math.random()).substring(2));
22
+ var ref = React.useRef(String(Math.random()).substring(2));
28
23
  return prefix + "-" + ref.current;
29
24
  };
30
25
 
31
26
  function useOnMount(callback) {
32
- var hasRun = React__default["default"].useRef(false);
33
- React__default["default"].useEffect(function () {
27
+ var hasRun = React.useRef(false);
28
+ React.useEffect(function () {
34
29
  if (!hasRun.current) {
35
30
  hasRun.current = true;
36
31
  callback();
@@ -116,6 +111,10 @@ var useOnEscape = function useOnEscape(ref, handler) {
116
111
 
117
112
  // from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs
118
113
  var getWindowDimensions = function getWindowDimensions() {
114
+ if (typeof window === 'undefined') return {
115
+ width: undefined,
116
+ height: undefined
117
+ };
119
118
  var _window = window,
120
119
  width = _window.innerWidth,
121
120
  height = _window.innerHeight;
@@ -132,10 +131,12 @@ var useWindowDimensions = function useWindowDimensions() {
132
131
  function handleResize() {
133
132
  setWindowDimensions(getWindowDimensions());
134
133
  }
135
- window.addEventListener('resize', handleResize);
136
- return function () {
137
- return window.removeEventListener('resize', handleResize);
138
- };
134
+ if (typeof window !== 'undefined') {
135
+ window.addEventListener('resize', handleResize);
136
+ return function () {
137
+ return window.removeEventListener('resize', handleResize);
138
+ };
139
+ }
139
140
  }, []);
140
141
  return windowDimensions;
141
142
  };
@@ -144,7 +145,7 @@ var ConditionalWrapper = function ConditionalWrapper(_ref) {
144
145
  var condition = _ref.condition,
145
146
  wrapper = _ref.wrapper,
146
147
  children = _ref.children;
147
- return condition ? wrapper(children) : React__default["default"].createElement(React__default["default"].Fragment, null, children);
148
+ return condition ? wrapper(children) : React.createElement(React.Fragment, null, children);
148
149
  };
149
150
 
150
151
  var packagesToCheck = /*#__PURE__*/new Set();
@@ -155,7 +156,7 @@ function checkAndWarn() {
155
156
  }).sort();
156
157
  // Finally, we warn about those pesky imports
157
158
  var singleMissingImport = missingImports.length === 1;
158
- warning__default["default"](missingImports.length === 0, "You are missing " + (singleMissingImport ? 'a CSS import' : missingImports.length + " CSS imports") + "!\n\nPlease add the following CSS import" + (singleMissingImport ? '' : 's') + " somewhere in your app:\n\n" + missingImports.map(function (namespace) {
159
+ warning(missingImports.length === 0, "You are missing " + (singleMissingImport ? 'a CSS import' : missingImports.length + " CSS imports") + "!\n\nPlease add the following CSS import" + (singleMissingImport ? '' : 's') + " somewhere in your app:\n\n" + missingImports.map(function (namespace) {
159
160
  return "\t@import '@entur/" + namespace + "/dist/styles.css';";
160
161
  }).join('\n') + "\n") ;
161
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.development.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/warnAboutMissingStyles.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\nconst getWindowDimensions = () => {\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = () => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["debounce","fn","delay","id","args","clearTimeout","setTimeout","useRandomId","prefix","ref","React","useRef","String","Math","random","substring","current","useOnMount","callback","hasRun","useEffect","mergeRefs","refs","node","useForceUpdate","useState","setValue","value","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","currentRef","getWindowDimensions","width","innerWidth","height","innerHeight","useWindowDimensions","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","createElement","Fragment","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;;;;;;;;;;AAAgB,SAAAA,QAAQ,CACtBC,EAAK,EACLC,KAAa,EAAA;AAEb,EAAA,IAAIC,EAAO,CAAA;AACX,EAAA,OAAO,YAAY;AAAA,IAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAARC,IAAI,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;MAAJA,IAAI,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,KAAA;IACbC,YAAY,CAACF,EAAE,CAAC,CAAA;IAChBA,EAAE,GAAGG,UAAU,CAAC,YAAA;MAAA,OAAML,EAAE,CAAIG,KAAAA,CAAAA,KAAAA,CAAAA,EAAAA,IAAI,CAAC,CAAA;AAAA,KAAA,EAAEF,KAAK,CAAC,CAAA;GAC1C,CAAA;AACH;;ICPaK,WAAW,GAAG,SAAdA,WAAW,CAAIC,MAAe,EAAY;AACrD,EAAA,IAAMC,GAAG,GAAGC,yBAAK,CAACC,MAAM,CAACC,MAAM,CAACC,IAAI,CAACC,MAAM,EAAE,CAAC,CAACC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5D,EAAA,OAAUP,MAAM,GAAA,GAAA,GAAIC,GAAG,CAACO,OAAO,CAAA;AACjC;;ACHM,SAAUC,UAAU,CAACC,QAAoB,EAAA;AAC7C,EAAA,IAAMC,MAAM,GAAGT,yBAAK,CAACC,MAAM,CAAU,KAAK,CAAC,CAAA;EAE3CD,yBAAK,CAACU,SAAS,CAAC,YAAK;AACnB,IAAA,IAAI,CAACD,MAAM,CAACH,OAAO,EAAE;MACnBG,MAAM,CAACH,OAAO,GAAG,IAAI,CAAA;AACrBE,MAAAA,QAAQ,EAAE,CA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CAAC,CAAA;AACvD,EAAAC,2BAAO,CACLZ,cAAc,CAACW,MAAM,KAAK,CAAC,EAAA,kBAAA,IAEzBD,mBAAmB,GACf,cAAc,GACXV,cAAc,CAACW,MAAM,GAAA,cAC9B,CAGED,GAAAA,0CAAAA,IAAAA,mBAAmB,GAAG,EAAE,GAAG,GAC7B,CAEFV,GAAAA,6BAAAA,GAAAA,cAAc,CACba,GAAG,CAAC,UAAAT,SAAS,EAAA;AAAA,IAAA,OAAA,oBAAA,GAAyBA,SAAS,GAAA,oBAAA,CAAA;AAAA,GAAoB,CAAC,CACpEU,IAAI,CAAC,IAAI,CAAC,GAEV,IAAA,CAAA,CAAA,CAAA;AACH,CAAA;AAEA;AACgB,SAAAC,sBAAsB,GAAwB;AAC5D;AACA,EAAA,IAAgB,OAAOvC,MAAM,KAAK,WAAW,EAAE;AAC7C,IAAA,OAAA;AACD,GAAA;AACD;AACAA,EAAAA,MAAM,CAACtC,YAAY,CAAC4D,cAAc,CAAC,CAAA;AAEnC;AAAA,EAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EARwCkB,UAAoB,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;IAApBA,UAAoB,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAS5DA,EAAAA,UAAU,CAACC,OAAO,CAAC,UAAAb,SAAS,EAAA;AAAA,IAAA,OAAIR,eAAe,CAACsB,GAAG,CAACd,SAAS,CAAC,CAAA;GAAC,CAAA,CAAA;AAE/D;EACAN,cAAc,GAAGtB,MAAM,CAACrC,UAAU,CAAC4D,YAAY,EAAE,IAAI,CAAC,CAAA;AACxD;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs.development.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/warnAboutMissingStyles.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\ntype WindowDimensions = {\n width: number | undefined;\n height: number | undefined;\n};\n\nconst getWindowDimensions = () => {\n if (typeof window === 'undefined')\n return { width: undefined, height: undefined };\n\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = (): WindowDimensions => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["debounce","fn","delay","id","args","clearTimeout","setTimeout","useRandomId","prefix","ref","React","useRef","String","Math","random","substring","current","useOnMount","callback","hasRun","useEffect","mergeRefs","refs","node","useForceUpdate","useState","setValue","value","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","currentRef","getWindowDimensions","width","undefined","height","innerWidth","innerHeight","useWindowDimensions","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","createElement","Fragment","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;;;;;AAAgB,SAAAA,QAAQ,CACtBC,EAAK,EACLC,KAAa,EAAA;AAEb,EAAA,IAAIC,EAAO,CAAA;AACX,EAAA,OAAO,YAAY;AAAA,IAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAARC,IAAI,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IA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,mBAAmB,GAAG,EAAE,GAAG,GAC7B,CAEFV,GAAAA,6BAAAA,GAAAA,cAAc,CACba,GAAG,CAAC,UAAAT,SAAS,EAAA;AAAA,IAAA,OAAA,oBAAA,GAAyBA,SAAS,GAAA,oBAAA,CAAA;AAAA,GAAoB,CAAC,CACpEU,IAAI,CAAC,IAAI,CAAC,GAEV,IAAA,CAAA,CAAA,CAAA;AACH,CAAA;AAEA;AACgB,SAAAC,sBAAsB,GAAwB;AAC5D;AACA,EAAA,IAAgB,OAAOxC,MAAM,KAAK,WAAW,EAAE;AAC7C,IAAA,OAAA;AACD,GAAA;AACD;AACAA,EAAAA,MAAM,CAACtC,YAAY,CAAC6D,cAAc,CAAC,CAAA;AAEnC;AAAA,EAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EARwCkB,UAAoB,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;IAApBA,UAAoB,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAS5DA,EAAAA,UAAU,CAACC,OAAO,CAAC,UAAAb,SAAS,EAAA;AAAA,IAAA,OAAIR,eAAe,CAACsB,GAAG,CAACd,SAAS,CAAC,CAAA;GAAC,CAAA,CAAA;AAE/D;EACAN,cAAc,GAAGvB,MAAM,CAACrC,UAAU,CAAC6D,YAAY,EAAE,IAAI,CAAC,CAAA;AACxD;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("tiny-warning");var t=n(e),r=function(){var e=window;return{width:e.innerWidth,height:e.innerHeight}};exports.ConditionalWrapper=function(e){var n=e.children;return e.condition?(0,e.wrapper)(n):t.default.createElement(t.default.Fragment,null,n)},exports.debounce=function(e,n){var t;return function(){for(var r=arguments.length,u=new Array(r),o=0;o<r;o++)u[o]=arguments[o];clearTimeout(t),t=setTimeout((function(){return e.apply(void 0,u)}),n)}},exports.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return function(e){for(var t=0,r=n;t<r.length;t++){var u=r[t];"function"==typeof u?u(e):u&&(u.current=e)}}},exports.useForceUpdate=function(){var n=e.useState(0)[1];return function(){return n((function(e){return e+1}))}},exports.useOnClickOutside=function(n,t){e.useEffect((function(){var e=function(e){n.some((function(n){return function(e,n){return!(!e||!(e.contains(n.target)||n.composed&&n.composedPath&&n.composedPath().find((function(n){return n!==window&&e.contains(n)}))))}(n.current,e)}))||t()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},exports.useOnEscape=function(n,t){e.useEffect((function(){var e=function(e){"Escape"===e.key&&t()},r=n.current;return null==r||r.addEventListener("keydown",e),function(){return null==r?void 0:r.removeEventListener("keydown",e)}}),[n,t])},exports.useOnMount=function(e){var n=t.default.useRef(!1);t.default.useEffect((function(){n.current||(n.current=!0,e())}),[e])},exports.useRandomId=function(e){return e+"-"+t.default.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var n=e.useState(r()),t=n[0],u=n[1];return e.useEffect((function(){function e(){u(r())}return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),t},exports.warnAboutMissingStyles=function(){};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("tiny-warning");var n=function(){if("undefined"==typeof window)return{width:void 0,height:void 0};var e=window;return{width:e.innerWidth,height:e.innerHeight}};exports.ConditionalWrapper=function(n){var t=n.children;return n.condition?(0,n.wrapper)(t):e.createElement(e.Fragment,null,t)},exports.debounce=function(e,n){var t;return function(){for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return e.apply(void 0,o)}),n)}},exports.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return function(e){for(var t=0,r=n;t<r.length;t++){var o=r[t];"function"==typeof o?o(e):o&&(o.current=e)}}},exports.useForceUpdate=function(){var n=e.useState(0)[1];return function(){return n((function(e){return e+1}))}},exports.useOnClickOutside=function(n,t){e.useEffect((function(){var e=function(e){n.some((function(n){return function(e,n){return!(!e||!(e.contains(n.target)||n.composed&&n.composedPath&&n.composedPath().find((function(n){return n!==window&&e.contains(n)}))))}(n.current,e)}))||t()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},exports.useOnEscape=function(n,t){e.useEffect((function(){var e=function(e){"Escape"===e.key&&t()},r=n.current;return null==r||r.addEventListener("keydown",e),function(){return null==r?void 0:r.removeEventListener("keydown",e)}}),[n,t])},exports.useOnMount=function(n){var t=e.useRef(!1);e.useEffect((function(){t.current||(t.current=!0,n())}),[n])},exports.useRandomId=function(n){return n+"-"+e.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var t=e.useState(n()),r=t[0],o=t[1];return e.useEffect((function(){function e(){o(n())}if("undefined"!=typeof window)return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),r},exports.warnAboutMissingStyles=function(){};
2
2
  //# sourceMappingURL=utils.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.production.min.js","sources":["../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/debounce.ts","../src/mergeRefs.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useOnMount.ts","../src/useRandomId.ts","../src/warnAboutMissingStyles.ts"],"sourcesContent":["// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\nconst getWindowDimensions = () => {\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = () => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["getWindowDimensions","_window","window","width","innerWidth","height","innerHeight","_ref","children","condition","wrapper","React","createElement","Fragment","fn","delay","id","_len","arguments","length","args","Array","_key","clearTimeout","setTimeout","refs","node","_i","_refs","ref","current","useState","setValue","value","handler","useEffect","listener","event","some","element","contains","target","composed","composedPath","find","elementContainsEventTarget","document","addEventListener","removeEventListener","runIfKeyIsEscape","key","currentRef","callback","hasRun","useRef","prefix","String","Math","random","substring","_useState","windowDimensions","setWindowDimensions","handleResize"],"mappings":"sMAGMA,EAAsB,WAC1B,IAAAC,EAAmDC,OACnD,MAAO,CACLC,QAFMC,WAGNC,SAHyBC,yCCIK,SAAHC,GAAA,IAG7BC,IAAAA,SAAQ,SAFRC,WAGyCC,IAFzCA,SAEiDF,GAAYG,EAAA,QAAAC,cAAAD,EAAAA,QAAAE,SAAA,KAAGL,qBCZlD,SACdM,EACAC,GAEA,IAAIC,EACJ,OAAO,WAAY,IAAA,IAAAC,EAAAC,UAAAC,OAARC,EAAI,IAAAC,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAJF,EAAIE,GAAAJ,UAAAI,GACbC,aAAaP,GACbA,EAAKQ,YAAW,WAAA,OAAMV,EAAMM,WAAAA,EAAAA,KAAOL,uBCPd,WAErB,IAAA,IAAAE,EAAAC,UAAAC,OADCM,EAAuE,IAAAJ,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAvEG,EAAuEH,GAAAJ,UAAAI,GAE1E,OAAO,SAACI,GACN,IAAA,IAAAC,EAAA,EAAAC,EAAkBH,EAAME,EAAAC,EAAAT,OAAAQ,IAAA,CAAnB,IAAME,EAAGD,EAAAD,GACO,mBAARE,EACTA,EAAIH,GACKG,IAAKA,EAAIC,QAAUJ,6BCLN,WACNK,IAAZC,EAAYD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,oBAAoB,SAAUe,MACjD,IAEIF,kCScO"}
1
+ {"version":3,"file":"utils.cjs.production.min.js","sources":["../src/mergeRefs.ts","../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/debounce.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useOnMount.ts","../src/useRandomId.ts","../src/warnAboutMissingStyles.ts"],"sourcesContent":["export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\ntype WindowDimensions = {\n width: number | undefined;\n height: number | undefined;\n};\n\nconst getWindowDimensions = () => {\n if (typeof window === 'undefined')\n return { width: undefined, height: undefined };\n\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = (): WindowDimensions => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["mergeRefs","getWindowDimensions","window","width","undefined","height","_window","innerWidth","innerHeight","_ref","children","condition","wrapper","React","createElement","Fragment","fn","delay","id","_len","arguments","length","args","Array","_key","clearTimeout","setTimeout","refs","node","_i","_refs","ref","current","useState","setValue","value","handler","useEffect","listener","event","some","element","contains","target","composed","composedPath","find","elementContainsEventTarget","document","addEventListener","removeEventListener","runIfKeyIsEscape","key","currentRef","callback","hasRun","useRef","prefix","String","Math","random","substring","_useState","windowDimensions","setWindowDimensions","handleResize"],"mappings":"mHAAaA,ICQPC,EAAsB,WAC1B,GAAsB,oBAAXC,OACT,MAAO,CAAEC,WAAOC,EAAWC,YAAQD,GAErC,IAAAE,EAAmDJ,OACnD,MAAO,CACLC,QAFMI,WAGNF,SAHyBG,YAK7B,6BCTkC,SAAHC,GAAA,IAG7BC,IAAAA,SAAQ,SAFRC,WAGyCC,IAFzCA,SAEiDF,GAAYG,EAAAC,cAAAD,EAAAE,SAAA,KAAGL,EAAY,mBCZ9D,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,WACR,IAAMc,EAAmB,SAACZ,GACN,WAAdA,EAAMa,KAAkBhB,KAGxBiB,EAAatB,EAAIC,QAGvB,OAFU,MAAVqB,GAAAA,EAAYJ,iBAAiB,UAAWE,GAEjC,WAAA,aAAME,SAAAA,EAAYH,oBAAoB,UAAWC,EAAiB,CAC3E,GAAG,CAACpB,EAAKK,GACX,qBCdM,SAAqBkB,GACzB,IAAMC,EAAS1C,EAAM2C,QAAgB,GAErC3C,EAAMwB,WAAU,WACTkB,EAAOvB,UACVuB,EAAOvB,SAAU,EACjBsB,IAEJ,GAAG,CAACA,GACN,sBCT2B,SAACG,GAE1B,OAAUA,EAAM,IADJ5C,EAAM2C,OAAOE,OAAOC,KAAKC,UAAUC,UAAU,IACjC7B,OAC1B,8BPcmC,WACjC,IAAA8B,EAAgD7B,WAC9ChC,KADK8D,EAAgBD,EAAA,GAAEE,EAAmBF,EAAA,GAe5C,OAXAzB,EAAAA,WAAU,WACR,SAAS4B,IACPD,EAAoB/D,IACtB,CAEA,GAAsB,oBAAXC,OAET,OADAA,OAAO+C,iBAAiB,SAAUgB,GAC3B,WAAA,OAAM/D,OAAOgD,oBAAoB,SAAUe,EAAa,CAElE,GAAE,IAEIF,CACT,iCQGgB,WAahB"}
package/dist/utils.esm.js CHANGED
@@ -107,6 +107,10 @@ var useOnEscape = function useOnEscape(ref, handler) {
107
107
 
108
108
  // from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs
109
109
  var getWindowDimensions = function getWindowDimensions() {
110
+ if (typeof window === 'undefined') return {
111
+ width: undefined,
112
+ height: undefined
113
+ };
110
114
  var _window = window,
111
115
  width = _window.innerWidth,
112
116
  height = _window.innerHeight;
@@ -123,10 +127,12 @@ var useWindowDimensions = function useWindowDimensions() {
123
127
  function handleResize() {
124
128
  setWindowDimensions(getWindowDimensions());
125
129
  }
126
- window.addEventListener('resize', handleResize);
127
- return function () {
128
- return window.removeEventListener('resize', handleResize);
129
- };
130
+ if (typeof window !== 'undefined') {
131
+ window.addEventListener('resize', handleResize);
132
+ return function () {
133
+ return window.removeEventListener('resize', handleResize);
134
+ };
135
+ }
130
136
  }, []);
131
137
  return windowDimensions;
132
138
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.esm.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/warnAboutMissingStyles.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\nconst getWindowDimensions = () => {\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = () => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["debounce","fn","delay","id","args","clearTimeout","setTimeout","useRandomId","prefix","ref","React","useRef","String","Math","random","substring","current","useOnMount","callback","hasRun","useEffect","mergeRefs","refs","node","useForceUpdate","useState","setValue","value","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","currentRef","getWindowDimensions","width","innerWidth","height","innerHeight","useWindowDimensions","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","createElement","Fragment","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;AAAgB,SAAAA,QAAQ,CACtBC,EAAK,EACLC,KAAa,EAAA;AAEb,EAAA,IAAIC,EAAO,CAAA;AACX,EAAA,OAAO,YAAY;AAAA,IAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA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,GAAAA,cAAc,CACba,GAAG,CAAC,UAAAT,SAAS,EAAA;AAAA,IAAA,OAAA,oBAAA,GAAyBA,SAAS,GAAA,oBAAA,CAAA;AAAA,GAAoB,CAAC,CACpEU,IAAI,CAAC,IAAI,CAAC,GAEV,IAAA,CAAA,GAAA,KAAA,CAAA,CAAA;AACH,CAAA;AAEA;AACgB,SAAAC,sBAAsB,GAAwB;AAC5D;AACA,EAAA,IAAI,wCAAQ,IAAI,OAAOvC,MAAM,KAAK,WAAW,EAAE;AAC7C,IAAA,OAAA;AACD,GAAA;AACD;AACAA,EAAAA,MAAM,CAACtC,YAAY,CAAC4D,cAAc,CAAC,CAAA;AAEnC;AAAA,EAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EARwCkB,UAAoB,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;IAApBA,UAAoB,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAS5DA,EAAAA,UAAU,CAACC,OAAO,CAAC,UAAAb,SAAS,EAAA;AAAA,IAAA,OAAIR,eAAe,CAACsB,GAAG,CAACd,SAAS,CAAC,CAAA;GAAC,CAAA,CAAA;AAE/D;EACAN,cAAc,GAAGtB,MAAM,CAACrC,UAAU,CAAC4D,YAAY,EAAE,IAAI,CAAC,CAAA;AACxD;;;;"}
1
+ {"version":3,"file":"utils.esm.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../src/useForceUpdate.ts","../src/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/warnAboutMissingStyles.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => any>(\n fn: T,\n delay: number,\n): (...args: Parameters<T>) => void {\n let id: any;\n return (...args) => {\n clearTimeout(id);\n id = setTimeout(() => fn(...args), delay);\n };\n}\n","import React from 'react';\n\nexport const useRandomId = (prefix?: string): string => {\n const ref = React.useRef(String(Math.random()).substring(2));\n return `${prefix}-${ref.current}`;\n};\n","import React from 'react';\n\nexport function useOnMount(callback: () => void): void {\n const hasRun = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!hasRun.current) {\n hasRun.current = true;\n callback();\n }\n }, [callback]);\n}\n","export const mergeRefs = <T extends HTMLElement>(\n ...refs: (React.MutableRefObject<T> | React.ForwardedRef<T> | undefined)[]\n) => {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) ref.current = node;\n }\n };\n};\n","import { useState } from 'react';\n\nexport const useForceUpdate = () => {\n const [_, setValue] = useState(0);\n return () => setValue(value => value + 1);\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnClickOutside = (\n refs: React.RefObject<HTMLDivElement>[],\n handler: () => void,\n) => {\n useEffect(() => {\n const listener = (event: Event) => {\n // If the ref contains the clicked element, then the click is not outside\n if (refs.some(ref => elementContainsEventTarget(ref.current, event))) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [refs, handler]);\n};\n\nconst elementContainsEventTarget = (\n element: HTMLElement | null,\n event: Event,\n) => {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n};\n","import React, { useEffect } from 'react';\n\nexport const useOnEscape = (\n ref: React.RefObject<HTMLElement>,\n handler: () => void,\n) => {\n useEffect(() => {\n const runIfKeyIsEscape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') handler();\n };\n\n const currentRef = ref.current;\n currentRef?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => currentRef?.removeEventListener('keydown', runIfKeyIsEscape);\n }, [ref, handler]);\n};\n","// from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs\nimport { useState, useEffect } from 'react';\n\ntype WindowDimensions = {\n width: number | undefined;\n height: number | undefined;\n};\n\nconst getWindowDimensions = () => {\n if (typeof window === 'undefined')\n return { width: undefined, height: undefined };\n\n const { innerWidth: width, innerHeight: height } = window;\n return {\n width,\n height,\n };\n};\n\nexport const useWindowDimensions = (): WindowDimensions => {\n const [windowDimensions, setWindowDimensions] = useState(\n getWindowDimensions(),\n );\n\n useEffect(() => {\n function handleResize() {\n setWindowDimensions(getWindowDimensions());\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }\n }, []);\n\n return windowDimensions;\n};\n","import React from 'react';\n\ntype ConditionalWrapperType = {\n condition: boolean;\n wrapper: any;\n children: any;\n};\n\nexport const ConditionalWrapper = ({\n condition,\n wrapper,\n children,\n}: ConditionalWrapperType) => (condition ? wrapper(children) : <>{children}</>);\n","import warning from 'tiny-warning';\n\nconst packagesToCheck: Set<string> = new Set();\nlet checkTimeoutId: number;\n\nfunction checkAndWarn() {\n const missingImports = Array.from(packagesToCheck)\n .filter(\n namespace =>\n parseInt(\n window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--eds-${namespace}`),\n ) !== 1,\n )\n .sort();\n\n // Finally, we warn about those pesky imports\n const singleMissingImport = missingImports.length === 1;\n warning(\n missingImports.length === 0,\n `You are missing ${\n singleMissingImport\n ? 'a CSS import'\n : `${missingImports.length} CSS imports`\n }!\n\nPlease add the following CSS import${\n singleMissingImport ? '' : 's'\n } somewhere in your app:\n\n${missingImports\n .map(namespace => `\\t@import '@entur/${namespace}/dist/styles.css';`)\n .join('\\n')}\n`,\n );\n}\n\n/** Warns the developer if they have forgotten to include styles */\nexport function warnAboutMissingStyles(...namespaces: string[]): void {\n // We skip this check in production, and when we build static sites\n if (!__DEV__ || typeof window === 'undefined') {\n return;\n }\n // First, let's clear earlier calls to setTimeout\n window.clearTimeout(checkTimeoutId);\n\n // Next, let's add all namespaces to the set of packages to check\n namespaces.forEach(namespace => packagesToCheck.add(namespace));\n\n // Finally. let's trigger a run of the checker.\n checkTimeoutId = window.setTimeout(checkAndWarn, 1000);\n}\n"],"names":["debounce","fn","delay","id","args","clearTimeout","setTimeout","useRandomId","prefix","ref","React","useRef","String","Math","random","substring","current","useOnMount","callback","hasRun","useEffect","mergeRefs","refs","node","useForceUpdate","useState","setValue","value","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","currentRef","getWindowDimensions","width","undefined","height","innerWidth","innerHeight","useWindowDimensions","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","createElement","Fragment","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;AAAgB,SAAAA,QAAQ,CACtBC,EAAK,EACLC,KAAa,EAAA;AAEb,EAAA,IAAIC,EAAO,CAAA;AACX,EAAA,OAAO,YAAY;AAAA,IAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAARC,IAAI,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;MAAJA,IAAI,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,KAAA;IACbC,YAAY,CAACF,EAAE,CAAC,CAAA;IAChBA,EAAE,GAAGG,UAAU,CAAC,YAAA;MAAA,OAAML,EAAE,CAAIG,KAAAA,CAAAA,KAAA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,CAAC,CACpEU,IAAI,CAAC,IAAI,CAAC,GAEV,IAAA,CAAA,GAAA,KAAA,CAAA,CAAA;AACH,CAAA;AAEA;AACgB,SAAAC,sBAAsB,GAAwB;AAC5D;AACA,EAAA,IAAI,wCAAQ,IAAI,OAAOxC,MAAM,KAAK,WAAW,EAAE;AAC7C,IAAA,OAAA;AACD,GAAA;AACD;AACAA,EAAAA,MAAM,CAACtC,YAAY,CAAC6D,cAAc,CAAC,CAAA;AAEnC;AAAA,EAAA,KAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EARwCkB,UAAoB,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,EAAA;IAApBA,UAAoB,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAS5DA,EAAAA,UAAU,CAACC,OAAO,CAAC,UAAAb,SAAS,EAAA;AAAA,IAAA,OAAIR,eAAe,CAACsB,GAAG,CAACd,SAAS,CAAC,CAAA;GAAC,CAAA,CAAA;AAE/D;EACAN,cAAc,GAAGvB,MAAM,CAACrC,UAAU,CAAC6D,YAAY,EAAE,IAAI,CAAC,CAAA;AACxD;;;;"}
@@ -1,2 +1,2 @@
1
- /** Warns the developer if they have forgotten to include styles */
2
- export declare function warnAboutMissingStyles(...namespaces: string[]): void;
1
+ /** Warns the developer if they have forgotten to include styles */
2
+ export declare function warnAboutMissingStyles(...namespaces: string[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/utils",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/utils.esm.js",
@@ -28,5 +28,5 @@
28
28
  "dependencies": {
29
29
  "tiny-warning": "^1.0.3"
30
30
  },
31
- "gitHead": "9bf0838160519db9fb072af36dc19731dfb5e2dd"
31
+ "gitHead": "9b8d4e5d2e6f7a74256371e30ebef43e046c9338"
32
32
  }