@fctc/widget-logic 1.5.0 → 1.5.1
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 +6 -0
- package/dist/config.d.ts +6 -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 +969 -0
- package/dist/hooks.d.ts +969 -0
- package/dist/hooks.js +743 -0
- package/dist/hooks.mjs +717 -0
- package/dist/icons.d.mts +9 -0
- package/dist/icons.d.ts +9 -0
- package/dist/icons.js +139 -0
- package/dist/icons.mjs +110 -0
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +7233 -229
- package/dist/index.mjs +7320 -218
- 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/store.d.mts +1 -0
- package/dist/store.d.ts +1 -0
- package/dist/store.js +24 -0
- package/dist/store.mjs +2 -0
- package/dist/types.d.mts +31 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.js +24 -0
- package/dist/types.mjs +2 -0
- package/dist/utils.d.mts +38 -0
- package/dist/utils.d.ts +38 -0
- package/dist/utils.js +282 -0
- package/dist/utils.mjs +242 -0
- package/dist/widget.d.mts +299 -0
- package/dist/widget.d.ts +299 -0
- package/dist/widget.js +7079 -0
- package/dist/widget.mjs +7111 -0
- package/package.json +69 -23
- package/dist/action.d.mts +0 -68
- package/dist/action.d.ts +0 -68
- package/dist/action.js +0 -152
- package/dist/action.mjs +0 -122
- package/dist/common.d.mts +0 -13
- package/dist/common.d.ts +0 -13
- package/dist/common.js +0 -60
- package/dist/common.mjs +0 -33
- package/dist/form.d.mts +0 -42
- package/dist/form.d.ts +0 -42
- package/dist/form.js +0 -116
- package/dist/form.mjs +0 -87
- package/dist/table.d.mts +0 -22
- package/dist/table.d.ts +0 -22
- package/dist/table.js +0 -118
- package/dist/table.mjs +0 -91
|
@@ -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/store.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/store';
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/store';
|
package/dist/store.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/store.ts
|
|
18
|
+
var store_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(store_exports);
|
|
20
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@fctc/interface-logic/store")
|
|
24
|
+
});
|
package/dist/store.mjs
ADDED
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
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?: string;
|
|
27
|
+
relation?: string;
|
|
28
|
+
domain?: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type { IInputFieldProps, ValuePropsType };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
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?: string;
|
|
27
|
+
relation?: string;
|
|
28
|
+
domain?: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
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,38 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/utils';
|
|
2
|
+
|
|
3
|
+
declare const languages: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
declare const API_PRESCHOOL_URL: {
|
|
8
|
+
baseURL: string;
|
|
9
|
+
};
|
|
10
|
+
declare const API_APP_URL: {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
c2: string;
|
|
13
|
+
apiV2: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const countSum: (data: any[], field: string) => number;
|
|
17
|
+
declare function mergeButtons(fields: any): any;
|
|
18
|
+
declare function useGetRowIds(tableRef: React.RefObject<HTMLTableElement | null>): {
|
|
19
|
+
rowIds: string[];
|
|
20
|
+
refresh: () => void;
|
|
21
|
+
};
|
|
22
|
+
declare const getDateRange: (currentDate: any, unit: string) => string[][];
|
|
23
|
+
declare const convertFieldsToArray: (fields: any[] | undefined | null) => any[];
|
|
24
|
+
declare function combineContexts(contexts: ({
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
} | undefined)[]): {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | undefined;
|
|
29
|
+
declare const STORAGES: {
|
|
30
|
+
readonly TOKEN: "accessToken";
|
|
31
|
+
readonly USER_INFO: "USER_INFO";
|
|
32
|
+
};
|
|
33
|
+
type UseStateHook<T> = [[boolean, T | null], (value: T | null) => void];
|
|
34
|
+
type StorageKey = keyof typeof STORAGES;
|
|
35
|
+
declare function setStorageItemAsync(key: StorageKey, value: string | null): Promise<void>;
|
|
36
|
+
declare function useStorageState(key: StorageKey): UseStateHook<string>;
|
|
37
|
+
|
|
38
|
+
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useStorageState };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from '@fctc/interface-logic/utils';
|
|
2
|
+
|
|
3
|
+
declare const languages: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
declare const API_PRESCHOOL_URL: {
|
|
8
|
+
baseURL: string;
|
|
9
|
+
};
|
|
10
|
+
declare const API_APP_URL: {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
c2: string;
|
|
13
|
+
apiV2: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const countSum: (data: any[], field: string) => number;
|
|
17
|
+
declare function mergeButtons(fields: any): any;
|
|
18
|
+
declare function useGetRowIds(tableRef: React.RefObject<HTMLTableElement | null>): {
|
|
19
|
+
rowIds: string[];
|
|
20
|
+
refresh: () => void;
|
|
21
|
+
};
|
|
22
|
+
declare const getDateRange: (currentDate: any, unit: string) => string[][];
|
|
23
|
+
declare const convertFieldsToArray: (fields: any[] | undefined | null) => any[];
|
|
24
|
+
declare function combineContexts(contexts: ({
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
} | undefined)[]): {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | undefined;
|
|
29
|
+
declare const STORAGES: {
|
|
30
|
+
readonly TOKEN: "accessToken";
|
|
31
|
+
readonly USER_INFO: "USER_INFO";
|
|
32
|
+
};
|
|
33
|
+
type UseStateHook<T> = [[boolean, T | null], (value: T | null) => void];
|
|
34
|
+
type StorageKey = keyof typeof STORAGES;
|
|
35
|
+
declare function setStorageItemAsync(key: StorageKey, value: string | null): Promise<void>;
|
|
36
|
+
declare function useStorageState(key: StorageKey): UseStateHook<string>;
|
|
37
|
+
|
|
38
|
+
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useStorageState };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
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
|
+
API_APP_URL: () => API_APP_URL,
|
|
25
|
+
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
26
|
+
STORAGES: () => STORAGES,
|
|
27
|
+
combineContexts: () => combineContexts,
|
|
28
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
29
|
+
countSum: () => countSum,
|
|
30
|
+
getDateRange: () => getDateRange,
|
|
31
|
+
languages: () => languages,
|
|
32
|
+
mergeButtons: () => mergeButtons,
|
|
33
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
34
|
+
useGetRowIds: () => useGetRowIds,
|
|
35
|
+
useStorageState: () => useStorageState
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(utils_exports);
|
|
38
|
+
|
|
39
|
+
// src/utils/constants.ts
|
|
40
|
+
var languages = [
|
|
41
|
+
{ id: "vi_VN", name: "VIE" },
|
|
42
|
+
{ id: "en_US", name: "ENG" }
|
|
43
|
+
];
|
|
44
|
+
var API_PRESCHOOL_URL = {
|
|
45
|
+
baseURL: "https://preschool.vitrust.app"
|
|
46
|
+
};
|
|
47
|
+
var API_APP_URL = {
|
|
48
|
+
baseUrl: "https://api.vitrust.app",
|
|
49
|
+
c2: "https://api.vitrust.app/c2",
|
|
50
|
+
apiV2: "https://api.vitrust.app/c2/api/v2"
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/utils/function.ts
|
|
54
|
+
var import_react = require("react");
|
|
55
|
+
var countSum = (data, field) => {
|
|
56
|
+
if (!data || !field) return 0;
|
|
57
|
+
return data.reduce(
|
|
58
|
+
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
59
|
+
0
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
function mergeButtons(fields) {
|
|
63
|
+
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
64
|
+
const others = fields?.filter((f) => f.type_co !== "button");
|
|
65
|
+
if (buttons?.length) {
|
|
66
|
+
others.push({
|
|
67
|
+
type_co: "buttons",
|
|
68
|
+
buttons
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return others;
|
|
72
|
+
}
|
|
73
|
+
function isElementVisible(el) {
|
|
74
|
+
const style = window.getComputedStyle(el);
|
|
75
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
76
|
+
}
|
|
77
|
+
function arraysAreEqual(a, b) {
|
|
78
|
+
if (a.length !== b.length) return false;
|
|
79
|
+
const setA = new Set(a);
|
|
80
|
+
const setB = new Set(b);
|
|
81
|
+
if (setA.size !== setB.size) return false;
|
|
82
|
+
for (const val of setA) {
|
|
83
|
+
if (!setB.has(val)) return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
function useGetRowIds(tableRef) {
|
|
88
|
+
const [rowIds, setRowIds] = (0, import_react.useState)([]);
|
|
89
|
+
const lastRowIdsRef = (0, import_react.useRef)([]);
|
|
90
|
+
const updateVisibleRowIds = (0, import_react.useCallback)(() => {
|
|
91
|
+
const table = tableRef?.current;
|
|
92
|
+
if (!table) return;
|
|
93
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
94
|
+
const ids = [];
|
|
95
|
+
rows.forEach((row) => {
|
|
96
|
+
const el = row;
|
|
97
|
+
if (isElementVisible(el)) {
|
|
98
|
+
const id = el.getAttribute("data-row-id");
|
|
99
|
+
if (id) ids.push(id);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
103
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
104
|
+
lastRowIdsRef.current = uniqueIds;
|
|
105
|
+
setRowIds(uniqueIds);
|
|
106
|
+
}
|
|
107
|
+
}, [tableRef]);
|
|
108
|
+
(0, import_react.useEffect)(() => {
|
|
109
|
+
const table = tableRef?.current;
|
|
110
|
+
if (!table) return;
|
|
111
|
+
const observer = new MutationObserver(() => {
|
|
112
|
+
updateVisibleRowIds();
|
|
113
|
+
});
|
|
114
|
+
observer.observe(table, {
|
|
115
|
+
childList: true,
|
|
116
|
+
subtree: true,
|
|
117
|
+
attributes: true,
|
|
118
|
+
attributeFilter: ["style", "class"]
|
|
119
|
+
});
|
|
120
|
+
updateVisibleRowIds();
|
|
121
|
+
return () => {
|
|
122
|
+
observer.disconnect();
|
|
123
|
+
};
|
|
124
|
+
}, [updateVisibleRowIds, tableRef]);
|
|
125
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
126
|
+
}
|
|
127
|
+
var getDateRange = (currentDate, unit) => {
|
|
128
|
+
const date = new Date(currentDate);
|
|
129
|
+
let dateStart, dateEnd;
|
|
130
|
+
function formatDate(d) {
|
|
131
|
+
return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0") + " " + String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0") + ":" + String(d.getSeconds()).padStart(2, "0");
|
|
132
|
+
}
|
|
133
|
+
switch (unit) {
|
|
134
|
+
case "month":
|
|
135
|
+
dateStart = new Date(
|
|
136
|
+
date.getFullYear(),
|
|
137
|
+
date.getMonth() + 1,
|
|
138
|
+
date.getDate(),
|
|
139
|
+
23,
|
|
140
|
+
59,
|
|
141
|
+
59
|
|
142
|
+
);
|
|
143
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
144
|
+
dateEnd = new Date(date.getFullYear(), date.getMonth(), 0, 0, 0, 0);
|
|
145
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
146
|
+
break;
|
|
147
|
+
case "day":
|
|
148
|
+
dateStart = new Date(
|
|
149
|
+
date.getFullYear(),
|
|
150
|
+
date.getMonth(),
|
|
151
|
+
date.getDate(),
|
|
152
|
+
23,
|
|
153
|
+
59,
|
|
154
|
+
59
|
|
155
|
+
);
|
|
156
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
157
|
+
dateEnd = new Date(
|
|
158
|
+
date.getFullYear(),
|
|
159
|
+
date.getMonth(),
|
|
160
|
+
date.getDate(),
|
|
161
|
+
0,
|
|
162
|
+
0,
|
|
163
|
+
0
|
|
164
|
+
);
|
|
165
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
166
|
+
break;
|
|
167
|
+
case "week":
|
|
168
|
+
const dayOfWeek = date.getDay();
|
|
169
|
+
const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
170
|
+
const daysToSunday = dayOfWeek === 0 ? 0 : 7 - dayOfWeek;
|
|
171
|
+
dateStart = new Date(
|
|
172
|
+
date.getFullYear(),
|
|
173
|
+
date.getMonth(),
|
|
174
|
+
date.getDate() + daysToSunday,
|
|
175
|
+
23,
|
|
176
|
+
59,
|
|
177
|
+
59
|
|
178
|
+
);
|
|
179
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
180
|
+
dateEnd = new Date(
|
|
181
|
+
date.getFullYear(),
|
|
182
|
+
date.getMonth(),
|
|
183
|
+
date.getDate() + daysToMonday,
|
|
184
|
+
0,
|
|
185
|
+
0,
|
|
186
|
+
0
|
|
187
|
+
);
|
|
188
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
189
|
+
break;
|
|
190
|
+
case "year":
|
|
191
|
+
dateStart = new Date(date.getFullYear(), 11, 31, 23, 59, 59);
|
|
192
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
193
|
+
dateEnd = new Date(date.getFullYear() - 1, 11, 31, 0, 0, 0);
|
|
194
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
throw new Error(
|
|
198
|
+
"\u0110\u01A1n v\u1ECB kh\xF4ng h\u1EE3p l\u1EC7. Ch\u1EC9 ch\u1EA5p nh\u1EADn: week, day, month, year"
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return [
|
|
202
|
+
["date_start", "<=", formatDate(dateStart)],
|
|
203
|
+
["date_end", ">=", formatDate(dateEnd)]
|
|
204
|
+
];
|
|
205
|
+
};
|
|
206
|
+
var convertFieldsToArray = (fields) => {
|
|
207
|
+
const defaultFields = ["display_name", "date_start", "date_end"];
|
|
208
|
+
if (!fields || !Array.isArray(fields)) {
|
|
209
|
+
return defaultFields;
|
|
210
|
+
}
|
|
211
|
+
const inputFields = fields.filter((field) => field && field.type_co === "field").map((field) => field.name);
|
|
212
|
+
return [...defaultFields, ...inputFields];
|
|
213
|
+
};
|
|
214
|
+
function combineContexts(contexts) {
|
|
215
|
+
if (contexts.some((context) => !context)) {
|
|
216
|
+
return void 0;
|
|
217
|
+
} else {
|
|
218
|
+
const res = contexts.reduce((acc, context) => {
|
|
219
|
+
return { ...acc, ...context };
|
|
220
|
+
}, {});
|
|
221
|
+
return res;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
var STORAGES = {
|
|
225
|
+
TOKEN: "accessToken",
|
|
226
|
+
USER_INFO: "USER_INFO"
|
|
227
|
+
};
|
|
228
|
+
function useAsyncState(initialValue = [true, null]) {
|
|
229
|
+
return (0, import_react.useReducer)(
|
|
230
|
+
(_state, action = null) => [false, action],
|
|
231
|
+
initialValue
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
async function setStorageItemAsync(key, value) {
|
|
235
|
+
try {
|
|
236
|
+
if (value === null) {
|
|
237
|
+
localStorage.removeItem(key);
|
|
238
|
+
} else {
|
|
239
|
+
localStorage.setItem(key, value);
|
|
240
|
+
}
|
|
241
|
+
} catch (e) {
|
|
242
|
+
console.error("Local storage is unavailable:", e);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function useStorageState(key) {
|
|
246
|
+
const [state, setState] = useAsyncState();
|
|
247
|
+
(0, import_react.useEffect)(() => {
|
|
248
|
+
try {
|
|
249
|
+
const storedValue = localStorage.getItem(key);
|
|
250
|
+
setState(storedValue);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
console.error("Local storage is unavailable:", e);
|
|
253
|
+
}
|
|
254
|
+
}, [key]);
|
|
255
|
+
const setValue = (0, import_react.useCallback)(
|
|
256
|
+
(value) => {
|
|
257
|
+
setState(value);
|
|
258
|
+
setStorageItemAsync(key, value);
|
|
259
|
+
},
|
|
260
|
+
[key]
|
|
261
|
+
);
|
|
262
|
+
return [state, setValue];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/utils.ts
|
|
266
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"), module.exports);
|
|
267
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
268
|
+
0 && (module.exports = {
|
|
269
|
+
API_APP_URL,
|
|
270
|
+
API_PRESCHOOL_URL,
|
|
271
|
+
STORAGES,
|
|
272
|
+
combineContexts,
|
|
273
|
+
convertFieldsToArray,
|
|
274
|
+
countSum,
|
|
275
|
+
getDateRange,
|
|
276
|
+
languages,
|
|
277
|
+
mergeButtons,
|
|
278
|
+
setStorageItemAsync,
|
|
279
|
+
useGetRowIds,
|
|
280
|
+
useStorageState,
|
|
281
|
+
...require("@fctc/interface-logic/utils")
|
|
282
|
+
});
|