@entur/utils 0.4.7 → 0.4.9

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,115 @@
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.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.8...@entur/utils@0.4.9) (2023-01-19)
7
+
8
+ ### Performance Improvements
9
+
10
+ - **button:** remove usage of react-polymorphic-types in favor of own implementation in button packa ([d15d852](https://bitbucket.org/enturas/design-system/commits/d15d85245d7f7273f0700fafcef3201d4fa2e0ff))
11
+ - **layout:** remove usage of react-polymorphic-types in favor of own implementation in layout packa ([b7ada6d](https://bitbucket.org/enturas/design-system/commits/b7ada6d7b9776cce86dea51f58c4b7ea0300451b))
12
+ - **packages:** remove all referenves to react-polymorphic-types npm-package ([e47a304](https://bitbucket.org/enturas/design-system/commits/e47a304d87eb77adae5dd002e89f03026c7eadce))
13
+
14
+ ## [0.4.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.8) (2022-12-09)
15
+
16
+ ### Bug Fixes
17
+
18
+ - **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
19
+
20
+ ## [0.4.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.6...@entur/utils@0.4.7) (2022-11-24)
21
+
22
+ **Note:** Version bump only for package @entur/utils
23
+
24
+ ## [0.4.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.6) (2022-10-31)
25
+
26
+ ### Bug Fixes
27
+
28
+ - **style import warning:** remove ~ from import warning since it is deprecated ([c6a25fd](https://bitbucket.org/enturas/design-system/commits/c6a25fde98ec2f2821f678c6175c797ad10b7185))
29
+
30
+ ## [0.4.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.4...@entur/utils@0.4.5) (2022-08-31)
31
+
32
+ **Note:** Version bump only for package @entur/utils
33
+
34
+ ## [0.4.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.3...@entur/utils@0.4.4) (2022-08-24)
35
+
36
+ ### Bug Fixes
37
+
38
+ - add parameter and return types ([861b878](https://bitbucket.org/enturas/design-system/commits/861b8782b1fae34242d64371a8af7887ac545df6))
39
+
40
+ ## [0.4.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.2...@entur/utils@0.4.3) (2022-02-09)
41
+
42
+ **Note:** Version bump only for package @entur/utils
43
+
44
+ ## [0.4.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.1...@entur/utils@0.4.2) (2021-06-25)
45
+
46
+ ### Bug Fixes
47
+
48
+ - update dependencies ([80b9175](https://bitbucket.org/enturas/design-system/commits/80b9175b193d1154aa4ee6977c765e2c19b73415))
49
+
50
+ ## [0.4.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.0...@entur/utils@0.4.1) (2021-02-17)
51
+
52
+ ### Bug Fixes
53
+
54
+ - **dependency:** remove old polymorphism from dependencies ([c170645](https://bitbucket.org/enturas/design-system/commits/c1706459b36048952e9ca14cc51148054bf12bdc))
55
+ - **polymorphic:** add new polymorphism dependency ([7bf79cc](https://bitbucket.org/enturas/design-system/commits/7bf79cca1feccf7cfee11fc9f8ff1e5f1025a47f))
56
+ - **polymorphic:** remove old dependency as exports ([eb5f431](https://bitbucket.org/enturas/design-system/commits/eb5f43171cdc8099f9479bd6a7210c0a5fa2daa4))
57
+
58
+ # [0.4.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.3.0...@entur/utils@0.4.0) (2020-12-04)
59
+
60
+ ### Features
61
+
62
+ - add polymorphic component dependecy as export ([5384642](https://bitbucket.org/enturas/design-system/commits/53846421f66f4b6193238d0d6cced8b09658d3b6))
63
+
64
+ # [0.3.0](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.9...@entur/utils@0.3.0) (2020-10-09)
65
+
66
+ ### Features
67
+
68
+ - add useOnMount hook ([0f1fc26](https://bitbucket.org/enturas/design-system/commits/0f1fc2658a1263179be80b656828cf6373834702))
69
+
70
+ ## [0.2.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.8...@entur/utils@0.2.9) (2020-06-17)
71
+
72
+ **Note:** Version bump only for package @entur/utils
73
+
74
+ ## [0.2.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.7...@entur/utils@0.2.8) (2020-05-27)
75
+
76
+ **Note:** Version bump only for package @entur/utils
77
+
78
+ ## [0.2.7](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.6...@entur/utils@0.2.7) (2020-05-26)
79
+
80
+ **Note:** Version bump only for package @entur/utils
81
+
82
+ ## [0.2.6](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.5...@entur/utils@0.2.6) (2020-05-20)
83
+
84
+ **Note:** Version bump only for package @entur/utils
85
+
86
+ ## [0.2.5](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.4...@entur/utils@0.2.5) (2020-04-27)
87
+
88
+ **Note:** Version bump only for package @entur/utils
89
+
90
+ ## [0.2.4](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.3...@entur/utils@0.2.4) (2020-04-23)
91
+
92
+ **Note:** Version bump only for package @entur/utils
93
+
94
+ ## [0.2.3](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.2...@entur/utils@0.2.3) (2020-02-05)
95
+
96
+ ### Bug Fixes
97
+
98
+ - add new breakpoint mixin for new breakpoint token ([eb6cc7a](https://bitbucket.org/enturas/design-system/commits/eb6cc7a63ff345e9835ab209f035dd2d615d20f8))
99
+ - remove test-files from build process ([e0b24af](https://bitbucket.org/enturas/design-system/commits/e0b24af05d5c2ad8de4ae587d83c389495235890))
100
+
101
+ ## [0.2.2](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.1...@entur/utils@0.2.2) (2020-01-27)
102
+
103
+ ### Bug Fixes
104
+
105
+ - **types:** place types in the correct place ([acace09](https://bitbucket.org/enturas/design-system/commits/acace09ec0e258c5cff3a65e13ab29d6603780d9))
106
+
107
+ ## [0.2.1](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.2.0...@entur/utils@0.2.1) (2020-01-14)
108
+
109
+ **Note:** Version bump only for package @entur/utils
110
+
111
+ # 0.2.0 (2020-01-08)
112
+
113
+ ### Features
114
+
115
+ - add function to warn about missing style imports ([535e06c](https://bitbucket.org/enturas/design-system/commits/535e06c627708c3c69b002ceacaeba36950915be))
@@ -1,2 +1,41 @@
1
- import type { PolymorphicPropsWithoutRef, PolymorphicPropsWithRef, PolymorphicForwardRefExoticComponent } from 'react-polymorphic-types';
2
- export { PolymorphicPropsWithoutRef, PolymorphicPropsWithRef, PolymorphicForwardRefExoticComponent, };
1
+ /** These polymorphic types are derrived from Ben Ilegbodu's article available at the following link:
2
+ * https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
3
+ */
4
+ import React from 'react';
5
+ export 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> = {
7
+ /**
8
+ * An override of the default HTML tag.
9
+ * Can also be another React component.
10
+ */
11
+ as?: C;
12
+ };
13
+ /**
14
+ * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
15
+ * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
16
+ * set of props.
17
+ */
18
+ export declare type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
19
+ /**
20
+ * Allows for inheriting the props from the specified element type so that
21
+ * props like children, className & style work, as well as element-specific
22
+ * attributes like aria roles. The component (`C`) must be passed in.
23
+ */
24
+ export declare type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
25
+ /**
26
+ * A more sophisticated version of `InheritableElementProps` where
27
+ * the passed in `as` prop will determine which props can be included
28
+ */
29
+ export declare type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
30
+ /**
31
+ * Utility type to extract the `ref` prop from a polymorphic component
32
+ */
33
+ export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
34
+ /**
35
+ * A wrapper of `PolymorphicComponentProps` that also includes the `ref`
36
+ * prop for the polymorphic component
37
+ */
38
+ export declare type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
39
+ ref?: PolymorphicRef<C>;
40
+ };
41
+ export {};
@@ -1 +1 @@
1
- export declare const useRandomId: (prefix?: string) => string;
1
+ export declare const useRandomId: (prefix?: string | undefined) => string;
@@ -16,6 +16,7 @@ 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
+
19
20
  clearTimeout(id);
20
21
  id = setTimeout(function () {
21
22
  return fn.apply(void 0, args);
@@ -46,14 +47,19 @@ function _unsupportedIterableToArray(o, minLen) {
46
47
  if (n === "Map" || n === "Set") return Array.from(o);
47
48
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
48
49
  }
50
+
49
51
  function _arrayLikeToArray(arr, len) {
50
52
  if (len == null || len > arr.length) len = arr.length;
53
+
51
54
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
55
+
52
56
  return arr2;
53
57
  }
58
+
54
59
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
55
60
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
56
61
  if (it) return (it = it.call(o)).next.bind(it);
62
+
57
63
  if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
58
64
  if (it) o = it;
59
65
  var i = 0;
@@ -67,6 +73,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
67
73
  };
68
74
  };
69
75
  }
76
+
70
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.");
71
78
  }
72
79
 
@@ -74,9 +81,11 @@ var mergeRefs = function mergeRefs() {
74
81
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
75
82
  refs[_key] = arguments[_key];
76
83
  }
84
+
77
85
  return function (node) {
78
86
  for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
79
87
  var ref = _step.value;
88
+
80
89
  if (typeof ref === 'function') {
81
90
  ref(node);
82
91
  } else if (ref) ref.current = node;
@@ -86,32 +95,37 @@ var mergeRefs = function mergeRefs() {
86
95
 
87
96
  var packagesToCheck = /*#__PURE__*/new Set();
88
97
  var checkTimeoutId;
98
+
89
99
  function checkAndWarn() {
90
100
  var missingImports = Array.from(packagesToCheck).filter(function (namespace) {
91
101
  return parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--eds-" + namespace)) !== 1;
92
- }).sort();
93
- // Finally, we warn about those pesky imports
102
+ }).sort(); // Finally, we warn about those pesky imports
103
+
94
104
  var singleMissingImport = missingImports.length === 1;
95
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) {
96
106
  return "\t@import '@entur/" + namespace + "/dist/styles.css';";
97
107
  }).join('\n') + "\n") ;
98
108
  }
99
109
  /** Warns the developer if they have forgotten to include styles */
110
+
111
+
100
112
  function warnAboutMissingStyles() {
101
113
  // We skip this check in production, and when we build static sites
102
114
  if (typeof window === 'undefined') {
103
115
  return;
104
- }
105
- // First, let's clear earlier calls to setTimeout
106
- window.clearTimeout(checkTimeoutId);
107
- // Next, let's add all namespaces to the set of packages to check
116
+ } // First, let's clear earlier calls to setTimeout
117
+
118
+
119
+ window.clearTimeout(checkTimeoutId); // Next, let's add all namespaces to the set of packages to check
120
+
108
121
  for (var _len = arguments.length, namespaces = new Array(_len), _key = 0; _key < _len; _key++) {
109
122
  namespaces[_key] = arguments[_key];
110
123
  }
124
+
111
125
  namespaces.forEach(function (namespace) {
112
126
  return packagesToCheck.add(namespace);
113
- });
114
- // Finally. let's trigger a run of the checker.
127
+ }); // Finally. let's trigger a run of the checker.
128
+
115
129
  checkTimeoutId = window.setTimeout(checkAndWarn, 1000);
116
130
  }
117
131
 
@@ -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,QAAQ,CACtBC,EAAK,EACLC,KAAa;EAEb,IAAIC,EAAO;EACX,OAAO;sCAAIC,IAAI;MAAJA,IAAI;;IACbC,YAAY,CAACF,EAAE,CAAC;IAChBA,EAAE,GAAGG,UAAU,CAAC;MAAA,OAAML,EAAE,eAAIG,IAAI,CAAC;OAAEF,KAAK,CAAC;GAC1C;AAC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DC,2BAAO,CACLd,cAAc,CAACa,MAAM,KAAK,CAAC,wBAEzBD,mBAAmB,GACf,cAAc,GACXZ,cAAc,CAACa,MAAM,iBAC9B,kDAGED,mBAAmB,GAAG,EAAE,GAAG,GAC7B,oCAEFZ,cAAc,CACbe,GAAG,CAAC,UAAAX,SAAS;IAAA,8BAAyBA,SAAS;GAAoB,CAAC,CACpEY,IAAI,CAAC,IAAI,CAAC,QAEV;AACH;AAEA;SACgBC,sBAAsB;;EAEpC,IAAgB,OAAOX,MAAM,KAAK,WAAW,EAAE;IAC7C;;;EAGFA,MAAM,CAAC7B,YAAY,CAACqB,cAAc,CAAC;;EAEnC,kCARwCoB,UAAoB;IAApBA,UAAoB;;EAS5DA,UAAU,CAACC,OAAO,CAAC,UAAAf,SAAS;IAAA,OAAIR,eAAe,CAACwB,GAAG,CAAChB,SAAS,CAAC;IAAC;;EAG/DN,cAAc,GAAGQ,MAAM,CAAC5B,UAAU,CAACqB,YAAY,EAAE,IAAI,CAAC;AACxD;;;;;;;;"}
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,E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AEGC,gBAFH,YAE6BN,SAF7B,CADM,CAAR,KAIM,CALC;AAAA,GAFU,EASpBO,IAToB,EAAvB;;AAYA,MAAMC,mBAAmB,GAAGZ,cAAc,CAACa,MAAf,KAA0B,CAAtD;AACA,EAAAC,2BAAO,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,kCAAyBA,SAAzB;AAAA,GADd,EAECY,IAFD,CAEM,IAFN,CAZO,QAAP;AAiBD;AAED;;;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;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.production.min.js","sources":["../src/debounce.ts","../src/mergeRefs.ts","../src/useOnMount.ts","../src/useRandomId.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","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 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":["fn","delay","id","args","clearTimeout","setTimeout","refs","node","ref","current","callback","hasRun","React","useRef","useEffect","prefix","String","Math","random","substring"],"mappings":"shCACEA,EACAC,GAEA,IAAIC,EACJ,OAAO,sCAAIC,2BAAAA,kBACTC,aAAaF,GACbA,EAAKG,YAAW,WAAA,OAAML,eAAMG,KAAOF,uBCPd,sCACpBK,2BAAAA,kBAEH,OAAO,SAACC,GACN,cAAkBD,kBAAM,CAAA,IAAbE,UACU,mBAARA,EACTA,EAAID,GACKC,IAAKA,EAAIC,QAAUF,kCCLTG,GACzB,IAAMC,EAASC,UAAMC,QAAgB,GAErCD,UAAME,WAAU,WACTH,EAAOF,UACVE,EAAOF,SAAU,EACjBC,OAED,CAACA,yBCRqB,SAACK,GAE1B,OAAUA,MADEH,UAAMC,OAAOG,OAAOC,KAAKC,UAAUC,UAAU,IACjCV"}
1
+ {"version":3,"file":"utils.cjs.production.min.js","sources":["../src/debounce.ts","../src/mergeRefs.ts","../src/useOnMount.ts","../src/useRandomId.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","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 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":["fn","delay","id","args","clearTimeout","setTimeout","refs","node","ref","current","callback","hasRun","React","useRef","useEffect","prefix","String","Math","random","substring"],"mappings":"shCACEA,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,kCCLTG,OACnBC,EAASC,UAAMC,QAAgB,GAErCD,UAAME,WAAU,WACTH,EAAOF,UACVE,EAAOF,SAAU,EACjBC,OAED,CAACA,yBCRqB,SAACK,UAEhBA,MADEH,UAAMC,OAAOG,OAAOC,KAAKC,UAAUC,UAAU,IACjCV"}
package/dist/utils.esm.js CHANGED
@@ -7,6 +7,7 @@ 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
+
10
11
  clearTimeout(id);
11
12
  id = setTimeout(function () {
12
13
  return fn.apply(void 0, args);
@@ -37,14 +38,19 @@ function _unsupportedIterableToArray(o, minLen) {
37
38
  if (n === "Map" || n === "Set") return Array.from(o);
38
39
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39
40
  }
41
+
40
42
  function _arrayLikeToArray(arr, len) {
41
43
  if (len == null || len > arr.length) len = arr.length;
44
+
42
45
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
46
+
43
47
  return arr2;
44
48
  }
49
+
45
50
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
46
51
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
47
52
  if (it) return (it = it.call(o)).next.bind(it);
53
+
48
54
  if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
49
55
  if (it) o = it;
50
56
  var i = 0;
@@ -58,6 +64,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
58
64
  };
59
65
  };
60
66
  }
67
+
61
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.");
62
69
  }
63
70
 
@@ -65,9 +72,11 @@ var mergeRefs = function mergeRefs() {
65
72
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
66
73
  refs[_key] = arguments[_key];
67
74
  }
75
+
68
76
  return function (node) {
69
77
  for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
70
78
  var ref = _step.value;
79
+
71
80
  if (typeof ref === 'function') {
72
81
  ref(node);
73
82
  } else if (ref) ref.current = node;
@@ -77,32 +86,37 @@ var mergeRefs = function mergeRefs() {
77
86
 
78
87
  var packagesToCheck = /*#__PURE__*/new Set();
79
88
  var checkTimeoutId;
89
+
80
90
  function checkAndWarn() {
81
91
  var missingImports = Array.from(packagesToCheck).filter(function (namespace) {
82
92
  return parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--eds-" + namespace)) !== 1;
83
- }).sort();
84
- // Finally, we warn about those pesky imports
93
+ }).sort(); // Finally, we warn about those pesky imports
94
+
85
95
  var singleMissingImport = missingImports.length === 1;
86
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) {
87
97
  return "\t@import '@entur/" + namespace + "/dist/styles.css';";
88
98
  }).join('\n') + "\n") : void 0;
89
99
  }
90
100
  /** Warns the developer if they have forgotten to include styles */
101
+
102
+
91
103
  function warnAboutMissingStyles() {
92
104
  // We skip this check in production, and when we build static sites
93
105
  if (!(process.env.NODE_ENV !== "production") || typeof window === 'undefined') {
94
106
  return;
95
- }
96
- // First, let's clear earlier calls to setTimeout
97
- window.clearTimeout(checkTimeoutId);
98
- // Next, let's add all namespaces to the set of packages to check
107
+ } // First, let's clear earlier calls to setTimeout
108
+
109
+
110
+ window.clearTimeout(checkTimeoutId); // Next, let's add all namespaces to the set of packages to check
111
+
99
112
  for (var _len = arguments.length, namespaces = new Array(_len), _key = 0; _key < _len; _key++) {
100
113
  namespaces[_key] = arguments[_key];
101
114
  }
115
+
102
116
  namespaces.forEach(function (namespace) {
103
117
  return packagesToCheck.add(namespace);
104
- });
105
- // Finally. let's trigger a run of the checker.
118
+ }); // Finally. let's trigger a run of the checker.
119
+
106
120
  checkTimeoutId = window.setTimeout(checkAndWarn, 1000);
107
121
  }
108
122
 
@@ -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","namespaces","forEach","add"],"mappings":";;;SAAgBA,QAAQ,CACtBC,EAAK,EACLC,KAAa;EAEb,IAAIC,EAAO;EACX,OAAO;sCAAIC,IAAI;MAAJA,IAAI;;IACbC,YAAY,CAACF,EAAE,CAAC;IAChBA,EAAE,GAAGG,UAAU,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AE;;EAGT,IAAMC,mBAAmB,GAAGZ,cAAc,CAACa,MAAM,KAAK,CAAC;EACvD,wCAAAC,OAAO,CACLd,cAAc,CAACa,MAAM,KAAK,CAAC,wBAEzBD,mBAAmB,GACf,cAAc,GACXZ,cAAc,CAACa,MAAM,iBAC9B,kDAGED,mBAAmB,GAAG,EAAE,GAAG,GAC7B,oCAEFZ,cAAc,CACbe,GAAG,CAAC,UAAAX,SAAS;IAAA,8BAAyBA,SAAS;GAAoB,CAAC,CACpEY,IAAI,CAAC,IAAI,CAAC,QAEV;AACH;AAEA;SACgBC,sBAAsB;;EAEpC,IAAI,wCAAQ,IAAI,OAAOX,MAAM,KAAK,WAAW,EAAE;IAC7C;;;EAGFA,MAAM,CAAC7B,YAAY,CAACqB,cAAc,CAAC;;EAEnC,kCARwCoB,UAAoB;IAApBA,UAAoB;;EAS5DA,UAAU,CAACC,OAAO,CAAC,UAAAf,SAAS;IAAA,OAAIR,eAAe,CAACwB,GAAG,CAAChB,SAAS,CAAC;IAAC;;EAG/DN,cAAc,GAAGQ,MAAM,CAAC5B,UAAU,CAACqB,YAAY,EAAE,IAAI,CAAC;AACxD;;;;"}
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;A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ACPC,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,kCAAyBA,SAAzB;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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/utils",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/utils.esm.js",
@@ -17,20 +17,16 @@
17
17
  "access": "public"
18
18
  },
19
19
  "scripts": {
20
- "start": "yarn run dts watch --noClean",
21
- "build": "yarn run dts build && cp src/*.scss dist",
22
- "lint": "yarn run dts lint"
20
+ "start": "dts watch --noClean",
21
+ "build": "dts build && cp src/*.scss dist",
22
+ "lint": "dts lint"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.8.0",
26
26
  "react-dom": ">=16.8.0"
27
27
  },
28
28
  "dependencies": {
29
- "react-polymorphic-types": "^1.1.0",
30
29
  "tiny-warning": "^1.0.3"
31
30
  },
32
- "devDependencies": {
33
- "dts-cli": "^1.1.6"
34
- },
35
- "gitHead": "8915b1630bd936740ba9a4a88883f3432948a80e"
31
+ "gitHead": "de71e205560a699e2dce301e133966dc9348c459"
36
32
  }