@fctc/widget-logic 1.0.1 → 1.0.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.d.mts +60 -0
- package/dist/action.d.ts +60 -0
- package/dist/action.js +148 -0
- package/dist/action.mjs +118 -0
- package/dist/form.d.mts +38 -0
- package/dist/form.d.ts +38 -0
- package/dist/form.js +111 -0
- package/dist/form.mjs +82 -0
- package/dist/table.d.mts +8 -0
- package/dist/table.d.ts +8 -0
- package/dist/table.js +124 -0
- package/dist/table.mjs +97 -0
- package/package.json +17 -9
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
interface UseArchieveProps {
|
|
2
|
+
data: {
|
|
3
|
+
method: string;
|
|
4
|
+
model: string;
|
|
5
|
+
ids: number[];
|
|
6
|
+
actionName: 'archieve' | 'unarchive';
|
|
7
|
+
};
|
|
8
|
+
onSuccess?: (res: any) => void;
|
|
9
|
+
onError?: (err: any) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const useArchieveHandler: ({ data, onSuccess, onError, }: UseArchieveProps) => () => void;
|
|
12
|
+
|
|
13
|
+
interface UseDuplicateRowProps {
|
|
14
|
+
data: {
|
|
15
|
+
model: string;
|
|
16
|
+
ids: any;
|
|
17
|
+
};
|
|
18
|
+
onSuccess?: (res: any) => void;
|
|
19
|
+
onError?: (err: any) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const useDuplicateRowHandler: ({ data, onSuccess, onError, }: UseDuplicateRowProps) => () => void;
|
|
22
|
+
|
|
23
|
+
interface UseGetFieldExportProps {
|
|
24
|
+
data: {
|
|
25
|
+
ids: number[];
|
|
26
|
+
model: string;
|
|
27
|
+
isShow?: boolean;
|
|
28
|
+
fieldType?: any;
|
|
29
|
+
importCompat?: boolean;
|
|
30
|
+
name?: string;
|
|
31
|
+
parentField?: any;
|
|
32
|
+
parentName?: string;
|
|
33
|
+
prefix?: any;
|
|
34
|
+
};
|
|
35
|
+
onSuccess?: (res: any) => void;
|
|
36
|
+
onError?: (err: any) => void;
|
|
37
|
+
}
|
|
38
|
+
declare const useGetFieldExportHandler: ({ data, onSuccess, onError, }: UseGetFieldExportProps) => () => void;
|
|
39
|
+
|
|
40
|
+
interface UseExportExcelProps {
|
|
41
|
+
data: {
|
|
42
|
+
model: string;
|
|
43
|
+
fields: {
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
domain: any;
|
|
49
|
+
title?: string;
|
|
50
|
+
ids?: number[];
|
|
51
|
+
groupby?: any;
|
|
52
|
+
importCompat?: boolean;
|
|
53
|
+
type?: 'xlsx' | 'csv';
|
|
54
|
+
};
|
|
55
|
+
onSuccess?: (res: any) => void;
|
|
56
|
+
onError?: (err: any) => void;
|
|
57
|
+
}
|
|
58
|
+
declare const useExportExcelHandler: ({ data, onSuccess, onError, }: UseExportExcelProps) => () => void;
|
|
59
|
+
|
|
60
|
+
export { useArchieveHandler, useDuplicateRowHandler, useExportExcelHandler, useGetFieldExportHandler };
|
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
interface UseArchieveProps {
|
|
2
|
+
data: {
|
|
3
|
+
method: string;
|
|
4
|
+
model: string;
|
|
5
|
+
ids: number[];
|
|
6
|
+
actionName: 'archieve' | 'unarchive';
|
|
7
|
+
};
|
|
8
|
+
onSuccess?: (res: any) => void;
|
|
9
|
+
onError?: (err: any) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const useArchieveHandler: ({ data, onSuccess, onError, }: UseArchieveProps) => () => void;
|
|
12
|
+
|
|
13
|
+
interface UseDuplicateRowProps {
|
|
14
|
+
data: {
|
|
15
|
+
model: string;
|
|
16
|
+
ids: any;
|
|
17
|
+
};
|
|
18
|
+
onSuccess?: (res: any) => void;
|
|
19
|
+
onError?: (err: any) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const useDuplicateRowHandler: ({ data, onSuccess, onError, }: UseDuplicateRowProps) => () => void;
|
|
22
|
+
|
|
23
|
+
interface UseGetFieldExportProps {
|
|
24
|
+
data: {
|
|
25
|
+
ids: number[];
|
|
26
|
+
model: string;
|
|
27
|
+
isShow?: boolean;
|
|
28
|
+
fieldType?: any;
|
|
29
|
+
importCompat?: boolean;
|
|
30
|
+
name?: string;
|
|
31
|
+
parentField?: any;
|
|
32
|
+
parentName?: string;
|
|
33
|
+
prefix?: any;
|
|
34
|
+
};
|
|
35
|
+
onSuccess?: (res: any) => void;
|
|
36
|
+
onError?: (err: any) => void;
|
|
37
|
+
}
|
|
38
|
+
declare const useGetFieldExportHandler: ({ data, onSuccess, onError, }: UseGetFieldExportProps) => () => void;
|
|
39
|
+
|
|
40
|
+
interface UseExportExcelProps {
|
|
41
|
+
data: {
|
|
42
|
+
model: string;
|
|
43
|
+
fields: {
|
|
44
|
+
name: string;
|
|
45
|
+
label: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
domain: any;
|
|
49
|
+
title?: string;
|
|
50
|
+
ids?: number[];
|
|
51
|
+
groupby?: any;
|
|
52
|
+
importCompat?: boolean;
|
|
53
|
+
type?: 'xlsx' | 'csv';
|
|
54
|
+
};
|
|
55
|
+
onSuccess?: (res: any) => void;
|
|
56
|
+
onError?: (err: any) => void;
|
|
57
|
+
}
|
|
58
|
+
declare const useExportExcelHandler: ({ data, onSuccess, onError, }: UseExportExcelProps) => () => void;
|
|
59
|
+
|
|
60
|
+
export { useArchieveHandler, useDuplicateRowHandler, useExportExcelHandler, useGetFieldExportHandler };
|
package/dist/action.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
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/action.ts
|
|
21
|
+
var action_exports = {};
|
|
22
|
+
__export(action_exports, {
|
|
23
|
+
useArchieveHandler: () => useArchieveHandler,
|
|
24
|
+
useDuplicateRowHandler: () => useDuplicateRowHandler,
|
|
25
|
+
useExportExcelHandler: () => useExportExcelHandler,
|
|
26
|
+
useGetFieldExportHandler: () => useGetFieldExportHandler
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(action_exports);
|
|
29
|
+
|
|
30
|
+
// src/action/use-archieve-row.tsx
|
|
31
|
+
var import_interface_logic = require("@fctc/interface-logic");
|
|
32
|
+
var useArchieveHandler = ({
|
|
33
|
+
data,
|
|
34
|
+
onSuccess,
|
|
35
|
+
onError
|
|
36
|
+
}) => {
|
|
37
|
+
const archieve = (0, import_interface_logic.useButton)();
|
|
38
|
+
const env = (0, import_interface_logic.getEnv)();
|
|
39
|
+
const handleDuplicateRecord = () => {
|
|
40
|
+
archieve.mutate(
|
|
41
|
+
{
|
|
42
|
+
method: `action_${data.actionName}`,
|
|
43
|
+
model: data.model,
|
|
44
|
+
ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
|
|
45
|
+
context: env.context
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
onSuccess,
|
|
49
|
+
onError
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
return handleDuplicateRecord;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/action/use-duplicate-row.tsx
|
|
57
|
+
var import_interface_logic2 = require("@fctc/interface-logic");
|
|
58
|
+
var useDuplicateRowHandler = ({
|
|
59
|
+
data,
|
|
60
|
+
onSuccess,
|
|
61
|
+
onError
|
|
62
|
+
}) => {
|
|
63
|
+
const duplicateRecord = (0, import_interface_logic2.useDuplicateRecord)();
|
|
64
|
+
const env = (0, import_interface_logic2.getEnv)();
|
|
65
|
+
const handleDuplicateRecord = () => {
|
|
66
|
+
duplicateRecord.mutate(
|
|
67
|
+
{
|
|
68
|
+
model: data.model,
|
|
69
|
+
id: Array.isArray(data.ids) ? [...data.ids] : data.ids,
|
|
70
|
+
context: env.context
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
onSuccess,
|
|
74
|
+
onError
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
return handleDuplicateRecord;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/action/use-get-field-export.tsx
|
|
82
|
+
var import_interface_logic3 = require("@fctc/interface-logic");
|
|
83
|
+
var useGetFieldExportHandler = ({
|
|
84
|
+
data,
|
|
85
|
+
onSuccess,
|
|
86
|
+
onError
|
|
87
|
+
}) => {
|
|
88
|
+
const fieldExport = (0, import_interface_logic3.useGetFieldExport)();
|
|
89
|
+
const env = (0, import_interface_logic3.getEnv)();
|
|
90
|
+
const handleGetFieldExport = () => {
|
|
91
|
+
fieldExport.mutate(
|
|
92
|
+
{
|
|
93
|
+
context: env.context,
|
|
94
|
+
ids: data.ids,
|
|
95
|
+
model: data.model,
|
|
96
|
+
isShow: data.isShow,
|
|
97
|
+
fieldType: data.fieldType,
|
|
98
|
+
importCompat: data.importCompat,
|
|
99
|
+
name: data.name,
|
|
100
|
+
parentField: data.parentField,
|
|
101
|
+
parentName: data.parentName,
|
|
102
|
+
prefix: data.prefix
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
onSuccess,
|
|
106
|
+
onError
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
return handleGetFieldExport;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/action/use-export-excel.tsx
|
|
114
|
+
var import_interface_logic4 = require("@fctc/interface-logic");
|
|
115
|
+
var useExportExcelHandler = ({
|
|
116
|
+
data,
|
|
117
|
+
onSuccess,
|
|
118
|
+
onError
|
|
119
|
+
}) => {
|
|
120
|
+
const exportExcel = (0, import_interface_logic4.useExportExcel)();
|
|
121
|
+
const env = (0, import_interface_logic4.getEnv)();
|
|
122
|
+
const handleExport = () => {
|
|
123
|
+
exportExcel.mutate(
|
|
124
|
+
{
|
|
125
|
+
model: data.model,
|
|
126
|
+
ids: data?.ids,
|
|
127
|
+
fields: data.fields,
|
|
128
|
+
domain: (0, import_interface_logic4.evalJSONDomain)(data.domain, env.context),
|
|
129
|
+
importCompat: data?.importCompat,
|
|
130
|
+
type: data.type,
|
|
131
|
+
context: env.context,
|
|
132
|
+
groupby: data?.groupby
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
onSuccess,
|
|
136
|
+
onError
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
return handleExport;
|
|
141
|
+
};
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
useArchieveHandler,
|
|
145
|
+
useDuplicateRowHandler,
|
|
146
|
+
useExportExcelHandler,
|
|
147
|
+
useGetFieldExportHandler
|
|
148
|
+
});
|
package/dist/action.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// src/action/use-archieve-row.tsx
|
|
2
|
+
import { getEnv, useButton } from "@fctc/interface-logic";
|
|
3
|
+
var useArchieveHandler = ({
|
|
4
|
+
data,
|
|
5
|
+
onSuccess,
|
|
6
|
+
onError
|
|
7
|
+
}) => {
|
|
8
|
+
const archieve = useButton();
|
|
9
|
+
const env = getEnv();
|
|
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: env.context
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
onSuccess,
|
|
20
|
+
onError
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
return handleDuplicateRecord;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/action/use-duplicate-row.tsx
|
|
28
|
+
import { getEnv as getEnv2, useDuplicateRecord } from "@fctc/interface-logic";
|
|
29
|
+
var useDuplicateRowHandler = ({
|
|
30
|
+
data,
|
|
31
|
+
onSuccess,
|
|
32
|
+
onError
|
|
33
|
+
}) => {
|
|
34
|
+
const duplicateRecord = useDuplicateRecord();
|
|
35
|
+
const env = getEnv2();
|
|
36
|
+
const handleDuplicateRecord = () => {
|
|
37
|
+
duplicateRecord.mutate(
|
|
38
|
+
{
|
|
39
|
+
model: data.model,
|
|
40
|
+
id: Array.isArray(data.ids) ? [...data.ids] : data.ids,
|
|
41
|
+
context: env.context
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
onSuccess,
|
|
45
|
+
onError
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
return handleDuplicateRecord;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/action/use-get-field-export.tsx
|
|
53
|
+
import { getEnv as getEnv3, useGetFieldExport } from "@fctc/interface-logic";
|
|
54
|
+
var useGetFieldExportHandler = ({
|
|
55
|
+
data,
|
|
56
|
+
onSuccess,
|
|
57
|
+
onError
|
|
58
|
+
}) => {
|
|
59
|
+
const fieldExport = useGetFieldExport();
|
|
60
|
+
const env = getEnv3();
|
|
61
|
+
const handleGetFieldExport = () => {
|
|
62
|
+
fieldExport.mutate(
|
|
63
|
+
{
|
|
64
|
+
context: env.context,
|
|
65
|
+
ids: data.ids,
|
|
66
|
+
model: data.model,
|
|
67
|
+
isShow: data.isShow,
|
|
68
|
+
fieldType: data.fieldType,
|
|
69
|
+
importCompat: data.importCompat,
|
|
70
|
+
name: data.name,
|
|
71
|
+
parentField: data.parentField,
|
|
72
|
+
parentName: data.parentName,
|
|
73
|
+
prefix: data.prefix
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
onSuccess,
|
|
77
|
+
onError
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
return handleGetFieldExport;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/action/use-export-excel.tsx
|
|
85
|
+
import { evalJSONDomain, getEnv as getEnv4, useExportExcel } from "@fctc/interface-logic";
|
|
86
|
+
var useExportExcelHandler = ({
|
|
87
|
+
data,
|
|
88
|
+
onSuccess,
|
|
89
|
+
onError
|
|
90
|
+
}) => {
|
|
91
|
+
const exportExcel = useExportExcel();
|
|
92
|
+
const env = getEnv4();
|
|
93
|
+
const handleExport = () => {
|
|
94
|
+
exportExcel.mutate(
|
|
95
|
+
{
|
|
96
|
+
model: data.model,
|
|
97
|
+
ids: data?.ids,
|
|
98
|
+
fields: data.fields,
|
|
99
|
+
domain: evalJSONDomain(data.domain, env.context),
|
|
100
|
+
importCompat: data?.importCompat,
|
|
101
|
+
type: data.type,
|
|
102
|
+
context: env.context,
|
|
103
|
+
groupby: data?.groupby
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
onSuccess,
|
|
107
|
+
onError
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
return handleExport;
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
useArchieveHandler,
|
|
115
|
+
useDuplicateRowHandler,
|
|
116
|
+
useExportExcelHandler,
|
|
117
|
+
useGetFieldExportHandler
|
|
118
|
+
};
|
package/dist/form.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface UseSaveFormProps$1 {
|
|
2
|
+
data: {
|
|
3
|
+
context: any;
|
|
4
|
+
model: string;
|
|
5
|
+
specification: any;
|
|
6
|
+
id: any;
|
|
7
|
+
nameField: any;
|
|
8
|
+
object: any;
|
|
9
|
+
};
|
|
10
|
+
onSuccess?: (res: any) => void;
|
|
11
|
+
onError?: (err: any) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const UseOnChangeFormHandler: ({ data, onSuccess, onError, }: UseSaveFormProps$1) => () => void;
|
|
14
|
+
|
|
15
|
+
interface UseSaveFormProps {
|
|
16
|
+
data: {
|
|
17
|
+
context: any;
|
|
18
|
+
model: string;
|
|
19
|
+
specification: any;
|
|
20
|
+
id: number | string;
|
|
21
|
+
};
|
|
22
|
+
onSuccess?: (res: any) => void;
|
|
23
|
+
onError?: (err: any) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const useSaveFormHandler: ({ data, onSuccess, onError, }: UseSaveFormProps) => () => void;
|
|
26
|
+
|
|
27
|
+
interface UseDeleteProps {
|
|
28
|
+
data: {
|
|
29
|
+
method: string;
|
|
30
|
+
model: string;
|
|
31
|
+
ids: number[];
|
|
32
|
+
};
|
|
33
|
+
onSuccess?: (res: any) => void;
|
|
34
|
+
onError?: (err: any) => void;
|
|
35
|
+
}
|
|
36
|
+
declare const useRemoveRowHandler: ({ data, onSuccess, onError, }: UseDeleteProps) => () => void;
|
|
37
|
+
|
|
38
|
+
export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler };
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface UseSaveFormProps$1 {
|
|
2
|
+
data: {
|
|
3
|
+
context: any;
|
|
4
|
+
model: string;
|
|
5
|
+
specification: any;
|
|
6
|
+
id: any;
|
|
7
|
+
nameField: any;
|
|
8
|
+
object: any;
|
|
9
|
+
};
|
|
10
|
+
onSuccess?: (res: any) => void;
|
|
11
|
+
onError?: (err: any) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const UseOnChangeFormHandler: ({ data, onSuccess, onError, }: UseSaveFormProps$1) => () => void;
|
|
14
|
+
|
|
15
|
+
interface UseSaveFormProps {
|
|
16
|
+
data: {
|
|
17
|
+
context: any;
|
|
18
|
+
model: string;
|
|
19
|
+
specification: any;
|
|
20
|
+
id: number | string;
|
|
21
|
+
};
|
|
22
|
+
onSuccess?: (res: any) => void;
|
|
23
|
+
onError?: (err: any) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const useSaveFormHandler: ({ data, onSuccess, onError, }: UseSaveFormProps) => () => void;
|
|
26
|
+
|
|
27
|
+
interface UseDeleteProps {
|
|
28
|
+
data: {
|
|
29
|
+
method: string;
|
|
30
|
+
model: string;
|
|
31
|
+
ids: number[];
|
|
32
|
+
};
|
|
33
|
+
onSuccess?: (res: any) => void;
|
|
34
|
+
onError?: (err: any) => void;
|
|
35
|
+
}
|
|
36
|
+
declare const useRemoveRowHandler: ({ data, onSuccess, onError, }: UseDeleteProps) => () => void;
|
|
37
|
+
|
|
38
|
+
export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler };
|
package/dist/form.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
}) => {
|
|
36
|
+
const fetchOnchange = (0, import_interface_logic.useOnChangeForm)();
|
|
37
|
+
const handleOnChangeForm = () => {
|
|
38
|
+
fetchOnchange.mutate(
|
|
39
|
+
{
|
|
40
|
+
ids: data.id ? data.id : [],
|
|
41
|
+
model: data.model,
|
|
42
|
+
specification: data.specification,
|
|
43
|
+
context: data.context,
|
|
44
|
+
object: data.object,
|
|
45
|
+
fieldChange: [data.nameField]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
onSuccess,
|
|
49
|
+
onError
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
return handleOnChangeForm;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/widget/form/use-save-form.ts
|
|
57
|
+
var import_interface_logic2 = require("@fctc/interface-logic");
|
|
58
|
+
var useSaveFormHandler = ({
|
|
59
|
+
data,
|
|
60
|
+
onSuccess,
|
|
61
|
+
onError
|
|
62
|
+
}) => {
|
|
63
|
+
const fetchSave = (0, import_interface_logic2.useSave)();
|
|
64
|
+
const handleSaveForm = () => {
|
|
65
|
+
fetchSave.mutate(
|
|
66
|
+
{
|
|
67
|
+
ids: data.id ? [data.id] : [],
|
|
68
|
+
model: data.model,
|
|
69
|
+
data,
|
|
70
|
+
specification: data.specification,
|
|
71
|
+
context: data.context
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
onSuccess,
|
|
75
|
+
onError
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
return handleSaveForm;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/widget/form/use-remove-row.ts
|
|
83
|
+
var import_interface_logic3 = require("@fctc/interface-logic");
|
|
84
|
+
var useRemoveRowHandler = ({
|
|
85
|
+
data,
|
|
86
|
+
onSuccess,
|
|
87
|
+
onError
|
|
88
|
+
}) => {
|
|
89
|
+
const remove = (0, import_interface_logic3.useRemoveRow)();
|
|
90
|
+
const env = (0, import_interface_logic3.getEnv)();
|
|
91
|
+
const handleRemoveRow = () => {
|
|
92
|
+
remove.mutate(
|
|
93
|
+
{
|
|
94
|
+
model: data.model,
|
|
95
|
+
ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
|
|
96
|
+
context: env.context
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
onSuccess,
|
|
100
|
+
onError
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
return handleRemoveRow;
|
|
105
|
+
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
UseOnChangeFormHandler,
|
|
109
|
+
useRemoveRowHandler,
|
|
110
|
+
useSaveFormHandler
|
|
111
|
+
});
|
package/dist/form.mjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}) => {
|
|
8
|
+
const fetchOnchange = useOnChangeForm();
|
|
9
|
+
const handleOnChangeForm = () => {
|
|
10
|
+
fetchOnchange.mutate(
|
|
11
|
+
{
|
|
12
|
+
ids: data.id ? data.id : [],
|
|
13
|
+
model: data.model,
|
|
14
|
+
specification: data.specification,
|
|
15
|
+
context: data.context,
|
|
16
|
+
object: data.object,
|
|
17
|
+
fieldChange: [data.nameField]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
onSuccess,
|
|
21
|
+
onError
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
return handleOnChangeForm;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/widget/form/use-save-form.ts
|
|
29
|
+
import { useSave } from "@fctc/interface-logic";
|
|
30
|
+
var useSaveFormHandler = ({
|
|
31
|
+
data,
|
|
32
|
+
onSuccess,
|
|
33
|
+
onError
|
|
34
|
+
}) => {
|
|
35
|
+
const fetchSave = useSave();
|
|
36
|
+
const handleSaveForm = () => {
|
|
37
|
+
fetchSave.mutate(
|
|
38
|
+
{
|
|
39
|
+
ids: data.id ? [data.id] : [],
|
|
40
|
+
model: data.model,
|
|
41
|
+
data,
|
|
42
|
+
specification: data.specification,
|
|
43
|
+
context: data.context
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
onSuccess,
|
|
47
|
+
onError
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
return handleSaveForm;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/widget/form/use-remove-row.ts
|
|
55
|
+
import { getEnv, useRemoveRow } from "@fctc/interface-logic";
|
|
56
|
+
var useRemoveRowHandler = ({
|
|
57
|
+
data,
|
|
58
|
+
onSuccess,
|
|
59
|
+
onError
|
|
60
|
+
}) => {
|
|
61
|
+
const remove = useRemoveRow();
|
|
62
|
+
const env = getEnv();
|
|
63
|
+
const handleRemoveRow = () => {
|
|
64
|
+
remove.mutate(
|
|
65
|
+
{
|
|
66
|
+
model: data.model,
|
|
67
|
+
ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
|
|
68
|
+
context: env.context
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
onSuccess,
|
|
72
|
+
onError
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
return handleRemoveRow;
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
UseOnChangeFormHandler,
|
|
80
|
+
useRemoveRowHandler,
|
|
81
|
+
useSaveFormHandler
|
|
82
|
+
};
|
package/dist/table.d.mts
ADDED
package/dist/table.d.ts
ADDED
package/dist/table.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
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 = ({
|
|
42
|
+
fields,
|
|
43
|
+
data,
|
|
44
|
+
dataModel,
|
|
45
|
+
context,
|
|
46
|
+
typeTable
|
|
47
|
+
}) => {
|
|
48
|
+
const [rows, setRows] = (0, import_react.useState)(data || []);
|
|
49
|
+
const [columns, setColumns] = (0, import_react.useState)([]);
|
|
50
|
+
const dataModelFields = fields?.map((field) => {
|
|
51
|
+
return {
|
|
52
|
+
...dataModel?.[field?.name],
|
|
53
|
+
...field,
|
|
54
|
+
string: field?.string || dataModel?.[field?.name]?.string
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const mergeFields = mergeButtons(dataModelFields);
|
|
58
|
+
const transformData = (dataList) => {
|
|
59
|
+
if (!dataList) return;
|
|
60
|
+
return dataList?.map((item) => {
|
|
61
|
+
const transformedItem = { ...item };
|
|
62
|
+
Object.keys(item).forEach((field) => {
|
|
63
|
+
if (field !== "__domain") {
|
|
64
|
+
if (item[field] && typeof item[field] === "object" && item[field].display_name) {
|
|
65
|
+
transformedItem[field] = item[field];
|
|
66
|
+
} else if (Array.isArray(item[field]) && item[field].length > 0) {
|
|
67
|
+
if (typeTable === "group" && item[field]?.length === 2 && typeof item[field]?.[1] === "string") {
|
|
68
|
+
transformedItem["string"] = item[field]?.[1];
|
|
69
|
+
}
|
|
70
|
+
transformedItem[field] = item[field];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
(0, import_react.useEffect)(() => {
|
|
78
|
+
setRows(transformData(data || null));
|
|
79
|
+
}, [data]);
|
|
80
|
+
const handleGetColumns = () => {
|
|
81
|
+
let cols = [];
|
|
82
|
+
try {
|
|
83
|
+
cols = mergeFields?.filter((item) => {
|
|
84
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_interface_logic.domainHelper.matchDomains(context, item?.column_invisible) : item?.invisible ? import_interface_logic.domainHelper.matchDomains(context, item?.invisible) : false);
|
|
85
|
+
})?.map((field) => {
|
|
86
|
+
return {
|
|
87
|
+
name: field?.name,
|
|
88
|
+
optional: field?.optional,
|
|
89
|
+
title: field?.type_co === "button" ? "" : field?.string,
|
|
90
|
+
field: { ...field }
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error("Error in useTable:", error);
|
|
95
|
+
}
|
|
96
|
+
return cols;
|
|
97
|
+
};
|
|
98
|
+
(0, import_react.useEffect)(() => {
|
|
99
|
+
const columns2 = handleGetColumns();
|
|
100
|
+
setColumns(columns2);
|
|
101
|
+
}, [data]);
|
|
102
|
+
const onToggleColumnOptional = (item) => {
|
|
103
|
+
const tempColumn = [...columns]?.map((val) => {
|
|
104
|
+
if (item?.name === val?.name) {
|
|
105
|
+
return {
|
|
106
|
+
...val,
|
|
107
|
+
optional: item?.optional === "show" ? "hide" : "show"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return val;
|
|
111
|
+
});
|
|
112
|
+
setColumns(tempColumn);
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
rows,
|
|
116
|
+
columns,
|
|
117
|
+
onToggleColumnOptional,
|
|
118
|
+
typeTable
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
useTableHandler
|
|
124
|
+
});
|
package/dist/table.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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 = ({
|
|
16
|
+
fields,
|
|
17
|
+
data,
|
|
18
|
+
dataModel,
|
|
19
|
+
context,
|
|
20
|
+
typeTable
|
|
21
|
+
}) => {
|
|
22
|
+
const [rows, setRows] = useState(data || []);
|
|
23
|
+
const [columns, setColumns] = useState([]);
|
|
24
|
+
const dataModelFields = fields?.map((field) => {
|
|
25
|
+
return {
|
|
26
|
+
...dataModel?.[field?.name],
|
|
27
|
+
...field,
|
|
28
|
+
string: field?.string || dataModel?.[field?.name]?.string
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const mergeFields = mergeButtons(dataModelFields);
|
|
32
|
+
const transformData = (dataList) => {
|
|
33
|
+
if (!dataList) return;
|
|
34
|
+
return dataList?.map((item) => {
|
|
35
|
+
const transformedItem = { ...item };
|
|
36
|
+
Object.keys(item).forEach((field) => {
|
|
37
|
+
if (field !== "__domain") {
|
|
38
|
+
if (item[field] && typeof item[field] === "object" && item[field].display_name) {
|
|
39
|
+
transformedItem[field] = item[field];
|
|
40
|
+
} else if (Array.isArray(item[field]) && item[field].length > 0) {
|
|
41
|
+
if (typeTable === "group" && item[field]?.length === 2 && typeof item[field]?.[1] === "string") {
|
|
42
|
+
transformedItem["string"] = item[field]?.[1];
|
|
43
|
+
}
|
|
44
|
+
transformedItem[field] = item[field];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setRows(transformData(data || null));
|
|
53
|
+
}, [data]);
|
|
54
|
+
const handleGetColumns = () => {
|
|
55
|
+
let cols = [];
|
|
56
|
+
try {
|
|
57
|
+
cols = mergeFields?.filter((item) => {
|
|
58
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? domainHelper.matchDomains(context, item?.column_invisible) : item?.invisible ? domainHelper.matchDomains(context, item?.invisible) : false);
|
|
59
|
+
})?.map((field) => {
|
|
60
|
+
return {
|
|
61
|
+
name: field?.name,
|
|
62
|
+
optional: field?.optional,
|
|
63
|
+
title: field?.type_co === "button" ? "" : field?.string,
|
|
64
|
+
field: { ...field }
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("Error in useTable:", error);
|
|
69
|
+
}
|
|
70
|
+
return cols;
|
|
71
|
+
};
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const columns2 = handleGetColumns();
|
|
74
|
+
setColumns(columns2);
|
|
75
|
+
}, [data]);
|
|
76
|
+
const onToggleColumnOptional = (item) => {
|
|
77
|
+
const tempColumn = [...columns]?.map((val) => {
|
|
78
|
+
if (item?.name === val?.name) {
|
|
79
|
+
return {
|
|
80
|
+
...val,
|
|
81
|
+
optional: item?.optional === "show" ? "hide" : "show"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return val;
|
|
85
|
+
});
|
|
86
|
+
setColumns(tempColumn);
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
rows,
|
|
90
|
+
columns,
|
|
91
|
+
onToggleColumnOptional,
|
|
92
|
+
typeTable
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
useTableHandler
|
|
97
|
+
};
|
package/package.json
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fctc/widget-logic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.mjs",
|
|
10
|
-
"require": "./dist/index.cjs"
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
11
12
|
},
|
|
12
|
-
"./
|
|
13
|
-
"import": "./dist/
|
|
14
|
-
"require": "./dist/
|
|
13
|
+
"./action": {
|
|
14
|
+
"import": "./dist/action.mjs",
|
|
15
|
+
"require": "./dist/action.cjs",
|
|
16
|
+
"types": "./dist/action.d.ts"
|
|
15
17
|
},
|
|
16
|
-
"./
|
|
17
|
-
"import": "./dist/
|
|
18
|
-
"require": "./dist/
|
|
18
|
+
"./form": {
|
|
19
|
+
"import": "./dist/form.mjs",
|
|
20
|
+
"require": "./dist/form.cjs",
|
|
21
|
+
"types": "./dist/form.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./table": {
|
|
24
|
+
"import": "./dist/table.mjs",
|
|
25
|
+
"require": "./dist/table.cjs",
|
|
26
|
+
"types": "./dist/table.d.ts"
|
|
19
27
|
}
|
|
20
28
|
},
|
|
21
29
|
"files": [
|
|
@@ -26,7 +34,7 @@
|
|
|
26
34
|
"test": "jest"
|
|
27
35
|
},
|
|
28
36
|
"dependencies": {
|
|
29
|
-
"@fctc/interface-logic": "^1.0.
|
|
37
|
+
"@fctc/interface-logic": "^1.0.1",
|
|
30
38
|
"@types/react": "^19.1.8",
|
|
31
39
|
"react": "18.0.0",
|
|
32
40
|
"react-dom": "18.0.0",
|