@leancodepl/utils 9.7.3 → 10.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/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.0.0](https://github.com/leancodepl/js_corelibrary/compare/v9.7.4...v10.0.0) (2026-02-11)
7
+
8
+ ### Bug Fixes
9
+
10
+ - exclude external packages from build output
11
+ ([4c2be7a](https://github.com/leancodepl/js_corelibrary/commit/4c2be7ac64eb6ed5603ba61b9aeef75a454dffb3))
12
+
13
+ # Change Log
14
+
15
+ All notable changes to this project will be documented in this file. See
16
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
17
+
18
+ ## [9.7.4](https://github.com/leancodepl/js_corelibrary/compare/v9.7.3...v9.7.4) (2026-02-10)
19
+
20
+ **Note:** Version bump only for package @leancodepl/utils
21
+
22
+ # Change Log
23
+
24
+ All notable changes to this project will be documented in this file. See
25
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
26
+
6
27
  ## [9.7.3](https://github.com/leancodepl/js_corelibrary/compare/v9.7.2...v9.7.3) (2026-02-10)
7
28
 
8
29
  **Note:** Version bump only for package @leancodepl/utils
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import { useState as s, useCallback as u, useMemo as y, createContext as m, useEffect as l, useContext as k } from "react";
3
- function v() {
4
- const [n, t] = s(0), e = u(async (r) => {
1
+ import a from "tiny-invariant";
2
+ import { jsx as p } from "react/jsx-runtime";
3
+ import { useState as c, useCallback as u, useMemo as d, createContext as m, useEffect as f, useContext as y } from "react";
4
+ function g() {
5
+ const [n, t] = c(0), e = u(async (r) => {
5
6
  t((o) => o + 1);
6
7
  try {
7
8
  return await r();
@@ -11,23 +12,23 @@ function v() {
11
12
  }, []);
12
13
  return [n > 0, e];
13
14
  }
14
- function j(n) {
15
- const [t, e] = v(), r = y(
15
+ function I(n) {
16
+ const [t, e] = g(), r = d(
16
17
  () => n ? (...o) => e(() => n(...o)) : void 0,
17
18
  [n, e]
18
19
  );
19
20
  return [t, r];
20
21
  }
21
- function g(n) {
22
+ function k(n) {
22
23
  return [u(() => n(!0), [n]), u(() => n(!1), [n])];
23
24
  }
24
- function I(n) {
25
- const [t, e] = s(!1), [r, o] = g(e), i = u(() => {
25
+ function L(n) {
26
+ const [t, e] = c(!1), [r, o] = k(e), i = u(() => {
26
27
  o(), n && setTimeout(n);
27
28
  }, [o, n]);
28
29
  return { isDialogOpen: t, openDialog: r, closeDialog: i };
29
30
  }
30
- function S(n) {
31
+ function N(n) {
31
32
  const t = [];
32
33
  for (const e in n) {
33
34
  const r = n[e];
@@ -35,112 +36,103 @@ function S(n) {
35
36
  }
36
37
  return t;
37
38
  }
38
- function b(n, t, e) {
39
- const [r, o] = s(n);
39
+ function v(n, t, e) {
40
+ const [r, o] = c(n);
40
41
  (e ? !e(n, r) : n !== r) && (o(n), t(n));
41
42
  }
42
- function L(n, t) {
43
+ function w(n, t) {
43
44
  return Object.fromEntries(Object.entries(n).map(([e, r]) => [`${t}${e}`, r]));
44
45
  }
45
- var D = process.env.NODE_ENV === "production", a = "Invariant failed";
46
- function f(n, t) {
47
- if (!n) {
48
- if (D)
49
- throw new Error(a);
50
- var e = typeof t == "function" ? t() : t, r = e ? "".concat(a, ": ").concat(e) : a;
51
- throw new Error(r);
52
- }
46
+ function D(n, t) {
47
+ a(n !== void 0, t);
53
48
  }
54
49
  function x(n, t) {
55
- f(n !== void 0, t);
56
- }
57
- function h(n, t) {
58
- f(n != null, t);
50
+ a(n != null, t);
59
51
  }
60
- function w(n, t) {
61
- f(n !== null, t);
52
+ function C(n, t) {
53
+ a(n !== null, t);
62
54
  }
63
- function C(n, t = {}) {
55
+ function R(n, t = {}) {
64
56
  if (typeof n == "string") {
65
57
  const { name: e } = t, r = document.createElement("a");
66
58
  r.href = n, r.target = "_blank", e && (r.download = e), r.click();
67
59
  } else {
68
60
  const e = URL.createObjectURL(n);
69
- C(e, t), URL.revokeObjectURL(e);
61
+ R(e, t), URL.revokeObjectURL(e);
70
62
  }
71
63
  }
72
- function O(n, t) {
73
- return x(n, t), n;
64
+ function z(n, t) {
65
+ return D(n, t), n;
74
66
  }
75
- function P(n, t) {
76
- return h(n, t), n;
67
+ function E(n, t) {
68
+ return x(n, t), n;
77
69
  }
78
- function V(n, t) {
79
- return w(n, t), n;
70
+ function O(n, t) {
71
+ return C(n, t), n;
80
72
  }
81
- function p(n, t) {
73
+ function l(n, t) {
82
74
  return n.length === 0 ? "" : t(n[0]) + n.slice(1);
83
75
  }
84
- function E(n) {
85
- return p(n, (t) => t.toLowerCase());
76
+ function T(n) {
77
+ return l(n, (t) => t.toLowerCase());
86
78
  }
87
- function R(n) {
88
- return p(n, (t) => t.toUpperCase());
79
+ function h(n) {
80
+ return l(n, (t) => t.toUpperCase());
89
81
  }
90
- function c(n, t) {
82
+ function s(n, t) {
91
83
  if (n != null) {
92
84
  if (Array.isArray(n))
93
- return n.map((e) => c(e, t));
85
+ return n.map((e) => s(e, t));
94
86
  if (typeof n == "object") {
95
- const e = t === "capitalize" ? R : E;
87
+ const e = t === "capitalize" ? h : T;
96
88
  return Object.entries(n).reduce(
97
- (r, [o, i]) => ({ ...r, [e(o)]: c(i, t) }),
89
+ (r, [o, i]) => ({ ...r, [e(o)]: s(i, t) }),
98
90
  {}
99
91
  );
100
92
  }
101
93
  return n;
102
94
  }
103
95
  }
104
- function z(n) {
105
- return c(n, "uncapitalize");
96
+ function P(n) {
97
+ return s(n, "uncapitalize");
106
98
  }
107
99
  function U(n) {
108
- return c(n, "capitalize");
100
+ return s(n, "capitalize");
109
101
  }
110
- function F() {
102
+ function V() {
111
103
  const n = m([void 0, () => {
112
104
  }]);
113
105
  function t() {
114
- return k(n);
106
+ return y(n);
115
107
  }
116
108
  return t.Provider = function({ children: r, initialValue: o }) {
117
- const i = s(o);
118
- return /* @__PURE__ */ d(n.Provider, { value: i, children: r });
109
+ const i = c(o);
110
+ return /* @__PURE__ */ p(n.Provider, { value: i, children: r });
119
111
  }, t.set = function(r) {
120
112
  const [, o] = t();
121
- l(() => {
113
+ f(() => {
122
114
  o(r);
123
- }, [o, r]), l(() => () => o(void 0), [o]);
115
+ }, [o, r]), f(() => () => o(void 0), [o]);
124
116
  }, t;
125
117
  }
126
118
  export {
127
- L as addPrefix,
128
- x as assertDefined,
129
- h as assertNotEmpty,
130
- w as assertNotNull,
119
+ w as addPrefix,
120
+ D as assertDefined,
121
+ x as assertNotEmpty,
122
+ C as assertNotNull,
131
123
  U as capitalizeDeep,
132
- C as downloadFile,
133
- O as ensureDefined,
134
- P as ensureNotEmpty,
135
- V as ensureNotNull,
136
- F as mkValueContext,
137
- E as toLowerFirst,
138
- R as toUpperFirst,
139
- z as uncapitalizeDeep,
140
- j as useBoundRunInTask,
141
- I as useDialog,
142
- S as useKeyByRoute,
143
- v as useRunInTask,
144
- g as useSetUnset,
145
- b as useSyncState
124
+ R as downloadFile,
125
+ z as ensureDefined,
126
+ E as ensureNotEmpty,
127
+ O as ensureNotNull,
128
+ V as mkValueContext,
129
+ T as toLowerFirst,
130
+ h as toUpperFirst,
131
+ P as uncapitalizeDeep,
132
+ I as useBoundRunInTask,
133
+ L as useDialog,
134
+ N as useKeyByRoute,
135
+ g as useRunInTask,
136
+ k as useSetUnset,
137
+ v as useSyncState
146
138
  };
@@ -1 +1 @@
1
- (function(u,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],c):(u=typeof globalThis<"u"?globalThis:u||self,c(u["@leancodepl/utils"]={},u.jsxRuntime,u.react))})(this,(function(u,c,r){"use strict";function d(){const[n,e]=r.useState(0),t=r.useCallback(async i=>{e(o=>o+1);try{return await i()}finally{e(o=>o-1)}},[]);return[n>0,t]}function g(n){const[e,t]=d(),i=r.useMemo(()=>n?(...o)=>t(()=>n(...o)):void 0,[n,t]);return[e,i]}function y(n){return[r.useCallback(()=>n(!0),[n]),r.useCallback(()=>n(!1),[n])]}function C(n){const[e,t]=r.useState(!1),[i,o]=y(t),s=r.useCallback(()=>{o(),n&&setTimeout(n)},[o,n]);return{isDialogOpen:e,openDialog:i,closeDialog:s}}function R(n){const e=[];for(const t in n){const i=n[t];(Array.isArray(i)?i.some(o=>o!==null):i!==null)&&e.push(t)}return e}function T(n,e,t){const[i,o]=r.useState(n);(t?!t(n,i):n!==i)&&(o(n),e(n))}function h(n,e){return Object.fromEntries(Object.entries(n).map(([t,i])=>[`${e}${t}`,i]))}var j=process.env.NODE_ENV==="production",f="Invariant failed";function l(n,e){if(!n){if(j)throw new Error(f);var t=typeof e=="function"?e():e,i=t?"".concat(f,": ").concat(t):f;throw new Error(i)}}function p(n,e){l(n!==void 0,e)}function m(n,e){l(n!=null,e)}function k(n,e){l(n!==null,e)}function D(n,e={}){if(typeof n=="string"){const{name:t}=e,i=document.createElement("a");i.href=n,i.target="_blank",t&&(i.download=t),i.click()}else{const t=URL.createObjectURL(n);D(t,e),URL.revokeObjectURL(t)}}function E(n,e){return p(n,e),n}function w(n,e){return m(n,e),n}function b(n,e){return k(n,e),n}function S(n,e){return n.length===0?"":e(n[0])+n.slice(1)}function v(n){return S(n,e=>e.toLowerCase())}function N(n){return S(n,e=>e.toUpperCase())}function a(n,e){if(n!=null){if(Array.isArray(n))return n.map(t=>a(t,e));if(typeof n=="object"){const t=e==="capitalize"?N:v;return Object.entries(n).reduce((i,[o,s])=>({...i,[t(o)]:a(s,e)}),{})}return n}}function I(n){return a(n,"uncapitalize")}function P(n){return a(n,"capitalize")}function z(){const n=r.createContext([void 0,()=>{}]);function e(){return r.useContext(n)}return e.Provider=function({children:i,initialValue:o}){const s=r.useState(o);return c.jsx(n.Provider,{value:s,children:i})},e.set=function(i){const[,o]=e();r.useEffect(()=>{o(i)},[o,i]),r.useEffect(()=>()=>o(void 0),[o])},e}u.addPrefix=h,u.assertDefined=p,u.assertNotEmpty=m,u.assertNotNull=k,u.capitalizeDeep=P,u.downloadFile=D,u.ensureDefined=E,u.ensureNotEmpty=w,u.ensureNotNull=b,u.mkValueContext=z,u.toLowerFirst=v,u.toUpperFirst=N,u.uncapitalizeDeep=I,u.useBoundRunInTask=g,u.useDialog=C,u.useKeyByRoute=R,u.useRunInTask=d,u.useSetUnset=y,u.useSyncState=T,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("tiny-invariant"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","tiny-invariant","react/jsx-runtime","react"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t["@leancodepl/utils"]={},t.invariant,t.jsxRuntime,t.react))})(this,(function(t,r,g,o){"use strict";function f(){const[n,e]=o.useState(0),u=o.useCallback(async i=>{e(s=>s+1);try{return await i()}finally{e(s=>s-1)}},[]);return[n>0,u]}function C(n){const[e,u]=f(),i=o.useMemo(()=>n?(...s)=>u(()=>n(...s)):void 0,[n,u]);return[e,i]}function l(n){return[o.useCallback(()=>n(!0),[n]),o.useCallback(()=>n(!1),[n])]}function R(n){const[e,u]=o.useState(!1),[i,s]=l(u),c=o.useCallback(()=>{s(),n&&setTimeout(n)},[s,n]);return{isDialogOpen:e,openDialog:i,closeDialog:c}}function T(n){const e=[];for(const u in n){const i=n[u];(Array.isArray(i)?i.some(s=>s!==null):i!==null)&&e.push(u)}return e}function j(n,e,u){const[i,s]=o.useState(n);(u?!u(n,i):n!==i)&&(s(n),e(n))}function N(n,e){return Object.fromEntries(Object.entries(n).map(([u,i])=>[`${e}${u}`,i]))}function d(n,e){r(n!==void 0,e)}function y(n,e){r(n!=null,e)}function m(n,e){r(n!==null,e)}function k(n,e={}){if(typeof n=="string"){const{name:u}=e,i=document.createElement("a");i.href=n,i.target="_blank",u&&(i.download=u),i.click()}else{const u=URL.createObjectURL(n);k(u,e),URL.revokeObjectURL(u)}}function h(n,e){return d(n,e),n}function b(n,e){return y(n,e),n}function E(n,e){return m(n,e),n}function p(n,e){return n.length===0?"":e(n[0])+n.slice(1)}function D(n){return p(n,e=>e.toLowerCase())}function S(n){return p(n,e=>e.toUpperCase())}function a(n,e){if(n!=null){if(Array.isArray(n))return n.map(u=>a(u,e));if(typeof n=="object"){const u=e==="capitalize"?S:D;return Object.entries(n).reduce((i,[s,c])=>({...i,[u(s)]:a(c,e)}),{})}return n}}function I(n){return a(n,"uncapitalize")}function w(n){return a(n,"capitalize")}function z(){const n=o.createContext([void 0,()=>{}]);function e(){return o.useContext(n)}return e.Provider=function({children:i,initialValue:s}){const c=o.useState(s);return g.jsx(n.Provider,{value:c,children:i})},e.set=function(i){const[,s]=e();o.useEffect(()=>{s(i)},[s,i]),o.useEffect(()=>()=>s(void 0),[s])},e}t.addPrefix=N,t.assertDefined=d,t.assertNotEmpty=y,t.assertNotNull=m,t.capitalizeDeep=w,t.downloadFile=k,t.ensureDefined=h,t.ensureNotEmpty=b,t.ensureNotNull=E,t.mkValueContext=z,t.toLowerFirst=D,t.toUpperFirst=S,t.uncapitalizeDeep=I,t.useBoundRunInTask=C,t.useDialog=R,t.useKeyByRoute=T,t.useRunInTask=f,t.useSetUnset=l,t.useSyncState=j,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/utils",
3
- "version": "9.7.3",
3
+ "version": "10.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "node": ">=22.0.0"
23
23
  },
24
24
  "dependencies": {
25
- "@leancodepl/api-date": "9.7.3",
25
+ "@leancodepl/api-date": "10.0.0",
26
26
  "tiny-invariant": ">=1.3.1"
27
27
  },
28
28
  "peerDependencies": {