@okam/core-lib 1.17.2 → 1.17.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.
- package/index.js +1 -1
- package/index.mjs +45 -45
- package/package.json +1 -1
- package/utils/createContext.d.ts +2 -3
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");function p(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new TypeError(`${n===0?"min":"max"} is not a valid integer`)}),e<t)throw new Error("Min cannot be greater than max");return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}class d{static getRandom(e){return e[p(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}function b(t){if(typeof t!="string"||!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t))return!1;try{return new Date(t).toISOString()===t}catch{return!1}}function c(t,e=!0){return typeof t=="string"&&(e?t.trim():t).length>0}function g(t){return typeof t=="object"&&t!==null&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function u(t){return typeof t=="number"&&Number.isSafeInteger(t)}function y(t){return typeof t=="number"&&!Number.isNaN(t)?!0:c(t)?!Number.isNaN(Number.parseInt(t,10)||Number.isNaN(Number.parseFloat(t))):!1}function h(t){const e=typeof t=="string"&&/^-?\d+$/.test(t)?Number.parseInt(t,10):t;return u(e)}function m(t){return u(t)&&t<600&&t>=100}class o{static isPresent(e,r){if(e==null)throw o.createException(r,"Value is null or undefined.")}static safeInteger(e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw o.createException(r,"Value is not a safe integer")}static nonEmptyString(e,r,n){if(!c(e,n??!0))throw o.createException(r)}static never(e,r){throw new Error(r??"Unexpected value")}static createException(e,r){throw typeof e=="function"?e():new Error(e??r??"Assertion did not pass.")}}function N(){const t=s.createContext(void 0);function e(){const r=s.use(t);if(r===void 0)throw new Error("useCtx must be inside a Provider");return r}return[e,t.Provider]}function P(){const t=s.createContext(void 0);function e(){const r=s.use(t);return r===void 0?{}:r}return[e,t.Provider]}function O(t){return t.split("/").reduceRight((n,i)=>n.length===0&&i===""?n:[i,...n],[]).join("/")}function x(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function l(t,e,r){const n=Object.keys(t);let i;i??=r;for(const a of n){const f=t[a];if(x(f)&&(i??=l(f,e,i)),a===e)return t[e]}return i}function w(t,e){const r=t[e];return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(t,e)?r:null}function I(t){return t.charAt(0).toUpperCase()+t.slice(1)}function j(t){return`I'm the @okam/shared-ui component telling ${t} !`}exports.ArrayUtils=d;exports.Asserts=o;exports.capitalizeFirstLetter=I;exports.checkObjectProperty=w;exports.createCtx=N;exports.createCtxNullable=P;exports.getNestedObjectValueOfKey=l;exports.isHttpStatusCode=m;exports.isIsoDateString=b;exports.isNonEmptyString=c;exports.isParsableNumeric=y;exports.isParsableSafeInteger=h;exports.isPlainObject=g;exports.isSafeInteger=u;exports.normalizePath=O;exports.sayHello=j;
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import { createContext as s, use as a } from "react";
|
|
2
|
+
function p(t, e) {
|
|
3
3
|
if ([t, e].forEach((r, n) => {
|
|
4
4
|
if (!Number.isSafeInteger(r))
|
|
5
5
|
throw new TypeError(`${n === 0 ? "min" : "max"} is not a valid integer`);
|
|
@@ -7,16 +7,16 @@ function l(t, e) {
|
|
|
7
7
|
throw new Error("Min cannot be greater than max");
|
|
8
8
|
return t = Math.ceil(t), e = Math.floor(e), Math.floor(Math.random() * (e - t + 1)) + t;
|
|
9
9
|
}
|
|
10
|
-
class
|
|
10
|
+
class m {
|
|
11
11
|
static getRandom(e) {
|
|
12
|
-
return e[
|
|
12
|
+
return e[p(0, e.length - 1)];
|
|
13
13
|
}
|
|
14
14
|
static removeItem(e, r) {
|
|
15
15
|
const n = e.indexOf(r);
|
|
16
16
|
return n > -1 && e.splice(n, 1), e;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function g(t) {
|
|
20
20
|
if (typeof t != "string" || !/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(t))
|
|
21
21
|
return !1;
|
|
22
22
|
try {
|
|
@@ -25,24 +25,24 @@ function h(t) {
|
|
|
25
25
|
return !1;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function f(t, e = !0) {
|
|
29
29
|
return typeof t == "string" && (e ? t.trim() : t).length > 0;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function y(t) {
|
|
32
32
|
return typeof t == "object" && t !== null && t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function l(t) {
|
|
35
35
|
return typeof t == "number" && Number.isSafeInteger(t);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return typeof t == "number" && !Number.isNaN(t) ? !0 :
|
|
37
|
+
function N(t) {
|
|
38
|
+
return typeof t == "number" && !Number.isNaN(t) ? !0 : f(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function w(t) {
|
|
41
41
|
const e = typeof t == "string" && /^-?\d+$/.test(t) ? Number.parseInt(t, 10) : t;
|
|
42
|
-
return
|
|
42
|
+
return l(e);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
44
|
+
function x(t) {
|
|
45
|
+
return l(t) && t < 600 && t >= 100;
|
|
46
46
|
}
|
|
47
47
|
class i {
|
|
48
48
|
static isPresent(e, r) {
|
|
@@ -54,7 +54,7 @@ class i {
|
|
|
54
54
|
throw i.createException(r, "Value is not a safe integer");
|
|
55
55
|
}
|
|
56
56
|
static nonEmptyString(e, r, n) {
|
|
57
|
-
if (!
|
|
57
|
+
if (!f(e, n ?? !0))
|
|
58
58
|
throw i.createException(r);
|
|
59
59
|
}
|
|
60
60
|
static never(e, r) {
|
|
@@ -64,66 +64,66 @@ class i {
|
|
|
64
64
|
throw typeof e == "function" ? e() : new Error(e ?? r ?? "Assertion did not pass.");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const t =
|
|
67
|
+
function I() {
|
|
68
|
+
const t = s(void 0);
|
|
69
69
|
function e() {
|
|
70
|
-
const r =
|
|
70
|
+
const r = a(t);
|
|
71
71
|
if (r === void 0)
|
|
72
72
|
throw new Error("useCtx must be inside a Provider");
|
|
73
73
|
return r;
|
|
74
74
|
}
|
|
75
75
|
return [e, t.Provider];
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
const t =
|
|
77
|
+
function O() {
|
|
78
|
+
const t = s(void 0);
|
|
79
79
|
function e() {
|
|
80
|
-
const r =
|
|
80
|
+
const r = a(t);
|
|
81
81
|
return r === void 0 ? {} : r;
|
|
82
82
|
}
|
|
83
83
|
return [e, t.Provider];
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function P(t) {
|
|
86
86
|
return t.split("/").reduceRight((n, o) => n.length === 0 && o === "" ? n : [o, ...n], []).join("/");
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function d(t) {
|
|
89
89
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function b(t, e, r) {
|
|
92
92
|
const n = Object.keys(t);
|
|
93
93
|
let o;
|
|
94
94
|
o ??= r;
|
|
95
|
-
for (const
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
95
|
+
for (const u of n) {
|
|
96
|
+
const c = t[u];
|
|
97
|
+
if (d(c) && (o ??= b(c, e, o)), u === e)
|
|
98
98
|
return t[e];
|
|
99
99
|
}
|
|
100
100
|
return o;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function j(t, e) {
|
|
103
103
|
const r = t[e];
|
|
104
104
|
return r != null && typeof r == "object" && Object.prototype.hasOwnProperty.call(t, e) ? r : null;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function E(t) {
|
|
107
107
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function C(t) {
|
|
110
110
|
return `I'm the @okam/shared-ui component telling ${t} !`;
|
|
111
111
|
}
|
|
112
112
|
export {
|
|
113
|
-
|
|
113
|
+
m as ArrayUtils,
|
|
114
114
|
i as Asserts,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
E as capitalizeFirstLetter,
|
|
116
|
+
j as checkObjectProperty,
|
|
117
|
+
I as createCtx,
|
|
118
|
+
O as createCtxNullable,
|
|
119
|
+
b as getNestedObjectValueOfKey,
|
|
120
|
+
x as isHttpStatusCode,
|
|
121
|
+
g as isIsoDateString,
|
|
122
|
+
f as isNonEmptyString,
|
|
123
|
+
N as isParsableNumeric,
|
|
124
|
+
w as isParsableSafeInteger,
|
|
125
|
+
y as isPlainObject,
|
|
126
|
+
l as isSafeInteger,
|
|
127
|
+
P as normalizePath,
|
|
128
|
+
C as sayHello
|
|
129
129
|
};
|
package/package.json
CHANGED
package/utils/createContext.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
/**
|
|
3
2
|
* A helper to create a Context and Provider with no upfront default value, and
|
|
4
3
|
* without having to check for undefined all the time.
|
|
5
4
|
*/
|
|
6
|
-
declare function createCtx<A extends object | null>(): readonly [() => A,
|
|
7
|
-
export declare function createCtxNullable<A extends object | null>(): readonly [() => A,
|
|
5
|
+
declare function createCtx<A extends object | null>(): readonly [() => A, import('react').Provider<A | undefined>];
|
|
6
|
+
export declare function createCtxNullable<A extends object | null>(): readonly [() => A, import('react').Provider<A | undefined>];
|
|
8
7
|
export default createCtx;
|