@bikiran/utils 2.3.2 → 2.3.4
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/dist/index.d.ts +9 -0
- package/dist/index.js +5 -0
- package/dist/index.ts +42 -0
- package/dist/lib/types/app.d.ts +9 -0
- package/dist/lib/types/app.js +1 -0
- package/dist/lib/types/app.ts +9 -0
- package/dist/lib/types/domain.d.ts +26 -0
- package/dist/lib/types/domain.js +1 -0
- package/dist/lib/types/domain.ts +28 -0
- package/dist/lib/types/event.d.ts +9 -0
- package/dist/lib/types/event.js +1 -0
- package/dist/lib/types/event.ts +17 -0
- package/dist/lib/types/invoice.d.ts +111 -0
- package/dist/lib/types/invoice.js +1 -0
- package/dist/lib/types/invoice.ts +118 -0
- package/dist/lib/types/response.d.ts +11 -0
- package/dist/lib/types/response.js +1 -0
- package/dist/lib/types/response.ts +12 -0
- package/dist/lib/types/user.d.ts +4 -0
- package/dist/lib/types/user.js +1 -0
- package/dist/lib/types/user.ts +4 -0
- package/dist/lib/utils/OutsideClick.d.ts +1 -0
- package/dist/lib/utils/OutsideClick.js +35 -0
- package/dist/lib/utils/OutsideClick.ts +43 -0
- package/dist/lib/utils/showSize.d.ts +1 -0
- package/dist/lib/utils/showSize.js +18 -0
- package/dist/lib/utils/showSize.ts +23 -0
- package/dist/lib/utils/statusColor.d.ts +7 -0
- package/dist/lib/utils/statusColor.js +35 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,16 @@ export { showCurrencySign, showInt } from "./lib/utils/show";
|
|
|
27
27
|
export { addOption, addOption2 } from "./lib/utils/option";
|
|
28
28
|
export { getBikiranUrl, getAccountUrl, getApiUrl, getApi2Url, getApi3Url, getBaseDomain, getSupportUrl, generateAnyUrl, getAdManageUrl, getAppoceanUrl, getDBConnectionString, getDocsUrl, getDomainUrl, getHostingUrl, getSiteUrl, SUB_DOMAIN_NAMES, isDev, getMode, } from "./lib/utils/Env";
|
|
29
29
|
export type { TInputChangeEvent, TTextAreaChangeEvent, TMouseEvent, TFormEvent, TKeyboardEvent, TFocusEvent, TDragEvent, TState, } from "./lib/types/GlobalType";
|
|
30
|
+
export type { TDomainProperty, TDomainDuration, TDomainInfo, } from "./lib/types/domain";
|
|
31
|
+
export type { TApp } from "./lib/types/app";
|
|
32
|
+
export type { TInputChangeEvent as TInputChangeEventAlt, TTextAreaChangeEvent as TTextAreaChangeEventAlt, TMouseEvent as TMouseEventAlt, TFormEvent as TFormEventAlt, TKeyboardEvent as TKeyboardEventAlt, TFocusEvent as TFocusEventAlt, TDragEvent as TDragEventAlt, TState as TStateAlt, } from "./lib/types/event";
|
|
33
|
+
export type { TUser } from "./lib/types/user";
|
|
34
|
+
export type { TApiResponse, TPagination } from "./lib/types/response";
|
|
35
|
+
export type { TInvoiceInfo, TAddressBilling, TAddressShipping, } from "./lib/types/invoice";
|
|
30
36
|
export { default as countries } from "./lib/utils/country.json";
|
|
31
37
|
export { win, doc, storage } from "./lib/utils/dom";
|
|
32
38
|
export { setLocalStorage, getLocalStorage } from "./lib/utils/storage";
|
|
33
39
|
export { mkQueryString, mkToken, mkStrongPassword, } from "./lib/utils/StringOperation";
|
|
40
|
+
export { default as StatusColor } from "./lib/utils/statusColor";
|
|
41
|
+
export { useOutsideClick } from "./lib/utils/OutsideClick";
|
|
42
|
+
export { showSize } from "./lib/utils/showSize";
|
package/dist/index.js
CHANGED
|
@@ -30,3 +30,8 @@ export { default as countries } from "./lib/utils/country.json";
|
|
|
30
30
|
export { win, doc, storage } from "./lib/utils/dom";
|
|
31
31
|
export { setLocalStorage, getLocalStorage } from "./lib/utils/storage";
|
|
32
32
|
export { mkQueryString, mkToken, mkStrongPassword, } from "./lib/utils/StringOperation";
|
|
33
|
+
// UI utilities
|
|
34
|
+
export { default as StatusColor } from "./lib/utils/statusColor";
|
|
35
|
+
// React hooks
|
|
36
|
+
export { useOutsideClick } from "./lib/utils/OutsideClick";
|
|
37
|
+
export { showSize } from "./lib/utils/showSize";
|
package/dist/index.ts
CHANGED
|
@@ -61,6 +61,41 @@ export type {
|
|
|
61
61
|
TDragEvent,
|
|
62
62
|
TState,
|
|
63
63
|
} from "./lib/types/GlobalType";
|
|
64
|
+
|
|
65
|
+
// Domain types
|
|
66
|
+
export type {
|
|
67
|
+
TDomainProperty,
|
|
68
|
+
TDomainDuration,
|
|
69
|
+
TDomainInfo,
|
|
70
|
+
} from "./lib/types/domain";
|
|
71
|
+
|
|
72
|
+
// App types
|
|
73
|
+
export type { TApp } from "./lib/types/app";
|
|
74
|
+
|
|
75
|
+
// Event types (alternative to GlobalType)
|
|
76
|
+
export type {
|
|
77
|
+
TInputChangeEvent as TInputChangeEventAlt,
|
|
78
|
+
TTextAreaChangeEvent as TTextAreaChangeEventAlt,
|
|
79
|
+
TMouseEvent as TMouseEventAlt,
|
|
80
|
+
TFormEvent as TFormEventAlt,
|
|
81
|
+
TKeyboardEvent as TKeyboardEventAlt,
|
|
82
|
+
TFocusEvent as TFocusEventAlt,
|
|
83
|
+
TDragEvent as TDragEventAlt,
|
|
84
|
+
TState as TStateAlt,
|
|
85
|
+
} from "./lib/types/event";
|
|
86
|
+
|
|
87
|
+
// User types
|
|
88
|
+
export type { TUser } from "./lib/types/user";
|
|
89
|
+
|
|
90
|
+
// Response types
|
|
91
|
+
export type { TApiResponse, TPagination } from "./lib/types/response";
|
|
92
|
+
|
|
93
|
+
// Invoice types
|
|
94
|
+
export type {
|
|
95
|
+
TInvoiceInfo,
|
|
96
|
+
TAddressBilling,
|
|
97
|
+
TAddressShipping,
|
|
98
|
+
} from "./lib/types/invoice";
|
|
64
99
|
export { default as countries } from "./lib/utils/country.json";
|
|
65
100
|
export { win, doc, storage } from "./lib/utils/dom";
|
|
66
101
|
export { setLocalStorage, getLocalStorage } from "./lib/utils/storage";
|
|
@@ -69,3 +104,10 @@ export {
|
|
|
69
104
|
mkToken,
|
|
70
105
|
mkStrongPassword,
|
|
71
106
|
} from "./lib/utils/StringOperation";
|
|
107
|
+
|
|
108
|
+
// UI utilities
|
|
109
|
+
export { default as StatusColor } from "./lib/utils/statusColor";
|
|
110
|
+
|
|
111
|
+
// React hooks
|
|
112
|
+
export { useOutsideClick } from "./lib/utils/OutsideClick";
|
|
113
|
+
export { showSize } from "./lib/utils/showSize";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type TDomainProperty = {
|
|
2
|
+
domainName: string;
|
|
3
|
+
tld: string;
|
|
4
|
+
isAvailable: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type TDomainDuration = {
|
|
7
|
+
quantity: number;
|
|
8
|
+
price: number;
|
|
9
|
+
offerPrice: number;
|
|
10
|
+
save: number;
|
|
11
|
+
};
|
|
12
|
+
export type TDomainInfo = {
|
|
13
|
+
packageId: number;
|
|
14
|
+
assetKey: string;
|
|
15
|
+
cartItemId: number;
|
|
16
|
+
title: string;
|
|
17
|
+
minQuantity: number;
|
|
18
|
+
selectedQuantity: number;
|
|
19
|
+
price: number;
|
|
20
|
+
priceRenew: number;
|
|
21
|
+
durations: TDomainDuration[];
|
|
22
|
+
unitName: string;
|
|
23
|
+
domainName: string;
|
|
24
|
+
domainProperty: TDomainProperty;
|
|
25
|
+
hostingProperty: any;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type TDomainProperty = {
|
|
2
|
+
domainName: string;
|
|
3
|
+
tld: string;
|
|
4
|
+
isAvailable: boolean;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type TDomainDuration = {
|
|
8
|
+
quantity: number;
|
|
9
|
+
price: number;
|
|
10
|
+
offerPrice: number;
|
|
11
|
+
save: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type TDomainInfo = {
|
|
15
|
+
packageId: number;
|
|
16
|
+
assetKey: string;
|
|
17
|
+
cartItemId: number;
|
|
18
|
+
title: string;
|
|
19
|
+
minQuantity: number;
|
|
20
|
+
selectedQuantity: number;
|
|
21
|
+
price: number;
|
|
22
|
+
priceRenew: number;
|
|
23
|
+
durations: TDomainDuration[];
|
|
24
|
+
unitName: string;
|
|
25
|
+
domainName: string;
|
|
26
|
+
domainProperty: TDomainProperty;
|
|
27
|
+
hostingProperty: any;
|
|
28
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type TInputChangeEvent = React.ChangeEvent<HTMLInputElement>;
|
|
3
|
+
export type TTextAreaChangeEvent = React.ChangeEvent<HTMLTextAreaElement>;
|
|
4
|
+
export type TMouseEvent = React.MouseEvent<HTMLButtonElement>;
|
|
5
|
+
export type TFormEvent = React.FormEvent<HTMLFormElement>;
|
|
6
|
+
export type TKeyboardEvent = React.KeyboardEvent<HTMLInputElement>;
|
|
7
|
+
export type TFocusEvent = React.FocusEvent<HTMLInputElement>;
|
|
8
|
+
export type TDragEvent = React.DragEvent<HTMLDivElement>;
|
|
9
|
+
export type TState<T> = React.Dispatch<React.SetStateAction<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export type TInputChangeEvent = React.ChangeEvent<HTMLInputElement>;
|
|
4
|
+
|
|
5
|
+
export type TTextAreaChangeEvent = React.ChangeEvent<HTMLTextAreaElement>;
|
|
6
|
+
|
|
7
|
+
export type TMouseEvent = React.MouseEvent<HTMLButtonElement>;
|
|
8
|
+
|
|
9
|
+
export type TFormEvent = React.FormEvent<HTMLFormElement>;
|
|
10
|
+
|
|
11
|
+
export type TKeyboardEvent = React.KeyboardEvent<HTMLInputElement>;
|
|
12
|
+
|
|
13
|
+
export type TFocusEvent = React.FocusEvent<HTMLInputElement>;
|
|
14
|
+
|
|
15
|
+
export type TDragEvent = React.DragEvent<HTMLDivElement>;
|
|
16
|
+
|
|
17
|
+
export type TState<T> = React.Dispatch<React.SetStateAction<T>>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export type TInvoiceInfo = {
|
|
2
|
+
id: number;
|
|
3
|
+
customId: string;
|
|
4
|
+
userId: number;
|
|
5
|
+
projectId: number;
|
|
6
|
+
billingId: number;
|
|
7
|
+
invoiceTitle: string;
|
|
8
|
+
localCurrency: string;
|
|
9
|
+
convertRatio: number;
|
|
10
|
+
paymentStatus: string;
|
|
11
|
+
paymentTime: number;
|
|
12
|
+
timeIssue: number;
|
|
13
|
+
timeDue: number;
|
|
14
|
+
totalItem: number;
|
|
15
|
+
totalPrice: number;
|
|
16
|
+
totalOfferPrice: number;
|
|
17
|
+
totalVat: number;
|
|
18
|
+
totalSaving: number;
|
|
19
|
+
totalPaid: number;
|
|
20
|
+
totalDue: number;
|
|
21
|
+
noteTitle: string;
|
|
22
|
+
noteDescription: string;
|
|
23
|
+
status: string;
|
|
24
|
+
gatewayId: number;
|
|
25
|
+
};
|
|
26
|
+
export type TAddressBilling = {
|
|
27
|
+
name: string;
|
|
28
|
+
organization: string;
|
|
29
|
+
email: string;
|
|
30
|
+
mobile: string;
|
|
31
|
+
telephone: string;
|
|
32
|
+
fax: string;
|
|
33
|
+
line1: string;
|
|
34
|
+
line2: string;
|
|
35
|
+
line3: string;
|
|
36
|
+
country: string;
|
|
37
|
+
state: string;
|
|
38
|
+
city: string;
|
|
39
|
+
zipCode: string;
|
|
40
|
+
};
|
|
41
|
+
export type TAddressShipping = {
|
|
42
|
+
name: string;
|
|
43
|
+
organization: string;
|
|
44
|
+
email: string;
|
|
45
|
+
mobile: string;
|
|
46
|
+
telephone: string;
|
|
47
|
+
fax: string;
|
|
48
|
+
line1: string;
|
|
49
|
+
line2: string;
|
|
50
|
+
line3: string;
|
|
51
|
+
country: string;
|
|
52
|
+
state: string;
|
|
53
|
+
city: string;
|
|
54
|
+
zipCode: string;
|
|
55
|
+
};
|
|
56
|
+
export type TInvoiceProduct = {
|
|
57
|
+
id: number;
|
|
58
|
+
type: string;
|
|
59
|
+
title: string;
|
|
60
|
+
quantity: number;
|
|
61
|
+
unitName: string;
|
|
62
|
+
domain: string;
|
|
63
|
+
price: number;
|
|
64
|
+
priceOffer: number;
|
|
65
|
+
vat: number;
|
|
66
|
+
totalPrice: number;
|
|
67
|
+
duration: string;
|
|
68
|
+
};
|
|
69
|
+
export type TPaymentOption = {
|
|
70
|
+
id: number;
|
|
71
|
+
provider: string;
|
|
72
|
+
title: string;
|
|
73
|
+
subTitle: string;
|
|
74
|
+
buttonText: string;
|
|
75
|
+
isDefault: number;
|
|
76
|
+
icon: string;
|
|
77
|
+
priority: number;
|
|
78
|
+
status: string;
|
|
79
|
+
};
|
|
80
|
+
export type TPaymentIssue = {
|
|
81
|
+
key: string;
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
84
|
+
export type TAddressPayload = {
|
|
85
|
+
type: string;
|
|
86
|
+
name: string;
|
|
87
|
+
organization: string;
|
|
88
|
+
email: string;
|
|
89
|
+
mobile: string;
|
|
90
|
+
telephone: string;
|
|
91
|
+
fax: string;
|
|
92
|
+
line1: string;
|
|
93
|
+
line2: string;
|
|
94
|
+
line3: string;
|
|
95
|
+
country: string;
|
|
96
|
+
state: string;
|
|
97
|
+
city: string;
|
|
98
|
+
zipCode: string;
|
|
99
|
+
};
|
|
100
|
+
export type TInvoiceData = {
|
|
101
|
+
invoice: TInvoiceInfo;
|
|
102
|
+
items: TInvoiceProduct[];
|
|
103
|
+
addressBilling: TAddressBilling;
|
|
104
|
+
addressShipping: TAddressShipping;
|
|
105
|
+
paymentGateways?: TPaymentOption[];
|
|
106
|
+
paymentIssues?: TPaymentIssue[];
|
|
107
|
+
linkDownload: string;
|
|
108
|
+
linkPrint: string;
|
|
109
|
+
transactions?: [];
|
|
110
|
+
notFound?: boolean;
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type TInvoiceInfo = {
|
|
2
|
+
id: number;
|
|
3
|
+
customId: string;
|
|
4
|
+
userId: number;
|
|
5
|
+
projectId: number;
|
|
6
|
+
billingId: number;
|
|
7
|
+
invoiceTitle: string;
|
|
8
|
+
localCurrency: string;
|
|
9
|
+
convertRatio: number;
|
|
10
|
+
paymentStatus: string;
|
|
11
|
+
paymentTime: number;
|
|
12
|
+
timeIssue: number;
|
|
13
|
+
timeDue: number;
|
|
14
|
+
totalItem: number;
|
|
15
|
+
totalPrice: number;
|
|
16
|
+
totalOfferPrice: number;
|
|
17
|
+
totalVat: number;
|
|
18
|
+
totalSaving: number;
|
|
19
|
+
totalPaid: number;
|
|
20
|
+
totalDue: number;
|
|
21
|
+
noteTitle: string;
|
|
22
|
+
noteDescription: string;
|
|
23
|
+
status: string;
|
|
24
|
+
gatewayId: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type TAddressBilling = {
|
|
28
|
+
name: string;
|
|
29
|
+
organization: string;
|
|
30
|
+
email: string;
|
|
31
|
+
mobile: string;
|
|
32
|
+
telephone: string;
|
|
33
|
+
fax: string;
|
|
34
|
+
line1: string;
|
|
35
|
+
line2: string;
|
|
36
|
+
line3: string;
|
|
37
|
+
country: string;
|
|
38
|
+
state: string;
|
|
39
|
+
city: string;
|
|
40
|
+
zipCode: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type TAddressShipping = {
|
|
44
|
+
name: string;
|
|
45
|
+
organization: string;
|
|
46
|
+
email: string;
|
|
47
|
+
mobile: string;
|
|
48
|
+
telephone: string;
|
|
49
|
+
fax: string;
|
|
50
|
+
line1: string;
|
|
51
|
+
line2: string;
|
|
52
|
+
line3: string;
|
|
53
|
+
country: string;
|
|
54
|
+
state: string;
|
|
55
|
+
city: string;
|
|
56
|
+
zipCode: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type TInvoiceProduct = {
|
|
60
|
+
id: number;
|
|
61
|
+
type: string;
|
|
62
|
+
title: string;
|
|
63
|
+
quantity: number;
|
|
64
|
+
unitName: string;
|
|
65
|
+
domain: string;
|
|
66
|
+
price: number;
|
|
67
|
+
priceOffer: number;
|
|
68
|
+
vat: number;
|
|
69
|
+
totalPrice: number;
|
|
70
|
+
duration: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type TPaymentOption = {
|
|
74
|
+
id: number;
|
|
75
|
+
provider: string;
|
|
76
|
+
title: string;
|
|
77
|
+
subTitle: string;
|
|
78
|
+
buttonText: string;
|
|
79
|
+
isDefault: number;
|
|
80
|
+
icon: string;
|
|
81
|
+
priority: number;
|
|
82
|
+
status: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type TPaymentIssue = {
|
|
86
|
+
key: string;
|
|
87
|
+
message: string;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type TAddressPayload = {
|
|
91
|
+
type: string;
|
|
92
|
+
name: string;
|
|
93
|
+
organization: string;
|
|
94
|
+
email: string;
|
|
95
|
+
mobile: string;
|
|
96
|
+
telephone: string;
|
|
97
|
+
fax: string;
|
|
98
|
+
line1: string;
|
|
99
|
+
line2: string;
|
|
100
|
+
line3: string;
|
|
101
|
+
country: string;
|
|
102
|
+
state: string;
|
|
103
|
+
city: string;
|
|
104
|
+
zipCode: string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type TInvoiceData = {
|
|
108
|
+
invoice: TInvoiceInfo;
|
|
109
|
+
items: TInvoiceProduct[];
|
|
110
|
+
addressBilling: TAddressBilling;
|
|
111
|
+
addressShipping: TAddressShipping;
|
|
112
|
+
paymentGateways?: TPaymentOption[];
|
|
113
|
+
paymentIssues?: TPaymentIssue[];
|
|
114
|
+
linkDownload: string;
|
|
115
|
+
linkPrint: string;
|
|
116
|
+
transactions?: [];
|
|
117
|
+
notFound?: boolean;
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useOutsideClick(ref: React.RefObject<HTMLElement>, callback: () => void, ignoreClassNames?: string[]): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export function useOutsideClick(ref, callback, ignoreClassNames) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
function handleClickOutside(event) {
|
|
5
|
+
const target = event.target;
|
|
6
|
+
// Check if the click is outside the referenced element
|
|
7
|
+
if (ref.current && !ref.current.contains(target)) {
|
|
8
|
+
// If ignoreClassNames is provided, check if the clicked element has any of those classes
|
|
9
|
+
if (ignoreClassNames && ignoreClassNames.length > 0) {
|
|
10
|
+
const hasIgnoredClass = ignoreClassNames.some((className) => {
|
|
11
|
+
var _a;
|
|
12
|
+
// Check if the clicked element or any of its parents has the ignored class
|
|
13
|
+
let element = target;
|
|
14
|
+
while (element) {
|
|
15
|
+
if ((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains(className)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
element = element.parentElement;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
});
|
|
22
|
+
// Don't trigger callback if clicked element has an ignored class
|
|
23
|
+
if (hasIgnoredClass) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
callback();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
31
|
+
return () => {
|
|
32
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
33
|
+
};
|
|
34
|
+
}, [ref, callback, ignoreClassNames]);
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export function useOutsideClick(
|
|
4
|
+
ref: React.RefObject<HTMLElement>,
|
|
5
|
+
callback: () => void,
|
|
6
|
+
ignoreClassNames?: string[]
|
|
7
|
+
) {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
function handleClickOutside(event: MouseEvent) {
|
|
10
|
+
const target = event.target as HTMLElement;
|
|
11
|
+
|
|
12
|
+
// Check if the click is outside the referenced element
|
|
13
|
+
if (ref.current && !ref.current.contains(target)) {
|
|
14
|
+
// If ignoreClassNames is provided, check if the clicked element has any of those classes
|
|
15
|
+
if (ignoreClassNames && ignoreClassNames.length > 0) {
|
|
16
|
+
const hasIgnoredClass = ignoreClassNames.some((className) => {
|
|
17
|
+
// Check if the clicked element or any of its parents has the ignored class
|
|
18
|
+
let element: HTMLElement | null = target;
|
|
19
|
+
while (element) {
|
|
20
|
+
if (element.classList?.contains(className)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
element = element.parentElement;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Don't trigger callback if clicked element has an ignored class
|
|
29
|
+
if (hasIgnoredClass) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
callback();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
39
|
+
return () => {
|
|
40
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
41
|
+
};
|
|
42
|
+
}, [ref, callback, ignoreClassNames]);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function showSize(value: number, fromUnit?: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function showSize(value, fromUnit = "bytes") {
|
|
2
|
+
const units = ["bytes", "KB", "MB", "GB", "TB"];
|
|
3
|
+
const normalizedUnit = fromUnit.toLowerCase();
|
|
4
|
+
// Convert units array to lowercase for comparison
|
|
5
|
+
const unitIndex = units.map((u) => u.toLowerCase()).indexOf(normalizedUnit);
|
|
6
|
+
if (unitIndex === -1) {
|
|
7
|
+
console.error(`Invalid unit: ${fromUnit}. Using 'bytes' as default.`);
|
|
8
|
+
return showSize(value, "bytes"); // Recursively call with default unit
|
|
9
|
+
}
|
|
10
|
+
// Convert the input value to bytes first
|
|
11
|
+
const bytes = value * Math.pow(1024, unitIndex);
|
|
12
|
+
// Then convert bytes to the most appropriate unit
|
|
13
|
+
if (bytes === 0)
|
|
14
|
+
return "0 bytes";
|
|
15
|
+
const k = 1024;
|
|
16
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
17
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + units[i];
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function showSize(value: number, fromUnit: string = "bytes"): string {
|
|
2
|
+
const units = ["bytes", "KB", "MB", "GB", "TB"];
|
|
3
|
+
const normalizedUnit = fromUnit.toLowerCase();
|
|
4
|
+
|
|
5
|
+
// Convert units array to lowercase for comparison
|
|
6
|
+
const unitIndex = units.map((u) => u.toLowerCase()).indexOf(normalizedUnit);
|
|
7
|
+
|
|
8
|
+
if (unitIndex === -1) {
|
|
9
|
+
console.error(`Invalid unit: ${fromUnit}. Using 'bytes' as default.`);
|
|
10
|
+
return showSize(value, "bytes"); // Recursively call with default unit
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Convert the input value to bytes first
|
|
14
|
+
const bytes = value * Math.pow(1024, unitIndex);
|
|
15
|
+
|
|
16
|
+
// Then convert bytes to the most appropriate unit
|
|
17
|
+
if (bytes === 0) return "0 bytes";
|
|
18
|
+
|
|
19
|
+
const k = 1024;
|
|
20
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
21
|
+
|
|
22
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + units[i];
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "./cn";
|
|
3
|
+
const StatusColor = ({ status, className }) => {
|
|
4
|
+
const getColor = (status) => {
|
|
5
|
+
switch (status.toLowerCase()) {
|
|
6
|
+
case "active":
|
|
7
|
+
return "text-success";
|
|
8
|
+
case "success":
|
|
9
|
+
return "text-success";
|
|
10
|
+
case "inactive":
|
|
11
|
+
return "text-error";
|
|
12
|
+
case "suspended":
|
|
13
|
+
return "text-error";
|
|
14
|
+
case "pending":
|
|
15
|
+
return "text-yellow-500";
|
|
16
|
+
case "progressing":
|
|
17
|
+
return "text-green-500";
|
|
18
|
+
case "closed":
|
|
19
|
+
return "text-success";
|
|
20
|
+
case "open":
|
|
21
|
+
return "text-secondary";
|
|
22
|
+
case "completed":
|
|
23
|
+
return "text-secondary";
|
|
24
|
+
case "not-configured":
|
|
25
|
+
return "red-500";
|
|
26
|
+
case "failed":
|
|
27
|
+
return "red-500";
|
|
28
|
+
default:
|
|
29
|
+
return "text-black "; // Default color
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
|
33
|
+
return (_jsx("span", { className: cn(getColor(status), className), children: capitalizeFirstLetter(status) || "---" }));
|
|
34
|
+
};
|
|
35
|
+
export default StatusColor;
|