@capsitech/react-utilities 0.1.4 → 0.1.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/lib/Components/SuspenseRoute.d.ts +7 -7
- package/lib/Components/SuspenseRoute.js +29 -29
- package/lib/Components/index.d.ts +1 -1
- package/lib/Components/index.js +1 -1
- package/lib/Hooks/index.d.ts +45 -45
- package/lib/Hooks/index.js +98 -98
- package/lib/Hooks/useInfiniteScroll.d.ts +7 -7
- package/lib/Hooks/useInfiniteScroll.js +22 -22
- package/lib/Hooks/useNetworkState.d.ts +67 -67
- package/lib/Hooks/useNetworkState.js +41 -41
- package/lib/Hooks/useShortcuts.d.ts +4 -4
- package/lib/Hooks/useShortcuts.js +91 -91
- package/lib/Utilities/ApiUtility.axios.d.ts +60 -60
- package/lib/Utilities/ApiUtility.axios.js +305 -305
- package/lib/Utilities/BrowserInfo.d.ts +74 -74
- package/lib/Utilities/BrowserInfo.js +153 -153
- package/lib/Utilities/Countries.d.ts +14 -14
- package/lib/Utilities/Countries.js +290 -290
- package/lib/Utilities/CustomEventEmitter.d.ts +12 -12
- package/lib/Utilities/CustomEventEmitter.js +30 -30
- package/lib/Utilities/FastCompare.d.ts +1 -1
- package/lib/Utilities/FastCompare.js +128 -128
- package/lib/Utilities/HideablePromise.d.ts +5 -5
- package/lib/Utilities/HideablePromise.js +10 -10
- package/lib/Utilities/LoadScripts.d.ts +9 -9
- package/lib/Utilities/LoadScripts.js +51 -51
- package/lib/Utilities/MTDFraudPrevention.d.ts +28 -28
- package/lib/Utilities/MTDFraudPrevention.js +157 -157
- package/lib/Utilities/Nationalities.d.ts +5 -5
- package/lib/Utilities/Nationalities.js +245 -245
- package/lib/Utilities/RouteUtils.d.ts +129 -120
- package/lib/Utilities/RouteUtils.js +223 -206
- package/lib/Utilities/TimeZones.d.ts +10 -10
- package/lib/Utilities/TimeZones.js +1069 -1069
- package/lib/Utilities/Types.d.ts +19 -19
- package/lib/Utilities/Types.js +1 -1
- package/lib/Utilities/Utils.d.ts +174 -174
- package/lib/Utilities/Utils.js +331 -331
- package/lib/Utilities/dayjs.d.ts +18 -18
- package/lib/Utilities/dayjs.js +56 -56
- package/lib/Utilities/index.d.ts +14 -14
- package/lib/Utilities/index.js +14 -14
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/package.json +12 -25
package/lib/Utilities/dayjs.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import dayjsBase from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/en-gb';
|
|
3
|
-
import AdvancedFormat from 'dayjs/plugin/advancedFormat';
|
|
4
|
-
import CustomParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import Duration from 'dayjs/plugin/duration';
|
|
6
|
-
import IsSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
7
|
-
import IsSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
|
-
import RelativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
-
import tz from 'dayjs/plugin/timezone';
|
|
10
|
-
import utc from 'dayjs/plugin/utc';
|
|
11
|
-
import Weekday from 'dayjs/plugin/weekday';
|
|
12
|
-
declare module 'dayjs' {
|
|
13
|
-
interface Dayjs {
|
|
14
|
-
addWorkdays(amount: number): dayjsBase.Dayjs;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export declare const dayjs: typeof dayjsBase;
|
|
18
|
-
export type tmpDayJs = typeof dayjsBase | typeof AdvancedFormat | typeof CustomParseFormat | typeof Weekday | typeof IsSameOrAfter | typeof IsSameOrBefore | typeof RelativeTime | typeof utc | typeof tz | typeof Duration;
|
|
1
|
+
import dayjsBase from 'dayjs';
|
|
2
|
+
import 'dayjs/locale/en-gb';
|
|
3
|
+
import AdvancedFormat from 'dayjs/plugin/advancedFormat';
|
|
4
|
+
import CustomParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import Duration from 'dayjs/plugin/duration';
|
|
6
|
+
import IsSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
7
|
+
import IsSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
|
+
import RelativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
+
import tz from 'dayjs/plugin/timezone';
|
|
10
|
+
import utc from 'dayjs/plugin/utc';
|
|
11
|
+
import Weekday from 'dayjs/plugin/weekday';
|
|
12
|
+
declare module 'dayjs' {
|
|
13
|
+
interface Dayjs {
|
|
14
|
+
addWorkdays(amount: number): dayjsBase.Dayjs;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const dayjs: typeof dayjsBase;
|
|
18
|
+
export type tmpDayJs = typeof dayjsBase | typeof AdvancedFormat | typeof CustomParseFormat | typeof Weekday | typeof IsSameOrAfter | typeof IsSameOrBefore | typeof RelativeTime | typeof utc | typeof tz | typeof Duration;
|
package/lib/Utilities/dayjs.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import dayjsBase from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/en-gb';
|
|
3
|
-
import AdvancedFormat from 'dayjs/plugin/advancedFormat';
|
|
4
|
-
import CustomParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import Duration from 'dayjs/plugin/duration';
|
|
6
|
-
import IsSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
7
|
-
import IsSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
|
-
import RelativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
-
import tz from 'dayjs/plugin/timezone';
|
|
10
|
-
import utc from 'dayjs/plugin/utc';
|
|
11
|
-
import Weekday from 'dayjs/plugin/weekday';
|
|
12
|
-
dayjsBase.locale('en-gb');
|
|
13
|
-
dayjsBase.extend(AdvancedFormat);
|
|
14
|
-
dayjsBase.extend(CustomParseFormat);
|
|
15
|
-
dayjsBase.extend(Weekday);
|
|
16
|
-
dayjsBase.extend(IsSameOrAfter);
|
|
17
|
-
dayjsBase.extend(IsSameOrBefore);
|
|
18
|
-
dayjsBase.extend(RelativeTime);
|
|
19
|
-
dayjsBase.extend(utc);
|
|
20
|
-
dayjsBase.extend(tz);
|
|
21
|
-
dayjsBase.extend(Duration);
|
|
22
|
-
const addWorkdays = (option, c) => {
|
|
23
|
-
function determineSign(x) {
|
|
24
|
-
x = +x;
|
|
25
|
-
return x > 0 ? 1 : -1;
|
|
26
|
-
}
|
|
27
|
-
c.prototype.addWorkdays = function (amount) {
|
|
28
|
-
if (amount === 0 || isNaN(amount)) {
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
var sign = determineSign(amount);
|
|
32
|
-
var day = this.day();
|
|
33
|
-
var absIncrement = Math.abs(amount);
|
|
34
|
-
var days = 0;
|
|
35
|
-
if (day === 0 && sign === -1) {
|
|
36
|
-
days = 1;
|
|
37
|
-
}
|
|
38
|
-
else if (day === 6 && sign === 1) {
|
|
39
|
-
days = 1;
|
|
40
|
-
}
|
|
41
|
-
// Add padding for weekends.
|
|
42
|
-
var paddedAbsIncrement = absIncrement;
|
|
43
|
-
if (day !== 0 && day !== 6 && sign > 0) {
|
|
44
|
-
paddedAbsIncrement += day;
|
|
45
|
-
}
|
|
46
|
-
else if (day !== 0 && day !== 6 && sign < 0) {
|
|
47
|
-
paddedAbsIncrement += 6 - day;
|
|
48
|
-
}
|
|
49
|
-
var weekendsInbetween = Math.max(Math.floor(paddedAbsIncrement / 5) - 1, 0) + (paddedAbsIncrement > 5 && paddedAbsIncrement % 5 > 0 ? 1 : 0);
|
|
50
|
-
// Add the increment and number of weekends.
|
|
51
|
-
days += absIncrement + weekendsInbetween * 2;
|
|
52
|
-
return this.add(sign * days, 'day');
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
dayjsBase.extend(addWorkdays);
|
|
56
|
-
export const dayjs = dayjsBase;
|
|
1
|
+
import dayjsBase from 'dayjs';
|
|
2
|
+
import 'dayjs/locale/en-gb';
|
|
3
|
+
import AdvancedFormat from 'dayjs/plugin/advancedFormat';
|
|
4
|
+
import CustomParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import Duration from 'dayjs/plugin/duration';
|
|
6
|
+
import IsSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
7
|
+
import IsSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
|
+
import RelativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
+
import tz from 'dayjs/plugin/timezone';
|
|
10
|
+
import utc from 'dayjs/plugin/utc';
|
|
11
|
+
import Weekday from 'dayjs/plugin/weekday';
|
|
12
|
+
dayjsBase.locale('en-gb');
|
|
13
|
+
dayjsBase.extend(AdvancedFormat);
|
|
14
|
+
dayjsBase.extend(CustomParseFormat);
|
|
15
|
+
dayjsBase.extend(Weekday);
|
|
16
|
+
dayjsBase.extend(IsSameOrAfter);
|
|
17
|
+
dayjsBase.extend(IsSameOrBefore);
|
|
18
|
+
dayjsBase.extend(RelativeTime);
|
|
19
|
+
dayjsBase.extend(utc);
|
|
20
|
+
dayjsBase.extend(tz);
|
|
21
|
+
dayjsBase.extend(Duration);
|
|
22
|
+
const addWorkdays = (option, c) => {
|
|
23
|
+
function determineSign(x) {
|
|
24
|
+
x = +x;
|
|
25
|
+
return x > 0 ? 1 : -1;
|
|
26
|
+
}
|
|
27
|
+
c.prototype.addWorkdays = function (amount) {
|
|
28
|
+
if (amount === 0 || isNaN(amount)) {
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
var sign = determineSign(amount);
|
|
32
|
+
var day = this.day();
|
|
33
|
+
var absIncrement = Math.abs(amount);
|
|
34
|
+
var days = 0;
|
|
35
|
+
if (day === 0 && sign === -1) {
|
|
36
|
+
days = 1;
|
|
37
|
+
}
|
|
38
|
+
else if (day === 6 && sign === 1) {
|
|
39
|
+
days = 1;
|
|
40
|
+
}
|
|
41
|
+
// Add padding for weekends.
|
|
42
|
+
var paddedAbsIncrement = absIncrement;
|
|
43
|
+
if (day !== 0 && day !== 6 && sign > 0) {
|
|
44
|
+
paddedAbsIncrement += day;
|
|
45
|
+
}
|
|
46
|
+
else if (day !== 0 && day !== 6 && sign < 0) {
|
|
47
|
+
paddedAbsIncrement += 6 - day;
|
|
48
|
+
}
|
|
49
|
+
var weekendsInbetween = Math.max(Math.floor(paddedAbsIncrement / 5) - 1, 0) + (paddedAbsIncrement > 5 && paddedAbsIncrement % 5 > 0 ? 1 : 0);
|
|
50
|
+
// Add the increment and number of weekends.
|
|
51
|
+
days += absIncrement + weekendsInbetween * 2;
|
|
52
|
+
return this.add(sign * days, 'day');
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
dayjsBase.extend(addWorkdays);
|
|
56
|
+
export const dayjs = dayjsBase;
|
package/lib/Utilities/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from './ApiUtility.axios';
|
|
2
|
-
export * from './BrowserInfo';
|
|
3
|
-
export * from './Countries';
|
|
4
|
-
export * from './CustomEventEmitter';
|
|
5
|
-
export * from './dayjs';
|
|
6
|
-
export * from './FastCompare';
|
|
7
|
-
export * from './HideablePromise';
|
|
8
|
-
export * from './LoadScripts';
|
|
9
|
-
export * from './MTDFraudPrevention';
|
|
10
|
-
export * from './Nationalities';
|
|
11
|
-
export * from './RouteUtils';
|
|
12
|
-
export * from './TimeZones';
|
|
13
|
-
export * from './Types';
|
|
14
|
-
export * from './Utils';
|
|
1
|
+
export * from './ApiUtility.axios';
|
|
2
|
+
export * from './BrowserInfo';
|
|
3
|
+
export * from './Countries';
|
|
4
|
+
export * from './CustomEventEmitter';
|
|
5
|
+
export * from './dayjs';
|
|
6
|
+
export * from './FastCompare';
|
|
7
|
+
export * from './HideablePromise';
|
|
8
|
+
export * from './LoadScripts';
|
|
9
|
+
export * from './MTDFraudPrevention';
|
|
10
|
+
export * from './Nationalities';
|
|
11
|
+
export * from './RouteUtils';
|
|
12
|
+
export * from './TimeZones';
|
|
13
|
+
export * from './Types';
|
|
14
|
+
export * from './Utils';
|
package/lib/Utilities/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from './ApiUtility.axios';
|
|
2
|
-
export * from './BrowserInfo';
|
|
3
|
-
export * from './Countries';
|
|
4
|
-
export * from './CustomEventEmitter';
|
|
5
|
-
export * from './dayjs';
|
|
6
|
-
export * from './FastCompare';
|
|
7
|
-
export * from './HideablePromise';
|
|
8
|
-
export * from './LoadScripts';
|
|
9
|
-
export * from './MTDFraudPrevention';
|
|
10
|
-
export * from './Nationalities';
|
|
11
|
-
export * from './RouteUtils';
|
|
12
|
-
export * from './TimeZones';
|
|
13
|
-
export * from './Types';
|
|
14
|
-
export * from './Utils';
|
|
1
|
+
export * from './ApiUtility.axios';
|
|
2
|
+
export * from './BrowserInfo';
|
|
3
|
+
export * from './Countries';
|
|
4
|
+
export * from './CustomEventEmitter';
|
|
5
|
+
export * from './dayjs';
|
|
6
|
+
export * from './FastCompare';
|
|
7
|
+
export * from './HideablePromise';
|
|
8
|
+
export * from './LoadScripts';
|
|
9
|
+
export * from './MTDFraudPrevention';
|
|
10
|
+
export * from './Nationalities';
|
|
11
|
+
export * from './RouteUtils';
|
|
12
|
+
export * from './TimeZones';
|
|
13
|
+
export * from './Types';
|
|
14
|
+
export * from './Utils';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Components';
|
|
2
|
-
export * from './Hooks';
|
|
3
|
-
export * from './Utilities';
|
|
1
|
+
export * from './Components';
|
|
2
|
+
export * from './Hooks';
|
|
3
|
+
export * from './Utilities';
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Components';
|
|
2
|
-
export * from './Hooks';
|
|
3
|
-
export * from './Utilities';
|
|
1
|
+
export * from './Components';
|
|
2
|
+
export * from './Hooks';
|
|
3
|
+
export * from './Utilities';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capsitech/react-utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A set of javascript utility methods",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"jsnext:main": "lib/index.js",
|
|
@@ -40,42 +40,29 @@
|
|
|
40
40
|
"lodash": "^4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"axios": "^1.
|
|
43
|
+
"axios": "^1.11.0",
|
|
44
44
|
"file-saver": "^2.0.5",
|
|
45
|
+
"qs": "^6.14.0",
|
|
45
46
|
"react": ">=18",
|
|
46
47
|
"react-dom": ">=18"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@storybook/addon-
|
|
50
|
-
"@storybook/addon-essentials": "^8.6.14",
|
|
51
|
-
"@storybook/addon-links": "^8.6.14",
|
|
52
|
-
"@storybook/addon-storysource": "^8.6.14",
|
|
50
|
+
"@storybook/addon-docs": "^9.1.2",
|
|
53
51
|
"@storybook/addon-webpack5-compiler-babel": "^3.0.6",
|
|
54
|
-
"@storybook/react": "^
|
|
55
|
-
"@storybook/react-webpack5": "^8.6.14",
|
|
56
|
-
"@storybook/test": "^8.6.14",
|
|
52
|
+
"@storybook/react-webpack5": "^9.1.2",
|
|
57
53
|
"@types/file-saver": "^2.0.7",
|
|
58
|
-
"@types/lodash": "4.17.
|
|
54
|
+
"@types/lodash": "4.17.20",
|
|
55
|
+
"@types/qs": "^6",
|
|
59
56
|
"@types/react": "^18.3.12",
|
|
60
|
-
"
|
|
61
|
-
"@typescript-eslint/parser": "^8.13.0",
|
|
62
|
-
"axios": "^1.9.0",
|
|
63
|
-
"copyfiles": "2.4.1",
|
|
64
|
-
"cross-env": "^7.0.3",
|
|
65
|
-
"eslint": "^9.14.0",
|
|
66
|
-
"eslint-config-standard": "^17.1.0",
|
|
67
|
-
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
68
|
-
"eslint-import-resolver-typescript": "^3.6.3",
|
|
69
|
-
"eslint-plugin-react": "^7.37.2",
|
|
70
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
57
|
+
"axios": "^1.11.0",
|
|
71
58
|
"file-saver": "^2.0.5",
|
|
59
|
+
"qs": "^6.14.0",
|
|
72
60
|
"react": "^18.3.1",
|
|
73
61
|
"react-dom": "^18.3.1",
|
|
74
|
-
"react-router-dom": "
|
|
75
|
-
"react-scripts": "5.0.1",
|
|
62
|
+
"react-router-dom": "^7.8.1",
|
|
76
63
|
"rimraf": "6.0.1",
|
|
77
|
-
"storybook": "^
|
|
78
|
-
"typescript": "
|
|
64
|
+
"storybook": "^9.1.2",
|
|
65
|
+
"typescript": "5.8.3"
|
|
79
66
|
},
|
|
80
67
|
"browserslist": {
|
|
81
68
|
"production": [
|