@entur/utils 0.4.6-beta.2 → 0.4.6

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,97 @@
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.4.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.6) (2022-10-31)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
11
+
12
+ ## [0.4.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.4...@entur/utils@0.4.5) (2022-08-31)
13
+
14
+ **Note:** Version bump only for package @entur/utils
15
+
16
+ ## [0.4.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.3...@entur/utils@0.4.4) (2022-08-24)
17
+
18
+ ### Bug Fixes
19
+
20
+ - add parameter and return types ([861b878](https://bitbucket.org/enturas/design-system/commits/861b8782b1fae34242d64371a8af7887ac545df6))
21
+
22
+ ## [0.4.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.2...@entur/utils@0.4.3) (2022-02-09)
23
+
24
+ **Note:** Version bump only for package @entur/utils
25
+
26
+ ## [0.4.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.1...@entur/utils@0.4.2) (2021-06-25)
27
+
28
+ ### Bug Fixes
29
+
30
+ - update dependencies ([80b9175](https://bitbucket.org/enturas/design-system/commits/80b9175b193d1154aa4ee6977c765e2c19b73415))
31
+
32
+ ## [0.4.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.0...@entur/utils@0.4.1) (2021-02-17)
33
+
34
+ ### Bug Fixes
35
+
36
+ - **dependency:** remove old polymorphism from dependencies ([c170645](https://bitbucket.org/enturas/design-system/commits/c1706459b36048952e9ca14cc51148054bf12bdc))
37
+ - **polymorphic:** add new polymorphism dependency ([7bf79cc](https://bitbucket.org/enturas/design-system/commits/7bf79cca1feccf7cfee11fc9f8ff1e5f1025a47f))
38
+ - **polymorphic:** remove old dependency as exports ([eb5f431](https://bitbucket.org/enturas/design-system/commits/eb5f43171cdc8099f9479bd6a7210c0a5fa2daa4))
39
+
40
+ # [0.4.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.3.0...@entur/utils@0.4.0) (2020-12-04)
41
+
42
+ ### Features
43
+
44
+ - add polymorphic component dependecy as export ([5384642](https://bitbucket.org/enturas/design-system/commits/53846421f66f4b6193238d0d6cced8b09658d3b6))
45
+
46
+ # [0.3.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.9...@entur/utils@0.3.0) (2020-10-09)
47
+
48
+ ### Features
49
+
50
+ - add useOnMount hook ([0f1fc26](https://bitbucket.org/enturas/design-system/commits/0f1fc2658a1263179be80b656828cf6373834702))
51
+
52
+ ## [0.2.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.8...@entur/utils@0.2.9) (2020-06-17)
53
+
54
+ **Note:** Version bump only for package @entur/utils
55
+
56
+ ## [0.2.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.7...@entur/utils@0.2.8) (2020-05-27)
57
+
58
+ **Note:** Version bump only for package @entur/utils
59
+
60
+ ## [0.2.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.6...@entur/utils@0.2.7) (2020-05-26)
61
+
62
+ **Note:** Version bump only for package @entur/utils
63
+
64
+ ## [0.2.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.5...@entur/utils@0.2.6) (2020-05-20)
65
+
66
+ **Note:** Version bump only for package @entur/utils
67
+
68
+ ## [0.2.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.4...@entur/utils@0.2.5) (2020-04-27)
69
+
70
+ **Note:** Version bump only for package @entur/utils
71
+
72
+ ## [0.2.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.3...@entur/utils@0.2.4) (2020-04-23)
73
+
74
+ **Note:** Version bump only for package @entur/utils
75
+
76
+ ## [0.2.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.2...@entur/utils@0.2.3) (2020-02-05)
77
+
78
+ ### Bug Fixes
79
+
80
+ - add new breakpoint mixin for new breakpoint token ([eb6cc7a](https://bitbucket.org/enturas/design-system/commits/eb6cc7a63ff345e9835ab209f035dd2d615d20f8))
81
+ - remove test-files from build process ([e0b24af](https://bitbucket.org/enturas/design-system/commits/e0b24af05d5c2ad8de4ae587d83c389495235890))
82
+
83
+ ## [0.2.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.1...@entur/utils@0.2.2) (2020-01-27)
84
+
85
+ ### Bug Fixes
86
+
87
+ - **types:** place types in the correct place ([acace09](https://bitbucket.org/enturas/design-system/commits/acace09ec0e258c5cff3a65e13ab29d6603780d9))
88
+
89
+ ## [0.2.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.0...@entur/utils@0.2.1) (2020-01-14)
90
+
91
+ **Note:** Version bump only for package @entur/utils
92
+
93
+ # 0.2.0 (2020-01-08)
94
+
95
+ ### Features
96
+
97
+ - add function to warn about missing style imports ([535e06c](https://bitbucket.org/enturas/design-system/commits/535e06c627708c3c69b002ceacaeba36950915be))
@@ -103,7 +103,7 @@ function checkAndWarn() {
103
103
 
104
104
  var singleMissingImport = missingImports.length === 1;
105
105
  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) {
106
- return "\t@import '~@entur/" + namespace + "/dist/styles.css';";
106
+ return "\t@import '@entur/" + namespace + "/dist/styles.css';";
107
107
  }).join('\n') + "\n") ;
108
108
  }
109
109
  /** Warns the developer if they have forgotten to include styles */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.development.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../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 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","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","window","getComputedStyle","document","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,MAAMC,GAAG,GAAGC,yBAAK,CAACC,MAAN,CAAaC,MAAM,CAACC,IAAI,CAACC,MAAL,EAAD,CAAN,CAAsBC,SAAtB,CAAgC,CAAhC,CAAb,CAAZ;AACA,SAAUP,MAAV,SAAoBC,GAAG,CAACO,OAAxB;AACD;;SCHeC,WAAWC;AACzB,MAAMC,MAAM,GAAGT,yBAAK,CAACC,MAAN,CAAsB,KAAtB,CAAf;AAEAD,EAAAA,yBAAK,CAACU,SAAN,CAAgB;AACd,QAAI,CAACD,MAAM,CAACH,OAAZ,EAAqB;AACnBG,MAAAA,MAAM,CAACH,OAAP,GAAiB,IAAjB;AACAE,MAAAA,QAAQ;AACT;AACF,GALD,EAKG,CAAC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AACC,OAAX,CAAmB,UAAAf,SAAS;AAAA,WAAIR,eAAe,CAACwB,GAAhB,CAAoBhB,SAApB,CAAJ;AAAA,GAA5B;;AAGAN,EAAAA,cAAc,GAAGQ,MAAM,CAAC5B,UAAP,CAAkBqB,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/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 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","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","window","getComputedStyle","document","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,MAAMC,GAAG,GAAGC,yBAAK,CAACC,MAAN,CAAaC,MAAM,CAACC,IAAI,CAACC,MAAL,EAAD,CAAN,CAAsBC,SAAtB,CAAgC,CAAhC,CAAb,CAAZ;AACA,SAAUP,MAAV,SAAoBC,GAAG,CAACO,OAAxB;AACD;;SCHeC,WAAWC;AACzB,MAAMC,MAAM,GAAGT,yBAAK,CAACC,MAAN,CAAsB,KAAtB,CAAf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;;;SACgBC;AACd;AACA,MAAgB,OAAOX,MAAP,KAAkB,WAAlC,EAA+C;AAC7C;AACD;;;AAEDA,EAAAA,MAAM,CAAC7B,YAAP,CAAoBqB,cAApB;;oCANwCoB;AAAAA,IAAAA;;;AASxCA,EAAAA,UAAU,CAACC,OAAX,CAAmB,UAAAf,SAAS;AAAA,WAAIR,eAAe,CAACwB,GAAhB,CAAoBhB,SAApB,CAAJ;AAAA,GAA5B;;AAGAN,EAAAA,cAAc,GAAGQ,MAAM,CAAC5B,UAAP,CAAkBqB,YAAlB,EAAgC,IAAhC,CAAjB;AACD;;;;;;;;"}
package/dist/utils.esm.js CHANGED
@@ -94,7 +94,7 @@ function checkAndWarn() {
94
94
 
95
95
  var singleMissingImport = missingImports.length === 1;
96
96
  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) {
97
- return "\t@import '~@entur/" + namespace + "/dist/styles.css';";
97
+ return "\t@import '@entur/" + namespace + "/dist/styles.css';";
98
98
  }).join('\n') + "\n") : void 0;
99
99
  }
100
100
  /** Warns the developer if they have forgotten to include styles */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.esm.js","sources":["../src/debounce.ts","../src/useRandomId.ts","../src/useOnMount.ts","../src/mergeRefs.ts","../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 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","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","window","getComputedStyle","document","documentElement","getPropertyValue","sort","singleMissingImport","length","warning","map","join","warnAboutMissingStyles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,cAAc,GAAGC,KAAK,CAACC,IAAN,CAAWN,eAAX,EACpBO,MADoB,CAEnB,UAAAC,SAAS;AAAA,WACPC,QAAQ,CACNC,MAAM,CACHC,gBADH,CACoBC,QAAQ,CAACC,eAD7B,EAEGC,gBAFH,YAE6BN,SAF7B,CADM,CAAR,KAIM,CALC;AAAA,GAFU,EASpBO,IAToB,EAAvB;;AAYA,MAAMC,mBAAmB,GAAGZ,cAAc,CAACa,MAAf,KAA0B,CAAtD;AACA,0CAAAC,OAAO,CACLd,cAAc,CAACa,MAAf,KAA0B,CADrB,wBAGHD,mBAAmB,GACf,cADe,GAEZZ,cAAc,CAACa,MAFH,iBAHhB,kDASHD,mBAAmB,GAAG,EAAH,GAAQ,GATxB,oCAYPZ,cAAc,CACbe,GADD,CACK,UAAAX,SAAS;AAAA,mCAA0BA,SAA1B;AAAA,GADd,EAECY,IAFD,CAEM,IAFN,CAZO,QAAP;AAiBD;AAED;;;SACgBC;AACd;AACA,MAAI,4CAAY,OAAOX,MAAP,KAAkB,WAAlC,EAA+C;AAC7C;AACD;;;AAEDA,EAAAA,MAAM,CAAC7B,YAAP,CAAoBqB,cAApB;;oCANwCoB;AAAAA,IAAAA;;;AASxCA,EAAAA,UAAU,CAACC,OAAX,CAAmB,UAAAf,SAAS;AAAA,WAAIR,eAAe,CAACwB,GAAhB,CAAoBhB,SAApB,CAAJ;AAAA,GAA5B;;AAGAN,EAAAA,cAAc,GAAGQ,MAAM,CAAC5B,UAAP,CAAkBqB,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/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 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","packagesToCheck","Set","checkTimeoutId","checkAndWarn","missingImports","Array","from","filter","namespace","parseInt","window","getComputedStyle","document","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,MAAMC,GAAG,GAAGC,KAAK,CAACC,MAAN,CAAaC,MAAM,CAACC,IAAI,CAACC,MAAL,EAAD,CAAN,CAAsBC,SAAtB,CAAgC,CAAhC,CAAb,CAAZ;AACA,SAAUP,MAAV,SAAoBC,GAAG,CAACO,OAAxB;AACD;;SCHeC,WAAWC;AACzB,MAAMC,MAAM,GAAGT,KAAK,CAACC,MAAN,CAAsB,KAAtB,CAAf;AAEAD,EAAAA,KAAK,CAACU,SAAN,CAAgB;AACd,QAAI,CAACD,MAAM,CAACH,OAAZ,EAAqB;AACnBG,MAAAA,MAAM,CAACH,OAAP,GAAiB,IAAjB;AACAE,MAAAA,QAAQ;AACT;AACF,GALD,EAKG,CAACA,QAAD,CALH;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICXYG,SAAS,GAAG,SAAZA,SAAY;oCACpBC;AAAAA,IAAAA;;;AAEH,SAAO,UAACC,IAAD;AACL,yDAAkBD,IAAlB,wCAAwB;AAAA,UAAbb,GAAa;;AACtB,UAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,QAAAA,GAAG,CAACc,IAAD,CAAH;AACD,OAFD,MAEO,IAAId,GAAJ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
+ "version": "0.4.6",
5
4
  "license": "EUPL-1.2",
6
5
  "main": "dist/index.js",
7
6
  "module": "dist/utils.esm.js",
@@ -18,9 +17,10 @@
18
17
  "access": "public"
19
18
  },
20
19
  "scripts": {
21
- "start": "yarn run dts watch --noClean",
22
- "build": "yarn run dts build && cp src/*.scss dist",
23
- "lint": "yarn run dts lint"
20
+ "start": "dts watch --noClean",
21
+ "build": "dts build && cp src/*.scss dist",
22
+ "test": "dts test --env=jsdom",
23
+ "lint": "dts lint"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": ">=16.8.0",
@@ -30,8 +30,5 @@
30
30
  "react-polymorphic-types": "^1.1.0",
31
31
  "tiny-warning": "^1.0.3"
32
32
  },
33
- "devDependencies": {
34
- "dts-cli": "^1.1.6"
35
- },
36
- "gitHead": "89c8eee86c247794134c34484a205e0f7f65d0a5"
33
+ "gitHead": "11fde5ffbfd805773572c3a7d999d63f2733e0c7"
37
34
  }