@entur/utils 0.5.1 → 0.5.3

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,4 +1,4 @@
1
- declare type ConditionalWrapperType = {
1
+ type ConditionalWrapperType = {
2
2
  condition: boolean;
3
3
  wrapper: any;
4
4
  children: any;
@@ -2,8 +2,8 @@
2
2
  * https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
3
3
  */
4
4
  import React from 'react';
5
- export declare type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;
6
- declare type AsProp<C extends React.ElementType> = {
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
7
  /**
8
8
  * An override of the default HTML tag.
9
9
  * Can also be another React component.
@@ -15,27 +15,27 @@ declare type AsProp<C extends React.ElementType> = {
15
15
  * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
16
16
  * set of props.
17
17
  */
18
- export declare type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
18
+ export type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
19
19
  /**
20
20
  * Allows for inheriting the props from the specified element type so that
21
21
  * props like children, className & style work, as well as element-specific
22
22
  * attributes like aria roles. The component (`C`) must be passed in.
23
23
  */
24
- export declare type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
24
+ export type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
25
25
  /**
26
26
  * A more sophisticated version of `InheritableElementProps` where
27
27
  * the passed in `as` prop will determine which props can be included
28
28
  */
29
- export declare type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
29
+ export type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
30
30
  /**
31
31
  * Utility type to extract the `ref` prop from a polymorphic component
32
32
  */
33
- export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
33
+ export type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
34
34
  /**
35
35
  * A wrapper of `PolymorphicComponentProps` that also includes the `ref`
36
36
  * prop for the polymorphic component
37
37
  */
38
- export declare type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
38
+ export type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
39
39
  ref?: PolymorphicRef<C>;
40
40
  };
41
41
  export {};
@@ -1 +1 @@
1
- export declare const useRandomId: (prefix?: string | undefined) => string;
1
+ export declare const useRandomId: (prefix?: string) => string;
@@ -16,7 +16,6 @@ function debounce(fn, delay) {
16
16
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17
17
  args[_key] = arguments[_key];
18
18
  }
19
-
20
19
  clearTimeout(id);
21
20
  id = setTimeout(function () {
22
21
  return fn.apply(void 0, args);
@@ -39,53 +38,13 @@ function useOnMount(callback) {
39
38
  }, [callback]);
40
39
  }
41
40
 
42
- function _unsupportedIterableToArray(o, minLen) {
43
- if (!o) return;
44
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
45
- var n = Object.prototype.toString.call(o).slice(8, -1);
46
- if (n === "Object" && o.constructor) n = o.constructor.name;
47
- if (n === "Map" || n === "Set") return Array.from(o);
48
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
49
- }
50
-
51
- function _arrayLikeToArray(arr, len) {
52
- if (len == null || len > arr.length) len = arr.length;
53
-
54
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
55
-
56
- return arr2;
57
- }
58
-
59
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
60
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
61
- if (it) return (it = it.call(o)).next.bind(it);
62
-
63
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
64
- if (it) o = it;
65
- var i = 0;
66
- return function () {
67
- if (i >= o.length) return {
68
- done: true
69
- };
70
- return {
71
- done: false,
72
- value: o[i++]
73
- };
74
- };
75
- }
76
-
77
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
78
- }
79
-
80
41
  var mergeRefs = function mergeRefs() {
81
42
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
82
43
  refs[_key] = arguments[_key];
83
44
  }
84
-
85
45
  return function (node) {
86
- for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
87
- var ref = _step.value;
88
-
46
+ for (var _i = 0, _refs = refs; _i < _refs.length; _i++) {
47
+ var ref = _refs[_i];
89
48
  if (typeof ref === 'function') {
90
49
  ref(node);
91
50
  } else if (ref) ref.current = node;
@@ -102,10 +61,8 @@ var useOnClickOutside = function useOnClickOutside(refs, handler) {
102
61
  })) {
103
62
  return;
104
63
  }
105
-
106
64
  handler();
107
65
  };
108
-
109
66
  document.addEventListener('mousedown', listener);
110
67
  document.addEventListener('touchstart', listener);
111
68
  return function () {
@@ -114,70 +71,57 @@ var useOnClickOutside = function useOnClickOutside(refs, handler) {
114
71
  };
115
72
  }, [refs, handler]);
116
73
  };
117
-
118
74
  var elementContainsEventTarget = function elementContainsEventTarget(element, event) {
119
75
  if (!element) {
120
76
  return false;
121
77
  }
122
-
123
78
  if (element.contains(event.target)) {
124
79
  return true;
125
- } // For elements inside a Shadow DOM we need to check the composedPath
126
-
127
-
80
+ }
81
+ // For elements inside a Shadow DOM we need to check the composedPath
128
82
  if (event.composed && event.composedPath) {
129
83
  var contains = event.composedPath().find(function (target) {
130
84
  if (target === window) {
131
85
  return false;
132
86
  }
133
-
134
87
  return element.contains(target);
135
88
  });
136
89
  return contains ? true : false;
137
90
  }
138
-
139
91
  return false;
140
92
  };
141
93
 
142
94
  var useOnEscape = function useOnEscape(ref, handler) {
143
95
  React.useEffect(function () {
144
- var _ref$current;
145
-
146
96
  var runIfKeyIsEscape = function runIfKeyIsEscape(event) {
147
97
  if (event.key === 'Escape') handler();
148
98
  };
149
-
150
- (_ref$current = ref.current) == null ? void 0 : _ref$current.addEventListener('keydown', runIfKeyIsEscape);
99
+ var currentRef = ref.current;
100
+ currentRef == null ? void 0 : currentRef.addEventListener('keydown', runIfKeyIsEscape);
151
101
  return function () {
152
- var _ref$current2;
153
-
154
- return (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.removeEventListener('keydown', runIfKeyIsEscape);
102
+ return currentRef == null ? void 0 : currentRef.removeEventListener('keydown', runIfKeyIsEscape);
155
103
  };
156
104
  }, [ref, handler]);
157
105
  };
158
106
 
159
107
  // from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs
160
-
161
108
  var getWindowDimensions = function getWindowDimensions() {
162
109
  var _window = window,
163
- width = _window.innerWidth,
164
- height = _window.innerHeight;
110
+ width = _window.innerWidth,
111
+ height = _window.innerHeight;
165
112
  return {
166
113
  width: width,
167
114
  height: height
168
115
  };
169
116
  };
170
-
171
117
  var useWindowDimensions = function useWindowDimensions() {
172
118
  var _useState = React.useState(getWindowDimensions()),
173
- windowDimensions = _useState[0],
174
- setWindowDimensions = _useState[1];
175
-
119
+ windowDimensions = _useState[0],
120
+ setWindowDimensions = _useState[1];
176
121
  React.useEffect(function () {
177
122
  function handleResize() {
178
123
  setWindowDimensions(getWindowDimensions());
179
124
  }
180
-
181
125
  window.addEventListener('resize', handleResize);
182
126
  return function () {
183
127
  return window.removeEventListener('resize', handleResize);
@@ -188,44 +132,39 @@ var useWindowDimensions = function useWindowDimensions() {
188
132
 
189
133
  var ConditionalWrapper = function ConditionalWrapper(_ref) {
190
134
  var condition = _ref.condition,
191
- wrapper = _ref.wrapper,
192
- children = _ref.children;
135
+ wrapper = _ref.wrapper,
136
+ children = _ref.children;
193
137
  return condition ? wrapper(children) : React__default["default"].createElement(React__default["default"].Fragment, null, children);
194
138
  };
195
139
 
196
140
  var packagesToCheck = /*#__PURE__*/new Set();
197
141
  var checkTimeoutId;
198
-
199
142
  function checkAndWarn() {
200
143
  var missingImports = Array.from(packagesToCheck).filter(function (namespace) {
201
144
  return parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--eds-" + namespace)) !== 1;
202
- }).sort(); // Finally, we warn about those pesky imports
203
-
145
+ }).sort();
146
+ // Finally, we warn about those pesky imports
204
147
  var singleMissingImport = missingImports.length === 1;
205
148
  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) {
206
149
  return "\t@import '@entur/" + namespace + "/dist/styles.css';";
207
150
  }).join('\n') + "\n") ;
208
151
  }
209
152
  /** Warns the developer if they have forgotten to include styles */
210
-
211
-
212
153
  function warnAboutMissingStyles() {
213
154
  // We skip this check in production, and when we build static sites
214
155
  if (typeof window === 'undefined') {
215
156
  return;
216
- } // First, let's clear earlier calls to setTimeout
217
-
218
-
219
- window.clearTimeout(checkTimeoutId); // Next, let's add all namespaces to the set of packages to check
220
-
157
+ }
158
+ // First, let's clear earlier calls to setTimeout
159
+ window.clearTimeout(checkTimeoutId);
160
+ // Next, let's add all namespaces to the set of packages to check
221
161
  for (var _len = arguments.length, namespaces = new Array(_len), _key = 0; _key < _len; _key++) {
222
162
  namespaces[_key] = arguments[_key];
223
163
  }
224
-
225
164
  namespaces.forEach(function (namespace) {
226
165
  return packagesToCheck.add(namespace);
227
- }); // Finally. let's trigger a run of the checker.
228
-
166
+ });
167
+ // Finally. let's trigger a run of the checker.
229
168
  checkTimeoutId = window.setTimeout(checkAndWarn, 1000);
230
169
  }
231
170
 
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.development.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.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>[]\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 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 ref.current?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => ref.current?.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","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","getWindowDimensions","width","innerWidth","height","innerHeight","useWindowDimensions","useState","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;;;;;;;;;;SAAgBA,SACdC,IACAC;AAEA,MAAIC,EAAJ;AACA,SAAO;sCAAIC;AAAAA,MAAAA;;;AACTC,IAAAA,YAAY,CAACF,EAAD,CAAZ;AACAA,IAAAA,EAAE,GAAGG,UAAU,CAAC;AAAA,aAAML,EAAE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ArC;AACA,IAAIC,cAAJ;;AAEA,SAASC,YAAT;AACE,MAAMC,cAAc,GAAGC,KAAK,CAACC,IAAN,CAAWN,eAAX,EACpBO,MADoB,CAEnB,UAAAC,SAAS;AAAA,WACPC,QAAQ,CACN3B,MAAM,CACH4B,gBADH,CACoBrC,QAAQ,CAACsC,eAD7B,EAEGC,gBAFH,YAE6BJ,SAF7B,CADM,CAAR,KAIM,CALC;AAAA,GAFU,EASpBK,IAToB,EAAvB;;AAYA,MAAMC,mBAAmB,GAAGV,cAAc,CAACW,MAAf,KAA0B,CAAtD;AACA,EAAAC,2BAAO,CACLZ,cAAc,CAACW,MAAf,KAA0B,CADrB,wBAGHD,mBAAmB,GACf,cADe,GAEZV,cAAc,CAACW,MAFH,iBAHhB,kDASHD,mBAAmB,GAAG,EAAH,GAAQ,GATxB,oCAYPV,cAAc,CACba,GADD,CACK,UAAAT,SAAS;AAAA,kCAAyBA,SAAzB;AAAA,GADd,EAECU,IAFD,CAEM,IAFN,CAZO,QAAP;AAiBD;AAED;;;SACgBC;AACd;AACA,MAAgB,OAAOrC,MAAP,KAAkB,WAAlC,EAA+C;AAC7C;AACD;;;AAEDA,EAAAA,MAAM,CAAClC,YAAP,CAAoBsD,cAApB;;oCANwCkB;AAAAA,IAAAA;;;AASxCA,EAAAA,UAAU,CAACC,OAAX,CAAmB,UAAAb,SAAS;AAAA,WAAIR,eAAe,CAACsB,GAAhB,CAAoBd,SAApB,CAAJ;AAAA,GAA5B;;AAGAN,EAAAA,cAAc,GAAGpB,MAAM,CAACjC,UAAP,CAAkBsD,YAAlB,EAAgC,IAAhC,CAAjB;AACD;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs.development.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.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>[]\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 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","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","useState","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,WA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AAA,CAAA;AAE/D;EACAN,cAAc,GAAGvB,MAAM,CAACjC,UAAU,CAACyD,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);function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function o(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=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,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,r=o(n);!(t=r()).done;){var u=t.value;"function"==typeof u?u(e):u&&(u.current=e)}}},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,r=function(e){"Escape"===e.key&&t()};return null==(e=n.current)||e.addEventListener("keydown",r),function(){var e;return null==(e=n.current)?void 0:e.removeEventListener("keydown",r)}}),[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(u()),t=n[0],r=n[1];return e.useEffect((function(){function e(){r(u())}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");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.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(){};
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/useOnClickOutside.ts","../src/useOnEscape.ts","../src/useOnMount.ts","../src/useRandomId.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>[]\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 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 ref.current?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => ref.current?.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"],"names":["getWindowDimensions","window","width","innerWidth","height","innerHeight","children","condition","wrapper","React","fn","delay","id","args","clearTimeout","setTimeout","refs","node","ref","current","handler","useEffect","listener","event","some","element","contains","target","composed","composedPath","find","elementContainsEventTarget","document","addEventListener","removeEventListener","runIfKeyIsEscape","key","_ref$current2","callback","hasRun","useRef","prefix","String","Math","random","substring","useState","windowDimensions","setWindowDimensions","handleResize"],"mappings":"ggCAGMA,EAAsB,iBACyBC,aAC5C,CACLC,QAFMC,WAGNC,SAHyBC,yCCIK,gBAGhCC,IAAAA,kBAFAC,WAGyCC,IAFzCA,SAEiDF,GAAYG,gDAAGH,8BCXhEI,EACAC,OAEIC,SACG,sCAAIC,2BAAAA,kBACTC,aAAaF,GACbA,EAAKG,YAAW,kBAAML,eAAMG,KAAOF,uBCPd,sCACpBK,2BAAAA,yBAEI,SAACC,iBACYD,kBAAM,KAAbE,UACU,mBAARA,EACTA,EAAID,GACKC,IAAKA,EAAIC,QAAUF,gCCLH,SAC/BD,EACAI,GAEAC,aAAU,eACFC,EAAW,SAACC,GAEZP,EAAKQ,MAAK,SAAAN,UAiBe,SACjCO,EACAF,YAEKE,KAIDA,EAAQC,SAASH,EAAMI,SAKvBJ,EAAMK,UAAYL,EAAMM,cACTN,EAAMM,eAAeC,MAAK,SAAAH,UACrCA,IAAW1B,QAGRwB,EAAQC,SAASC,QAnCHI,CAA2Bb,EAAIC,QAASI,OAI7DH,YAGFY,SAASC,iBAAiB,YAAaX,GACvCU,SAASC,iBAAiB,aAAcX,GAEjC,WACLU,SAASE,oBAAoB,YAAaZ,GAC1CU,SAASE,oBAAoB,aAAcZ,MAE5C,CAACN,EAAMI,yBCrBe,SACzBF,EACAE,GAEAC,aAAU,iBACFc,EAAmB,SAACZ,GACN,WAAdA,EAAMa,KAAkBhB,qBAG9BF,EAAIC,YAASc,iBAAiB,UAAWE,GAElC,iCAAMjB,EAAIC,gBAAJkB,EAAaH,oBAAoB,UAAWC,MACxD,CAACjB,EAAKE,iCCZgBkB,OACnBC,EAAS9B,UAAM+B,QAAgB,GAErC/B,UAAMY,WAAU,WACTkB,EAAOpB,UACVoB,EAAOpB,SAAU,EACjBmB,OAED,CAACA,yBCRqB,SAACG,UAEhBA,MADEhC,UAAM+B,OAAOE,OAAOC,KAAKC,UAAUC,UAAU,IACjC1B,qCPOS,iBACe2B,WAC9C9C,KADK+C,OAAkBC,cAIzB3B,aAAU,oBACC4B,IACPD,EAAoBhD,YAGtBC,OAAOgC,iBAAiB,SAAUgB,GAC3B,kBAAMhD,OAAOiC,oBAAoB,SAAUe,MACjD,IAEIF"}
1
+ {"version":3,"file":"utils.cjs.production.min.js","sources":["../src/useWindowDimensions.ts","../src/ConditionalWrapper.tsx","../src/debounce.ts","../src/mergeRefs.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>[]\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 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","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","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,GAAY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iBAAiB,UAAWE,GAEjC,WAAA,aAAME,SAAAA,EAAYH,oBAAoB,UAAWC,MACvD,CAACjB,EAAKE,wBCbL,SAAqBkB,GACzB,IAAMC,EAASvC,EAAAA,QAAMwC,QAAgB,GAErCxC,EAAK,QAACqB,WAAU,WACTkB,EAAOpB,UACVoB,EAAOpB,SAAU,EACjBmB,OAED,CAACA,yBCRqB,SAACG,GAE1B,OAAUA,EAAM,IADJzC,EAAAA,QAAMwC,OAAOE,OAAOC,KAAKC,UAAUC,UAAU,IACjC1B,qCPOS,WACjC,IAAA2B,EAAgDC,WAC9C1D,KADK2D,EAAgBF,EAAA,GAAEG,EAAmBH,EAAA,GAa5C,OATAzB,EAAAA,WAAU,WACR,SAAS6B,IACPD,EAAoB5D,KAItB,OADAE,OAAO0C,iBAAiB,SAAUiB,GAC3B,WAAA,OAAM3D,OAAO2C,oBAAoB,SAAUgB,MACjD,IAEIF,kCQcO"}
package/dist/utils.esm.js CHANGED
@@ -7,7 +7,6 @@ function debounce(fn, delay) {
7
7
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
8
  args[_key] = arguments[_key];
9
9
  }
10
-
11
10
  clearTimeout(id);
12
11
  id = setTimeout(function () {
13
12
  return fn.apply(void 0, args);
@@ -30,53 +29,13 @@ function useOnMount(callback) {
30
29
  }, [callback]);
31
30
  }
32
31
 
33
- function _unsupportedIterableToArray(o, minLen) {
34
- if (!o) return;
35
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
36
- var n = Object.prototype.toString.call(o).slice(8, -1);
37
- if (n === "Object" && o.constructor) n = o.constructor.name;
38
- if (n === "Map" || n === "Set") return Array.from(o);
39
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
40
- }
41
-
42
- function _arrayLikeToArray(arr, len) {
43
- if (len == null || len > arr.length) len = arr.length;
44
-
45
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
46
-
47
- return arr2;
48
- }
49
-
50
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
51
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
52
- if (it) return (it = it.call(o)).next.bind(it);
53
-
54
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
55
- if (it) o = it;
56
- var i = 0;
57
- return function () {
58
- if (i >= o.length) return {
59
- done: true
60
- };
61
- return {
62
- done: false,
63
- value: o[i++]
64
- };
65
- };
66
- }
67
-
68
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
69
- }
70
-
71
32
  var mergeRefs = function mergeRefs() {
72
33
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
73
34
  refs[_key] = arguments[_key];
74
35
  }
75
-
76
36
  return function (node) {
77
- for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
78
- var ref = _step.value;
79
-
37
+ for (var _i = 0, _refs = refs; _i < _refs.length; _i++) {
38
+ var ref = _refs[_i];
80
39
  if (typeof ref === 'function') {
81
40
  ref(node);
82
41
  } else if (ref) ref.current = node;
@@ -93,10 +52,8 @@ var useOnClickOutside = function useOnClickOutside(refs, handler) {
93
52
  })) {
94
53
  return;
95
54
  }
96
-
97
55
  handler();
98
56
  };
99
-
100
57
  document.addEventListener('mousedown', listener);
101
58
  document.addEventListener('touchstart', listener);
102
59
  return function () {
@@ -105,70 +62,57 @@ var useOnClickOutside = function useOnClickOutside(refs, handler) {
105
62
  };
106
63
  }, [refs, handler]);
107
64
  };
108
-
109
65
  var elementContainsEventTarget = function elementContainsEventTarget(element, event) {
110
66
  if (!element) {
111
67
  return false;
112
68
  }
113
-
114
69
  if (element.contains(event.target)) {
115
70
  return true;
116
- } // For elements inside a Shadow DOM we need to check the composedPath
117
-
118
-
71
+ }
72
+ // For elements inside a Shadow DOM we need to check the composedPath
119
73
  if (event.composed && event.composedPath) {
120
74
  var contains = event.composedPath().find(function (target) {
121
75
  if (target === window) {
122
76
  return false;
123
77
  }
124
-
125
78
  return element.contains(target);
126
79
  });
127
80
  return contains ? true : false;
128
81
  }
129
-
130
82
  return false;
131
83
  };
132
84
 
133
85
  var useOnEscape = function useOnEscape(ref, handler) {
134
86
  useEffect(function () {
135
- var _ref$current;
136
-
137
87
  var runIfKeyIsEscape = function runIfKeyIsEscape(event) {
138
88
  if (event.key === 'Escape') handler();
139
89
  };
140
-
141
- (_ref$current = ref.current) == null ? void 0 : _ref$current.addEventListener('keydown', runIfKeyIsEscape);
90
+ var currentRef = ref.current;
91
+ currentRef == null ? void 0 : currentRef.addEventListener('keydown', runIfKeyIsEscape);
142
92
  return function () {
143
- var _ref$current2;
144
-
145
- return (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.removeEventListener('keydown', runIfKeyIsEscape);
93
+ return currentRef == null ? void 0 : currentRef.removeEventListener('keydown', runIfKeyIsEscape);
146
94
  };
147
95
  }, [ref, handler]);
148
96
  };
149
97
 
150
98
  // from https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs
151
-
152
99
  var getWindowDimensions = function getWindowDimensions() {
153
100
  var _window = window,
154
- width = _window.innerWidth,
155
- height = _window.innerHeight;
101
+ width = _window.innerWidth,
102
+ height = _window.innerHeight;
156
103
  return {
157
104
  width: width,
158
105
  height: height
159
106
  };
160
107
  };
161
-
162
108
  var useWindowDimensions = function useWindowDimensions() {
163
109
  var _useState = useState(getWindowDimensions()),
164
- windowDimensions = _useState[0],
165
- setWindowDimensions = _useState[1];
166
-
110
+ windowDimensions = _useState[0],
111
+ setWindowDimensions = _useState[1];
167
112
  useEffect(function () {
168
113
  function handleResize() {
169
114
  setWindowDimensions(getWindowDimensions());
170
115
  }
171
-
172
116
  window.addEventListener('resize', handleResize);
173
117
  return function () {
174
118
  return window.removeEventListener('resize', handleResize);
@@ -179,44 +123,39 @@ var useWindowDimensions = function useWindowDimensions() {
179
123
 
180
124
  var ConditionalWrapper = function ConditionalWrapper(_ref) {
181
125
  var condition = _ref.condition,
182
- wrapper = _ref.wrapper,
183
- children = _ref.children;
126
+ wrapper = _ref.wrapper,
127
+ children = _ref.children;
184
128
  return condition ? wrapper(children) : React.createElement(React.Fragment, null, children);
185
129
  };
186
130
 
187
131
  var packagesToCheck = /*#__PURE__*/new Set();
188
132
  var checkTimeoutId;
189
-
190
133
  function checkAndWarn() {
191
134
  var missingImports = Array.from(packagesToCheck).filter(function (namespace) {
192
135
  return parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--eds-" + namespace)) !== 1;
193
- }).sort(); // Finally, we warn about those pesky imports
194
-
136
+ }).sort();
137
+ // Finally, we warn about those pesky imports
195
138
  var singleMissingImport = missingImports.length === 1;
196
139
  process.env.NODE_ENV !== "production" ? 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) {
197
140
  return "\t@import '@entur/" + namespace + "/dist/styles.css';";
198
141
  }).join('\n') + "\n") : void 0;
199
142
  }
200
143
  /** Warns the developer if they have forgotten to include styles */
201
-
202
-
203
144
  function warnAboutMissingStyles() {
204
145
  // We skip this check in production, and when we build static sites
205
146
  if (!(process.env.NODE_ENV !== "production") || typeof window === 'undefined') {
206
147
  return;
207
- } // First, let's clear earlier calls to setTimeout
208
-
209
-
210
- window.clearTimeout(checkTimeoutId); // Next, let's add all namespaces to the set of packages to check
211
-
148
+ }
149
+ // First, let's clear earlier calls to setTimeout
150
+ window.clearTimeout(checkTimeoutId);
151
+ // Next, let's add all namespaces to the set of packages to check
212
152
  for (var _len = arguments.length, namespaces = new Array(_len), _key = 0; _key < _len; _key++) {
213
153
  namespaces[_key] = arguments[_key];
214
154
  }
215
-
216
155
  namespaces.forEach(function (namespace) {
217
156
  return packagesToCheck.add(namespace);
218
- }); // Finally. let's trigger a run of the checker.
219
-
157
+ });
158
+ // Finally. let's trigger a run of the checker.
220
159
  checkTimeoutId = window.setTimeout(checkAndWarn, 1000);
221
160
  }
222
161
 
@@ -1 +1 @@
1
- {"version":3,"file":"utils.esm.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.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>[]\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 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 ref.current?.addEventListener('keydown', runIfKeyIsEscape);\n\n return () => ref.current?.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","useOnClickOutside","handler","listener","event","some","elementContainsEventTarget","document","addEventListener","removeEventListener","element","contains","target","composed","composedPath","find","window","useOnEscape","runIfKeyIsEscape","key","getWindowDimensions","width","innerWidth","height","innerHeight","useWindowDimensions","useState","windowDimensions","setWindowDimensions","handleResize","ConditionalWrapper","condition","wrapper","children","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","getComputedStyle","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles","namespaces","forEach","add"],"mappings":";;;SAAgBA,SACdC,IACAC;AAEA,MAAIC,EAAJ;AACA,SAAO;sCAAIC;AAAAA,MAAAA;;;AACTC,IAAAA,YAAY,CAACF,EAAD,CAAZ;AACAA,IAAAA,EAAE,GAAGG,UAAU,CAAC;AAAA,aAAML,EAAE,MAAF,SAAMG,IAAN,CAAN;AAAA,KAAD,EAAoBF,KAApB,CAAf;AACD,GAHD;AAID;;ICPYK,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD;AACzB,M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AAAA,WACPC,QAAQ,CACN3B,MAAM,CACH4B,gBADH,CACoBrC,QAAQ,CAACsC,eAD7B,EAEGC,gBAFH,YAE6BJ,SAF7B,CADM,CAAR,KAIM,CALC;AAAA,GAFU,EASpBK,IAToB,EAAvB;;AAYA,MAAMC,mBAAmB,GAAGV,cAAc,CAACW,MAAf,KAA0B,CAAtD;AACA,0CAAAC,OAAO,CACLZ,cAAc,CAACW,MAAf,KAA0B,CADrB,wBAGHD,mBAAmB,GACf,cADe,GAEZV,cAAc,CAACW,MAFH,iBAHhB,kDASHD,mBAAmB,GAAG,EAAH,GAAQ,GATxB,oCAYPV,cAAc,CACba,GADD,CACK,UAAAT,SAAS;AAAA,kCAAyBA,SAAzB;AAAA,GADd,EAECU,IAFD,CAEM,IAFN,CAZO,QAAP;AAiBD;AAED;;;SACgBC;AACd;AACA,MAAI,4CAAY,OAAOrC,MAAP,KAAkB,WAAlC,EAA+C;AAC7C;AACD;;;AAEDA,EAAAA,MAAM,CAAClC,YAAP,CAAoBsD,cAApB;;oCANwCkB;AAAAA,IAAAA;;;AASxCA,EAAAA,UAAU,CAACC,OAAX,CAAmB,UAAAb,SAAS;AAAA,WAAIR,eAAe,CAACsB,GAAhB,CAAoBd,SAApB,CAAJ;AAAA,GAA5B;;AAGAN,EAAAA,cAAc,GAAGpB,MAAM,CAACjC,UAAP,CAAkBsD,YAAlB,EAAgC,IAAhC,CAAjB;AACD;;;;"}
1
+ {"version":3,"file":"utils.esm.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.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>[]\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 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","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","useState","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,KAAK,CAACC,MAAM,CAACC,MAAM,CAACC,IAAI,CAACC,MAAM,EAAE,CAAC,CAACC,SAAS,CAAC,CAAC,CAAC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AAC,CAAA;AACxD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/utils",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
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": "224040bb9f98c2c8975ce76f0786265c9e3459e2"
31
+ "gitHead": "be56a9cea51aa1cf026d38174750f2a52e67a463"
32
32
  }
package/CHANGELOG.md DELETED
@@ -1,150 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.5.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0...@entur/utils@0.5.1) (2023-02-02)
7
-
8
- **Note:** Version bump only for package @entur/utils
9
-
10
-
11
-
12
-
13
-
14
- ## [0.4.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.8...@entur/utils@0.4.9) (2023-01-19)
15
-
16
- ### Performance Improvements
17
-
18
- - **button:** remove usage of react-polymorphic-types in favor of own implementation in button packa ([d15d852](https://bitbucket.org/enturas/design-system/commits/d15d85245d7f7273f0700fafcef3201d4fa2e0ff))
19
- - **layout:** remove usage of react-polymorphic-types in favor of own implementation in layout packa ([b7ada6d](https://bitbucket.org/enturas/design-system/commits/b7ada6d7b9776cce86dea51f58c4b7ea0300451b))
20
- - **packages:** remove all referenves to react-polymorphic-types npm-package ([e47a304](https://bitbucket.org/enturas/design-system/commits/e47a304d87eb77adae5dd002e89f03026c7eadce))
21
-
22
- ## [0.4.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.8) (2022-12-09)
23
-
24
- ### Bug Fixes
25
-
26
- - **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
27
-
28
- ## [0.4.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.6...@entur/utils@0.4.7) (2022-11-24)
29
-
30
- **Note:** Version bump only for package @entur/utils
31
-
32
- ## [0.4.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.6) (2022-10-31)
33
-
34
- ### Bug Fixes
35
-
36
- - **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
37
-
38
- # [0.5.0-RC.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-RC.1...@entur/utils@0.5.0-RC.2) (2022-11-22)
39
-
40
- ### Bug Fixes
41
-
42
- - **useOnEscape:** commit for force updating utils-packages for publishing ([4c1082c](https://bitbucket.org/enturas/design-system/commits/4c1082c872a546c6c848aed2e2ae80e2d4599d11))
43
-
44
- # [0.5.0-RC.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-RC.0...@entur/utils@0.5.0-RC.1) (2022-11-21)
45
-
46
- **Note:** Version bump only for package @entur/utils
47
-
48
- # [0.5.0-RC.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.5.0-alpha.0...@entur/utils@0.5.0-RC.0) (2022-11-21)
49
-
50
- **Note:** Version bump only for package @entur/utils
51
-
52
- # [0.5.0-alpha.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.6-alpha.0...@entur/utils@0.5.0-alpha.0) (2022-10-26)
53
-
54
- ### Features
55
-
56
- - **datepicker:** add i18y-wrapper to components for locale ([aed14fb](https://bitbucket.org/enturas/design-system/commits/aed14fb32e789159b4021c8b740a8101b83228fa))
57
- - **datepicker:** add modal view for calendar when using small screen widths ([05d9325](https://bitbucket.org/enturas/design-system/commits/05d9325a83dbc8d7d2e62050e7d6bbecbe2f665e))
58
-
59
- ## [0.4.6-alpha.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.6-alpha.0) (2022-10-20)
60
-
61
- ### Bug Fixes
62
-
63
- - **locale:** fix for locale not working ([0ff0912](https://bitbucket.org/enturas/design-system/commits/0ff0912405e015abb50c9cb6103c5f9827d8bd7b))
64
-
65
- ## [0.4.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.4...@entur/utils@0.4.5) (2022-08-31)
66
-
67
- **Note:** Version bump only for package @entur/utils
68
-
69
- ## [0.4.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.3...@entur/utils@0.4.4) (2022-08-24)
70
-
71
- ### Bug Fixes
72
-
73
- - add parameter and return types ([861b878](https://bitbucket.org/enturas/design-system/commits/861b8782b1fae34242d64371a8af7887ac545df6))
74
-
75
- ## [0.4.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.2...@entur/utils@0.4.3) (2022-02-09)
76
-
77
- **Note:** Version bump only for package @entur/utils
78
-
79
- ## [0.4.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.1...@entur/utils@0.4.2) (2021-06-25)
80
-
81
- ### Bug Fixes
82
-
83
- - update dependencies ([80b9175](https://bitbucket.org/enturas/design-system/commits/80b9175b193d1154aa4ee6977c765e2c19b73415))
84
-
85
- ## [0.4.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.0...@entur/utils@0.4.1) (2021-02-17)
86
-
87
- ### Bug Fixes
88
-
89
- - **dependency:** remove old polymorphism from dependencies ([c170645](https://bitbucket.org/enturas/design-system/commits/c1706459b36048952e9ca14cc51148054bf12bdc))
90
- - **polymorphic:** add new polymorphism dependency ([7bf79cc](https://bitbucket.org/enturas/design-system/commits/7bf79cca1feccf7cfee11fc9f8ff1e5f1025a47f))
91
- - **polymorphic:** remove old dependency as exports ([eb5f431](https://bitbucket.org/enturas/design-system/commits/eb5f43171cdc8099f9479bd6a7210c0a5fa2daa4))
92
-
93
- # [0.4.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.3.0...@entur/utils@0.4.0) (2020-12-04)
94
-
95
- ### Features
96
-
97
- - add polymorphic component dependecy as export ([5384642](https://bitbucket.org/enturas/design-system/commits/53846421f66f4b6193238d0d6cced8b09658d3b6))
98
-
99
- # [0.3.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.9...@entur/utils@0.3.0) (2020-10-09)
100
-
101
- ### Features
102
-
103
- - add useOnMount hook ([0f1fc26](https://bitbucket.org/enturas/design-system/commits/0f1fc2658a1263179be80b656828cf6373834702))
104
-
105
- ## [0.2.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.8...@entur/utils@0.2.9) (2020-06-17)
106
-
107
- **Note:** Version bump only for package @entur/utils
108
-
109
- ## [0.2.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.7...@entur/utils@0.2.8) (2020-05-27)
110
-
111
- **Note:** Version bump only for package @entur/utils
112
-
113
- ## [0.2.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.6...@entur/utils@0.2.7) (2020-05-26)
114
-
115
- **Note:** Version bump only for package @entur/utils
116
-
117
- ## [0.2.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.5...@entur/utils@0.2.6) (2020-05-20)
118
-
119
- **Note:** Version bump only for package @entur/utils
120
-
121
- ## [0.2.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.4...@entur/utils@0.2.5) (2020-04-27)
122
-
123
- **Note:** Version bump only for package @entur/utils
124
-
125
- ## [0.2.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.3...@entur/utils@0.2.4) (2020-04-23)
126
-
127
- **Note:** Version bump only for package @entur/utils
128
-
129
- ## [0.2.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.2...@entur/utils@0.2.3) (2020-02-05)
130
-
131
- ### Bug Fixes
132
-
133
- - add new breakpoint mixin for new breakpoint token ([eb6cc7a](https://bitbucket.org/enturas/design-system/commits/eb6cc7a63ff345e9835ab209f035dd2d615d20f8))
134
- - remove test-files from build process ([e0b24af](https://bitbucket.org/enturas/design-system/commits/e0b24af05d5c2ad8de4ae587d83c389495235890))
135
-
136
- ## [0.2.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.1...@entur/utils@0.2.2) (2020-01-27)
137
-
138
- ### Bug Fixes
139
-
140
- - **types:** place types in the correct place ([acace09](https://bitbucket.org/enturas/design-system/commits/acace09ec0e258c5cff3a65e13ab29d6603780d9))
141
-
142
- ## [0.2.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.0...@entur/utils@0.2.1) (2020-01-14)
143
-
144
- **Note:** Version bump only for package @entur/utils
145
-
146
- # 0.2.0 (2020-01-08)
147
-
148
- ### Features
149
-
150
- - add function to warn about missing style imports ([535e06c](https://bitbucket.org/enturas/design-system/commits/535e06c627708c3c69b002ceacaeba36950915be))