@fctc/widget-logic 5.3.7-beta.16 → 5.3.7-beta.18
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/config.d.mts +5 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +24 -0
- package/dist/config.mjs +2 -0
- package/dist/constants.d.mts +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +24 -0
- package/dist/constants.mjs +2 -0
- package/dist/environment.d.mts +1 -0
- package/dist/environment.d.ts +1 -0
- package/dist/environment.js +24 -0
- package/dist/environment.mjs +2 -0
- package/dist/hooks.d.mts +1179 -0
- package/dist/hooks.d.ts +1179 -0
- package/dist/hooks.js +977 -0
- package/dist/hooks.mjs +958 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2727 -0
- package/dist/index.mjs +2814 -0
- package/dist/provider.d.mts +1 -0
- package/dist/provider.d.ts +1 -0
- package/dist/provider.js +24 -0
- package/dist/provider.mjs +2 -0
- package/dist/services.d.mts +1 -0
- package/dist/services.d.ts +1 -0
- package/dist/services.js +24 -0
- package/dist/services.mjs +2 -0
- package/dist/types.d.mts +36 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.js +24 -0
- package/dist/types.mjs +2 -0
- package/dist/utils.d.mts +21 -0
- package/dist/utils.d.ts +21 -0
- package/dist/utils.js +140 -0
- package/dist/utils.mjs +104 -0
- package/dist/widget.d.mts +332 -0
- package/dist/widget.d.ts +332 -0
- package/dist/widget.js +2103 -0
- package/dist/widget.mjs +2164 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/provider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/provider';
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/provider.ts
|
|
18
|
+
var provider_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(provider_exports);
|
|
20
|
+
__reExport(provider_exports, require("@fctc/interface-logic/provider"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@fctc/interface-logic/provider")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/services';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/services';
|
package/dist/services.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/services.ts
|
|
18
|
+
var services_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(services_exports);
|
|
20
|
+
__reExport(services_exports, require("@fctc/interface-logic/services"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@fctc/interface-logic/services")
|
|
24
|
+
});
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/types';
|
|
2
|
+
|
|
3
|
+
interface ValuePropsType {
|
|
4
|
+
id: number | string;
|
|
5
|
+
display_name: number | string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
interface IInputFieldProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
readonly?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
defaultValue?: string | number | ValuePropsType | any;
|
|
15
|
+
invisible?: boolean;
|
|
16
|
+
methods?: any;
|
|
17
|
+
onChange?: (name: string, value: any) => void;
|
|
18
|
+
onBlur?: Function;
|
|
19
|
+
onRefetch?: Function;
|
|
20
|
+
isForm?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
value?: string | number | ValuePropsType | null | Record<any, any> | any;
|
|
23
|
+
string?: string;
|
|
24
|
+
isEditTable?: boolean;
|
|
25
|
+
formValues?: any;
|
|
26
|
+
model?: any;
|
|
27
|
+
relation?: string;
|
|
28
|
+
domain?: any;
|
|
29
|
+
idForm?: boolean;
|
|
30
|
+
widget?: string;
|
|
31
|
+
aid?: string | number;
|
|
32
|
+
context?: string | Object;
|
|
33
|
+
filename?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type { IInputFieldProps, ValuePropsType };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/types';
|
|
2
|
+
|
|
3
|
+
interface ValuePropsType {
|
|
4
|
+
id: number | string;
|
|
5
|
+
display_name: number | string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
interface IInputFieldProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
readonly?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
defaultValue?: string | number | ValuePropsType | any;
|
|
15
|
+
invisible?: boolean;
|
|
16
|
+
methods?: any;
|
|
17
|
+
onChange?: (name: string, value: any) => void;
|
|
18
|
+
onBlur?: Function;
|
|
19
|
+
onRefetch?: Function;
|
|
20
|
+
isForm?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
value?: string | number | ValuePropsType | null | Record<any, any> | any;
|
|
23
|
+
string?: string;
|
|
24
|
+
isEditTable?: boolean;
|
|
25
|
+
formValues?: any;
|
|
26
|
+
model?: any;
|
|
27
|
+
relation?: string;
|
|
28
|
+
domain?: any;
|
|
29
|
+
idForm?: boolean;
|
|
30
|
+
widget?: string;
|
|
31
|
+
aid?: string | number;
|
|
32
|
+
context?: string | Object;
|
|
33
|
+
filename?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type { IInputFieldProps, ValuePropsType };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/types.ts
|
|
18
|
+
var types_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(types_exports);
|
|
20
|
+
__reExport(types_exports, require("@fctc/interface-logic/types"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@fctc/interface-logic/types")
|
|
24
|
+
});
|
package/dist/types.mjs
ADDED
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/utils';
|
|
2
|
+
|
|
3
|
+
declare const languages: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
|
|
8
|
+
declare const countSum: (data: any[], field: string) => number;
|
|
9
|
+
declare const isObjectEmpty: (obj: object) => boolean;
|
|
10
|
+
declare function mergeButtons(fields: any): any;
|
|
11
|
+
declare const STORAGES: {
|
|
12
|
+
readonly TOKEN: "accessToken";
|
|
13
|
+
readonly USER_INFO: "USER_INFO";
|
|
14
|
+
};
|
|
15
|
+
type UseStateHook<T> = [[boolean, T | null], (value: T | null) => void];
|
|
16
|
+
type StorageKey = keyof typeof STORAGES;
|
|
17
|
+
declare function setStorageItemAsync(key: StorageKey, value: string | null): Promise<void>;
|
|
18
|
+
declare function useStorageState(key: StorageKey): UseStateHook<string>;
|
|
19
|
+
declare const guessTypeFromUrl: (url: string) => any;
|
|
20
|
+
|
|
21
|
+
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/utils';
|
|
2
|
+
|
|
3
|
+
declare const languages: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
|
|
8
|
+
declare const countSum: (data: any[], field: string) => number;
|
|
9
|
+
declare const isObjectEmpty: (obj: object) => boolean;
|
|
10
|
+
declare function mergeButtons(fields: any): any;
|
|
11
|
+
declare const STORAGES: {
|
|
12
|
+
readonly TOKEN: "accessToken";
|
|
13
|
+
readonly USER_INFO: "USER_INFO";
|
|
14
|
+
};
|
|
15
|
+
type UseStateHook<T> = [[boolean, T | null], (value: T | null) => void];
|
|
16
|
+
type StorageKey = keyof typeof STORAGES;
|
|
17
|
+
declare function setStorageItemAsync(key: StorageKey, value: string | null): Promise<void>;
|
|
18
|
+
declare function useStorageState(key: StorageKey): UseStateHook<string>;
|
|
19
|
+
declare const guessTypeFromUrl: (url: string) => any;
|
|
20
|
+
|
|
21
|
+
export { STORAGES, countSum, guessTypeFromUrl, isObjectEmpty, languages, mergeButtons, setStorageItemAsync, useStorageState };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/utils.ts
|
|
22
|
+
var utils_exports = {};
|
|
23
|
+
__export(utils_exports, {
|
|
24
|
+
STORAGES: () => STORAGES,
|
|
25
|
+
countSum: () => countSum,
|
|
26
|
+
guessTypeFromUrl: () => guessTypeFromUrl,
|
|
27
|
+
isObjectEmpty: () => isObjectEmpty,
|
|
28
|
+
languages: () => languages,
|
|
29
|
+
mergeButtons: () => mergeButtons,
|
|
30
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
31
|
+
useStorageState: () => useStorageState
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(utils_exports);
|
|
34
|
+
|
|
35
|
+
// src/utils/constants.ts
|
|
36
|
+
var languages = [
|
|
37
|
+
{ id: "vi_VN", name: "VIE" },
|
|
38
|
+
{ id: "en_US", name: "ENG" }
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// src/utils/function.ts
|
|
42
|
+
var import_react = require("react");
|
|
43
|
+
var countSum = (data, field) => {
|
|
44
|
+
if (!data || !field) return 0;
|
|
45
|
+
return data.reduce(
|
|
46
|
+
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
47
|
+
0
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
var isObjectEmpty = (obj) => {
|
|
51
|
+
return Object.keys(obj).length === 0;
|
|
52
|
+
};
|
|
53
|
+
function mergeButtons(fields) {
|
|
54
|
+
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
55
|
+
const others = fields?.filter((f) => f.type_co !== "button");
|
|
56
|
+
if (buttons?.length) {
|
|
57
|
+
others.push({
|
|
58
|
+
type_co: "buttons",
|
|
59
|
+
buttons
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return others;
|
|
63
|
+
}
|
|
64
|
+
var STORAGES = {
|
|
65
|
+
TOKEN: "accessToken",
|
|
66
|
+
USER_INFO: "USER_INFO"
|
|
67
|
+
};
|
|
68
|
+
function useAsyncState(initialValue = [true, null]) {
|
|
69
|
+
return (0, import_react.useReducer)(
|
|
70
|
+
(_state, action = null) => [false, action],
|
|
71
|
+
initialValue
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
async function setStorageItemAsync(key, value) {
|
|
75
|
+
try {
|
|
76
|
+
if (value === null) {
|
|
77
|
+
localStorage.removeItem(key);
|
|
78
|
+
} else {
|
|
79
|
+
localStorage.setItem(key, value);
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error("Local storage is unavailable:", e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function useStorageState(key) {
|
|
86
|
+
const [state, setState] = useAsyncState();
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
try {
|
|
89
|
+
const storedValue = localStorage.getItem(key);
|
|
90
|
+
setState(storedValue);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error("Local storage is unavailable:", e);
|
|
93
|
+
}
|
|
94
|
+
}, [key]);
|
|
95
|
+
const setValue = (0, import_react.useCallback)(
|
|
96
|
+
(value) => {
|
|
97
|
+
setState(value);
|
|
98
|
+
setStorageItemAsync(key, value);
|
|
99
|
+
},
|
|
100
|
+
[key]
|
|
101
|
+
);
|
|
102
|
+
return [state, setValue];
|
|
103
|
+
}
|
|
104
|
+
var guessTypeFromUrl = (url) => {
|
|
105
|
+
const ext = url.split(".").pop()?.toLowerCase();
|
|
106
|
+
if (!ext) return null;
|
|
107
|
+
const map = {
|
|
108
|
+
jpg: "image/jpeg",
|
|
109
|
+
jpeg: "image/jpeg",
|
|
110
|
+
png: "image/png",
|
|
111
|
+
webp: "image/webp",
|
|
112
|
+
gif: "image/gif",
|
|
113
|
+
svg: "image/svg+xml",
|
|
114
|
+
bmp: "image/bmp",
|
|
115
|
+
tiff: "image/tiff",
|
|
116
|
+
pdf: "application/pdf",
|
|
117
|
+
zip: "application/zip",
|
|
118
|
+
rar: "application/x-rar-compressed",
|
|
119
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
120
|
+
xls: "application/vnd.ms-excel",
|
|
121
|
+
mp4: "video/mp4",
|
|
122
|
+
mov: "video/quicktime"
|
|
123
|
+
};
|
|
124
|
+
return map[ext] || null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/utils.ts
|
|
128
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"), module.exports);
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
STORAGES,
|
|
132
|
+
countSum,
|
|
133
|
+
guessTypeFromUrl,
|
|
134
|
+
isObjectEmpty,
|
|
135
|
+
languages,
|
|
136
|
+
mergeButtons,
|
|
137
|
+
setStorageItemAsync,
|
|
138
|
+
useStorageState,
|
|
139
|
+
...require("@fctc/interface-logic/utils")
|
|
140
|
+
});
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/utils/constants.ts
|
|
2
|
+
var languages = [
|
|
3
|
+
{ id: "vi_VN", name: "VIE" },
|
|
4
|
+
{ id: "en_US", name: "ENG" }
|
|
5
|
+
];
|
|
6
|
+
|
|
7
|
+
// src/utils/function.ts
|
|
8
|
+
import { useCallback, useEffect, useReducer } from "react";
|
|
9
|
+
var countSum = (data, field) => {
|
|
10
|
+
if (!data || !field) return 0;
|
|
11
|
+
return data.reduce(
|
|
12
|
+
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
13
|
+
0
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
var isObjectEmpty = (obj) => {
|
|
17
|
+
return Object.keys(obj).length === 0;
|
|
18
|
+
};
|
|
19
|
+
function mergeButtons(fields) {
|
|
20
|
+
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
21
|
+
const others = fields?.filter((f) => f.type_co !== "button");
|
|
22
|
+
if (buttons?.length) {
|
|
23
|
+
others.push({
|
|
24
|
+
type_co: "buttons",
|
|
25
|
+
buttons
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return others;
|
|
29
|
+
}
|
|
30
|
+
var STORAGES = {
|
|
31
|
+
TOKEN: "accessToken",
|
|
32
|
+
USER_INFO: "USER_INFO"
|
|
33
|
+
};
|
|
34
|
+
function useAsyncState(initialValue = [true, null]) {
|
|
35
|
+
return useReducer(
|
|
36
|
+
(_state, action = null) => [false, action],
|
|
37
|
+
initialValue
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
async function setStorageItemAsync(key, value) {
|
|
41
|
+
try {
|
|
42
|
+
if (value === null) {
|
|
43
|
+
localStorage.removeItem(key);
|
|
44
|
+
} else {
|
|
45
|
+
localStorage.setItem(key, value);
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error("Local storage is unavailable:", e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function useStorageState(key) {
|
|
52
|
+
const [state, setState] = useAsyncState();
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
try {
|
|
55
|
+
const storedValue = localStorage.getItem(key);
|
|
56
|
+
setState(storedValue);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error("Local storage is unavailable:", e);
|
|
59
|
+
}
|
|
60
|
+
}, [key]);
|
|
61
|
+
const setValue = useCallback(
|
|
62
|
+
(value) => {
|
|
63
|
+
setState(value);
|
|
64
|
+
setStorageItemAsync(key, value);
|
|
65
|
+
},
|
|
66
|
+
[key]
|
|
67
|
+
);
|
|
68
|
+
return [state, setValue];
|
|
69
|
+
}
|
|
70
|
+
var guessTypeFromUrl = (url) => {
|
|
71
|
+
const ext = url.split(".").pop()?.toLowerCase();
|
|
72
|
+
if (!ext) return null;
|
|
73
|
+
const map = {
|
|
74
|
+
jpg: "image/jpeg",
|
|
75
|
+
jpeg: "image/jpeg",
|
|
76
|
+
png: "image/png",
|
|
77
|
+
webp: "image/webp",
|
|
78
|
+
gif: "image/gif",
|
|
79
|
+
svg: "image/svg+xml",
|
|
80
|
+
bmp: "image/bmp",
|
|
81
|
+
tiff: "image/tiff",
|
|
82
|
+
pdf: "application/pdf",
|
|
83
|
+
zip: "application/zip",
|
|
84
|
+
rar: "application/x-rar-compressed",
|
|
85
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
86
|
+
xls: "application/vnd.ms-excel",
|
|
87
|
+
mp4: "video/mp4",
|
|
88
|
+
mov: "video/quicktime"
|
|
89
|
+
};
|
|
90
|
+
return map[ext] || null;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/utils.ts
|
|
94
|
+
export * from "@fctc/interface-logic/utils";
|
|
95
|
+
export {
|
|
96
|
+
STORAGES,
|
|
97
|
+
countSum,
|
|
98
|
+
guessTypeFromUrl,
|
|
99
|
+
isObjectEmpty,
|
|
100
|
+
languages,
|
|
101
|
+
mergeButtons,
|
|
102
|
+
setStorageItemAsync,
|
|
103
|
+
useStorageState
|
|
104
|
+
};
|