@fctc/widget-logic 1.1.1 → 1.1.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/dist/action.mjs DELETED
@@ -1,122 +0,0 @@
1
- // src/action/use-archieve-row.ts
2
- import { useButton } from "@fctc/interface-logic";
3
- var useArchieveHandler = ({
4
- data,
5
- onSuccess,
6
- onError,
7
- onSettled
8
- }) => {
9
- const archieve = useButton();
10
- const handleDuplicateRecord = () => {
11
- archieve.mutate(
12
- {
13
- method: `action_${data.actionName}`,
14
- model: data.model,
15
- ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
16
- context: data.context
17
- },
18
- {
19
- onSuccess,
20
- onError,
21
- onSettled
22
- }
23
- );
24
- };
25
- return handleDuplicateRecord;
26
- };
27
-
28
- // src/action/use-duplicate-row.ts
29
- import { useDuplicateRecord } from "@fctc/interface-logic";
30
- var useDuplicateRowHandler = ({
31
- data,
32
- onSuccess,
33
- onError,
34
- onSettled
35
- }) => {
36
- const duplicateRecord = useDuplicateRecord();
37
- const handleDuplicateRecord = () => {
38
- duplicateRecord.mutate(
39
- {
40
- model: data.model,
41
- id: Array.isArray(data.ids) ? [...data.ids] : data.ids,
42
- context: data.context
43
- },
44
- {
45
- onSuccess,
46
- onError,
47
- onSettled
48
- }
49
- );
50
- };
51
- return handleDuplicateRecord;
52
- };
53
-
54
- // src/action/use-get-field-export.ts
55
- import { useGetFieldExport } from "@fctc/interface-logic";
56
- var useGetFieldExportHandler = ({
57
- data,
58
- onSuccess,
59
- onError,
60
- onSettled
61
- }) => {
62
- const fieldExport = useGetFieldExport();
63
- const handleGetFieldExport = () => {
64
- fieldExport.mutate(
65
- {
66
- context: data.context,
67
- ids: data.ids,
68
- model: data.model,
69
- isShow: data.isShow,
70
- fieldType: data.fieldType,
71
- importCompat: data.importCompat,
72
- name: data.name,
73
- parentField: data.parentField,
74
- parentName: data.parentName,
75
- prefix: data.prefix
76
- },
77
- {
78
- onSuccess,
79
- onError,
80
- onSettled
81
- }
82
- );
83
- };
84
- return handleGetFieldExport;
85
- };
86
-
87
- // src/action/use-export-excel.ts
88
- import { evalJSONDomain, useExportExcel } from "@fctc/interface-logic";
89
- var useExportExcelHandler = ({
90
- data,
91
- onSuccess,
92
- onError,
93
- onSettled
94
- }) => {
95
- const exportExcel = useExportExcel();
96
- const handleExport = () => {
97
- exportExcel.mutate(
98
- {
99
- model: data.model,
100
- ids: data?.ids,
101
- fields: data.fields,
102
- domain: evalJSONDomain(data.domain, data.context),
103
- importCompat: data?.importCompat,
104
- type: data.type,
105
- context: data.context,
106
- groupby: data?.groupby
107
- },
108
- {
109
- onSuccess,
110
- onError,
111
- onSettled
112
- }
113
- );
114
- };
115
- return handleExport;
116
- };
117
- export {
118
- useArchieveHandler,
119
- useDuplicateRowHandler,
120
- useExportExcelHandler,
121
- useGetFieldExportHandler
122
- };
package/dist/form.d.mts DELETED
@@ -1,42 +0,0 @@
1
- interface UseSaveFormProps$1 {
2
- data: {
3
- context: any;
4
- model: string;
5
- specification: any;
6
- ids: any;
7
- nameField?: any;
8
- object?: any;
9
- };
10
- onSuccess?: (res: any) => void;
11
- onError?: (err: any) => void;
12
- onSettled?: (err: any) => void;
13
- }
14
- declare const UseOnChangeFormHandler: ({ data, onSuccess, onError, onSettled, }: UseSaveFormProps$1) => Promise<any>;
15
-
16
- interface UseSaveFormProps {
17
- data: {
18
- context: any;
19
- model: string;
20
- specification?: any;
21
- ids: any;
22
- records: any;
23
- };
24
- onSuccess?: (res: any) => void;
25
- onError?: (err: any) => void;
26
- onSettled?: (err: any) => void;
27
- }
28
- declare const useSaveFormHandler: ({ data, onSuccess, onError, onSettled, }: UseSaveFormProps) => () => void;
29
-
30
- interface UseDeleteProps {
31
- data: {
32
- model: string;
33
- ids: number[];
34
- context: any;
35
- };
36
- onSuccess?: (res: any) => void;
37
- onError?: (err: any) => void;
38
- onSettled?: (err: any) => void;
39
- }
40
- declare const useRemoveRowHandler: ({ data, onSuccess, onError, onSettled, }: UseDeleteProps) => () => void;
41
-
42
- export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler };
package/dist/form.d.ts DELETED
@@ -1,42 +0,0 @@
1
- interface UseSaveFormProps$1 {
2
- data: {
3
- context: any;
4
- model: string;
5
- specification: any;
6
- ids: any;
7
- nameField?: any;
8
- object?: any;
9
- };
10
- onSuccess?: (res: any) => void;
11
- onError?: (err: any) => void;
12
- onSettled?: (err: any) => void;
13
- }
14
- declare const UseOnChangeFormHandler: ({ data, onSuccess, onError, onSettled, }: UseSaveFormProps$1) => Promise<any>;
15
-
16
- interface UseSaveFormProps {
17
- data: {
18
- context: any;
19
- model: string;
20
- specification?: any;
21
- ids: any;
22
- records: any;
23
- };
24
- onSuccess?: (res: any) => void;
25
- onError?: (err: any) => void;
26
- onSettled?: (err: any) => void;
27
- }
28
- declare const useSaveFormHandler: ({ data, onSuccess, onError, onSettled, }: UseSaveFormProps) => () => void;
29
-
30
- interface UseDeleteProps {
31
- data: {
32
- model: string;
33
- ids: number[];
34
- context: any;
35
- };
36
- onSuccess?: (res: any) => void;
37
- onError?: (err: any) => void;
38
- onSettled?: (err: any) => void;
39
- }
40
- declare const useRemoveRowHandler: ({ data, onSuccess, onError, onSettled, }: UseDeleteProps) => () => void;
41
-
42
- export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler };
package/dist/form.js DELETED
@@ -1,121 +0,0 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/form.ts
21
- var form_exports = {};
22
- __export(form_exports, {
23
- UseOnChangeFormHandler: () => UseOnChangeFormHandler,
24
- useRemoveRowHandler: () => useRemoveRowHandler,
25
- useSaveFormHandler: () => useSaveFormHandler
26
- });
27
- module.exports = __toCommonJS(form_exports);
28
-
29
- // src/widget/form/use-on-change-form.ts
30
- var import_interface_logic = require("@fctc/interface-logic");
31
- var UseOnChangeFormHandler = ({
32
- data,
33
- onSuccess,
34
- onError,
35
- onSettled
36
- }) => {
37
- const fetchOnchange = (0, import_interface_logic.useOnChangeForm)();
38
- return new Promise((resolve, reject) => {
39
- fetchOnchange.mutate(
40
- {
41
- ids: data.ids ? data.ids : [],
42
- model: data.model,
43
- specification: data.specification,
44
- context: data.context,
45
- object: data.object,
46
- fieldChange: data.nameField
47
- },
48
- {
49
- onSuccess: (res) => {
50
- onSuccess?.(res);
51
- resolve(res);
52
- },
53
- onError: (err) => {
54
- onError?.(err);
55
- reject(err);
56
- },
57
- onSettled
58
- }
59
- );
60
- });
61
- };
62
-
63
- // src/widget/form/use-save-form.ts
64
- var import_interface_logic2 = require("@fctc/interface-logic");
65
- var useSaveFormHandler = ({
66
- data,
67
- onSuccess,
68
- onError,
69
- onSettled
70
- }) => {
71
- const fetchSave = (0, import_interface_logic2.useSave)();
72
- const handleSaveForm = () => {
73
- fetchSave.mutate(
74
- {
75
- ids: data.ids ? [data.ids] : [],
76
- model: data.model,
77
- data: data.records,
78
- specification: data.specification,
79
- context: data.context
80
- },
81
- {
82
- onSuccess,
83
- onError,
84
- onSettled
85
- }
86
- );
87
- };
88
- return handleSaveForm;
89
- };
90
-
91
- // src/widget/form/use-remove-row.ts
92
- var import_interface_logic3 = require("@fctc/interface-logic");
93
- var useRemoveRowHandler = ({
94
- data,
95
- onSuccess,
96
- onError,
97
- onSettled
98
- }) => {
99
- const remove = (0, import_interface_logic3.useRemoveRow)();
100
- const handleRemoveRow = () => {
101
- remove.mutate(
102
- {
103
- model: data.model,
104
- ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
105
- context: data.context
106
- },
107
- {
108
- onSuccess,
109
- onError,
110
- onSettled
111
- }
112
- );
113
- };
114
- return handleRemoveRow;
115
- };
116
- // Annotate the CommonJS export names for ESM import in node:
117
- 0 && (module.exports = {
118
- UseOnChangeFormHandler,
119
- useRemoveRowHandler,
120
- useSaveFormHandler
121
- });
package/dist/form.mjs DELETED
@@ -1,92 +0,0 @@
1
- // src/widget/form/use-on-change-form.ts
2
- import { useOnChangeForm } from "@fctc/interface-logic";
3
- var UseOnChangeFormHandler = ({
4
- data,
5
- onSuccess,
6
- onError,
7
- onSettled
8
- }) => {
9
- const fetchOnchange = useOnChangeForm();
10
- return new Promise((resolve, reject) => {
11
- fetchOnchange.mutate(
12
- {
13
- ids: data.ids ? data.ids : [],
14
- model: data.model,
15
- specification: data.specification,
16
- context: data.context,
17
- object: data.object,
18
- fieldChange: data.nameField
19
- },
20
- {
21
- onSuccess: (res) => {
22
- onSuccess?.(res);
23
- resolve(res);
24
- },
25
- onError: (err) => {
26
- onError?.(err);
27
- reject(err);
28
- },
29
- onSettled
30
- }
31
- );
32
- });
33
- };
34
-
35
- // src/widget/form/use-save-form.ts
36
- import { useSave } from "@fctc/interface-logic";
37
- var useSaveFormHandler = ({
38
- data,
39
- onSuccess,
40
- onError,
41
- onSettled
42
- }) => {
43
- const fetchSave = useSave();
44
- const handleSaveForm = () => {
45
- fetchSave.mutate(
46
- {
47
- ids: data.ids ? [data.ids] : [],
48
- model: data.model,
49
- data: data.records,
50
- specification: data.specification,
51
- context: data.context
52
- },
53
- {
54
- onSuccess,
55
- onError,
56
- onSettled
57
- }
58
- );
59
- };
60
- return handleSaveForm;
61
- };
62
-
63
- // src/widget/form/use-remove-row.ts
64
- import { useRemoveRow } from "@fctc/interface-logic";
65
- var useRemoveRowHandler = ({
66
- data,
67
- onSuccess,
68
- onError,
69
- onSettled
70
- }) => {
71
- const remove = useRemoveRow();
72
- const handleRemoveRow = () => {
73
- remove.mutate(
74
- {
75
- model: data.model,
76
- ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
77
- context: data.context
78
- },
79
- {
80
- onSuccess,
81
- onError,
82
- onSettled
83
- }
84
- );
85
- };
86
- return handleRemoveRow;
87
- };
88
- export {
89
- UseOnChangeFormHandler,
90
- useRemoveRowHandler,
91
- useSaveFormHandler
92
- };
package/dist/table.d.mts DELETED
@@ -1,22 +0,0 @@
1
- interface UseTableProps {
2
- data: {
3
- fields: any[];
4
- records: any[];
5
- dataModel: {
6
- [fieldName: string]: {
7
- string?: string;
8
- [key: string]: any;
9
- };
10
- };
11
- context: any;
12
- typeTable?: 'list' | 'group' | 'calendar';
13
- };
14
- }
15
- declare const useTableHandler: ({ data }: UseTableProps) => {
16
- rows: any[];
17
- columns: any;
18
- onToggleColumnOptional: (item: any) => void;
19
- typeTable: "list" | "group" | "calendar" | undefined;
20
- };
21
-
22
- export { useTableHandler };
package/dist/table.d.ts DELETED
@@ -1,22 +0,0 @@
1
- interface UseTableProps {
2
- data: {
3
- fields: any[];
4
- records: any[];
5
- dataModel: {
6
- [fieldName: string]: {
7
- string?: string;
8
- [key: string]: any;
9
- };
10
- };
11
- context: any;
12
- typeTable?: 'list' | 'group' | 'calendar';
13
- };
14
- }
15
- declare const useTableHandler: ({ data }: UseTableProps) => {
16
- rows: any[];
17
- columns: any;
18
- onToggleColumnOptional: (item: any) => void;
19
- typeTable: "list" | "group" | "calendar" | undefined;
20
- };
21
-
22
- export { useTableHandler };
package/dist/table.js DELETED
@@ -1,118 +0,0 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/table.ts
21
- var table_exports = {};
22
- __export(table_exports, {
23
- useTableHandler: () => useTableHandler
24
- });
25
- module.exports = __toCommonJS(table_exports);
26
-
27
- // src/widget/table/use-table.ts
28
- var import_interface_logic = require("@fctc/interface-logic");
29
- var import_react = require("react");
30
- function mergeButtons(fields) {
31
- const buttons = fields?.filter((f) => f.type_co === "button");
32
- const others = fields?.filter((f) => f.type_co !== "button");
33
- if (buttons?.length) {
34
- others.push({
35
- type_co: "buttons",
36
- buttons
37
- });
38
- }
39
- return others;
40
- }
41
- var useTableHandler = ({ data }) => {
42
- const [rows, setRows] = (0, import_react.useState)(data.records || []);
43
- const [columns, setColumns] = (0, import_react.useState)([]);
44
- const dataModelFields = data.fields?.map((field) => {
45
- return {
46
- ...data.dataModel?.[field?.name],
47
- ...field,
48
- string: field?.string || data.dataModel?.[field?.name]?.string
49
- };
50
- });
51
- const mergeFields = mergeButtons(dataModelFields);
52
- const transformData = (dataList) => {
53
- if (!dataList) return;
54
- return dataList?.map((item) => {
55
- const transformedItem = { ...item };
56
- Object.keys(item).forEach((field) => {
57
- if (field !== "__domain") {
58
- if (item[field] && typeof item[field] === "object" && item[field].display_name) {
59
- transformedItem[field] = item[field];
60
- } else if (Array.isArray(item[field]) && item[field].length > 0) {
61
- if (data.typeTable === "group" && item[field]?.length === 2 && typeof item[field]?.[1] === "string") {
62
- transformedItem["string"] = item[field]?.[1];
63
- }
64
- transformedItem[field] = item[field];
65
- }
66
- }
67
- });
68
- return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
69
- });
70
- };
71
- (0, import_react.useEffect)(() => {
72
- setRows(transformData(data.records || null));
73
- }, [data.records]);
74
- const handleGetColumns = () => {
75
- let cols = [];
76
- try {
77
- cols = mergeFields?.filter((item) => {
78
- return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_interface_logic.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_interface_logic.domainHelper.matchDomains(data.context, item?.invisible) : false);
79
- })?.map((field) => {
80
- return {
81
- name: field?.name,
82
- optional: field?.optional,
83
- title: field?.type_co === "button" ? "" : field?.string,
84
- field: { ...field }
85
- };
86
- });
87
- } catch (error) {
88
- console.error("Error in useTable:", error);
89
- }
90
- return cols;
91
- };
92
- (0, import_react.useEffect)(() => {
93
- const columns2 = handleGetColumns();
94
- setColumns(columns2);
95
- }, [data.records]);
96
- const onToggleColumnOptional = (item) => {
97
- const tempColumn = [...columns]?.map((val) => {
98
- if (item?.name === val?.name) {
99
- return {
100
- ...val,
101
- optional: item?.optional === "show" ? "hide" : "show"
102
- };
103
- }
104
- return val;
105
- });
106
- setColumns(tempColumn);
107
- };
108
- return {
109
- rows,
110
- columns,
111
- onToggleColumnOptional,
112
- typeTable: data.typeTable
113
- };
114
- };
115
- // Annotate the CommonJS export names for ESM import in node:
116
- 0 && (module.exports = {
117
- useTableHandler
118
- });
package/dist/table.mjs DELETED
@@ -1,91 +0,0 @@
1
- // src/widget/table/use-table.ts
2
- import { domainHelper } from "@fctc/interface-logic";
3
- import { useEffect, useState } from "react";
4
- function mergeButtons(fields) {
5
- const buttons = fields?.filter((f) => f.type_co === "button");
6
- const others = fields?.filter((f) => f.type_co !== "button");
7
- if (buttons?.length) {
8
- others.push({
9
- type_co: "buttons",
10
- buttons
11
- });
12
- }
13
- return others;
14
- }
15
- var useTableHandler = ({ data }) => {
16
- const [rows, setRows] = useState(data.records || []);
17
- const [columns, setColumns] = useState([]);
18
- const dataModelFields = data.fields?.map((field) => {
19
- return {
20
- ...data.dataModel?.[field?.name],
21
- ...field,
22
- string: field?.string || data.dataModel?.[field?.name]?.string
23
- };
24
- });
25
- const mergeFields = mergeButtons(dataModelFields);
26
- const transformData = (dataList) => {
27
- if (!dataList) return;
28
- return dataList?.map((item) => {
29
- const transformedItem = { ...item };
30
- Object.keys(item).forEach((field) => {
31
- if (field !== "__domain") {
32
- if (item[field] && typeof item[field] === "object" && item[field].display_name) {
33
- transformedItem[field] = item[field];
34
- } else if (Array.isArray(item[field]) && item[field].length > 0) {
35
- if (data.typeTable === "group" && item[field]?.length === 2 && typeof item[field]?.[1] === "string") {
36
- transformedItem["string"] = item[field]?.[1];
37
- }
38
- transformedItem[field] = item[field];
39
- }
40
- }
41
- });
42
- return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
43
- });
44
- };
45
- useEffect(() => {
46
- setRows(transformData(data.records || null));
47
- }, [data.records]);
48
- const handleGetColumns = () => {
49
- let cols = [];
50
- try {
51
- cols = mergeFields?.filter((item) => {
52
- return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? domainHelper.matchDomains(data.context, item?.invisible) : false);
53
- })?.map((field) => {
54
- return {
55
- name: field?.name,
56
- optional: field?.optional,
57
- title: field?.type_co === "button" ? "" : field?.string,
58
- field: { ...field }
59
- };
60
- });
61
- } catch (error) {
62
- console.error("Error in useTable:", error);
63
- }
64
- return cols;
65
- };
66
- useEffect(() => {
67
- const columns2 = handleGetColumns();
68
- setColumns(columns2);
69
- }, [data.records]);
70
- const onToggleColumnOptional = (item) => {
71
- const tempColumn = [...columns]?.map((val) => {
72
- if (item?.name === val?.name) {
73
- return {
74
- ...val,
75
- optional: item?.optional === "show" ? "hide" : "show"
76
- };
77
- }
78
- return val;
79
- });
80
- setColumns(tempColumn);
81
- };
82
- return {
83
- rows,
84
- columns,
85
- onToggleColumnOptional,
86
- typeTable: data.typeTable
87
- };
88
- };
89
- export {
90
- useTableHandler
91
- };