@leancodepl/utils 7.8.1 → 8.0.0

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/index.cjs.js CHANGED
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var invariant = require('tiny-invariant');
6
4
  var react = require('react');
7
5
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
11
-
12
6
  function addPrefix(object, prefix) {
13
7
  return Object.fromEntries(Object.entries(object).map(([key, value])=>[
14
8
  `${prefix}${key}`,
@@ -63,15 +57,15 @@ function capitalizeDeep(value) {
63
57
  }
64
58
 
65
59
  function assertDefined(value, message) {
66
- invariant__default["default"](value !== undefined, message);
60
+ invariant(value !== undefined, message);
67
61
  }
68
62
 
69
63
  function assertNotNull(value, message) {
70
- invariant__default["default"](value !== null, message);
64
+ invariant(value !== null, message);
71
65
  }
72
66
 
73
67
  function assertNotEmpty(value, message) {
74
- invariant__default["default"](value !== null && value !== undefined, message);
68
+ invariant(value !== null && value !== undefined, message);
75
69
  }
76
70
 
77
71
  function ensureDefined(value, message) {
@@ -159,7 +153,7 @@ function useDialog(onAfterClose) {
159
153
  const [openDialog, closeDialog] = useSetUnset(setIsDialogOpen);
160
154
  const close = react.useCallback(()=>{
161
155
  closeDialog();
162
- onAfterClose && setTimeout(onAfterClose);
156
+ if (onAfterClose) setTimeout(onAfterClose);
163
157
  }, [
164
158
  closeDialog,
165
159
  onAfterClose
package/index.esm.js CHANGED
@@ -151,7 +151,7 @@ function useDialog(onAfterClose) {
151
151
  const [openDialog, closeDialog] = useSetUnset(setIsDialogOpen);
152
152
  const close = useCallback(()=>{
153
153
  closeDialog();
154
- onAfterClose && setTimeout(onAfterClose);
154
+ if (onAfterClose) setTimeout(onAfterClose);
155
155
  }, [
156
156
  closeDialog,
157
157
  onAfterClose
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@leancodepl/utils",
3
- "version": "7.8.1",
3
+ "version": "8.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "dependencies": {
6
- "@leancodepl/api-date": "7.8.1",
6
+ "@leancodepl/api-date": "8.0.0",
7
7
  "tiny-invariant": ">=1.3.1"
8
8
  },
9
9
  "peerDependencies": {
@@ -14,10 +14,12 @@
14
14
  "./package.json": "./package.json",
15
15
  ".": {
16
16
  "module": "./index.esm.js",
17
+ "types": "./index.esm.d.ts",
17
18
  "import": "./index.cjs.mjs",
18
19
  "default": "./index.cjs.js"
19
20
  }
20
21
  },
21
22
  "module": "./index.esm.js",
22
- "main": "./index.cjs.js"
23
+ "main": "./index.cjs.js",
24
+ "types": "./index.esm.d.ts"
23
25
  }
@@ -1,2 +1,2 @@
1
1
  import { PathMatch } from "react-router-dom";
2
- export declare function useKeyByRoute<TKey extends string>(routeMatches: Record<TKey, (PathMatch | null)[] | PathMatch | never | null>): TKey[];
2
+ export declare function useKeyByRoute<TKey extends string>(routeMatches: Record<TKey, (PathMatch | null)[] | never | PathMatch | null>): TKey[];
@@ -5,6 +5,6 @@ export type TransformDeep<T, TMode extends Mode> = T extends Array<infer TArrayE
5
5
  } : T extends null ? undefined : T;
6
6
  export type UncapitalizeDeep<T> = TransformDeep<T, "uncapitalize">;
7
7
  export type CapitalizeDeep<T> = TransformDeep<T, "capitalize">;
8
- export type MutableDeep<T> = T extends Date | bigint | boolean | number | string | symbol | null | undefined ? T : T extends ReadonlyArray<infer ArrayType> ? Array<MutableDeep<ArrayType>> : {
8
+ export type MutableDeep<T> = T extends bigint | boolean | Date | number | string | symbol | null | undefined ? T : T extends ReadonlyArray<infer ArrayType> ? Array<MutableDeep<ArrayType>> : {
9
9
  -readonly [K in keyof T]: MutableDeep<T[K]>;
10
10
  };