@fctc/widget-logic 1.4.0 → 1.4.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.
Files changed (57) hide show
  1. package/dist/config.d.mts +6 -0
  2. package/dist/config.d.ts +6 -0
  3. package/dist/config.js +24 -0
  4. package/dist/config.mjs +2 -0
  5. package/dist/constants.d.mts +1 -0
  6. package/dist/constants.d.ts +1 -0
  7. package/dist/constants.js +24 -0
  8. package/dist/constants.mjs +2 -0
  9. package/dist/environment.d.mts +1 -0
  10. package/dist/environment.d.ts +1 -0
  11. package/dist/environment.js +24 -0
  12. package/dist/environment.mjs +2 -0
  13. package/dist/hooks.d.mts +969 -0
  14. package/dist/hooks.d.ts +969 -0
  15. package/dist/hooks.js +743 -0
  16. package/dist/hooks.mjs +717 -0
  17. package/dist/icons.d.mts +9 -0
  18. package/dist/icons.d.ts +9 -0
  19. package/dist/icons.js +139 -0
  20. package/dist/icons.mjs +110 -0
  21. package/dist/index.d.mts +2 -5
  22. package/dist/index.d.ts +2 -5
  23. package/dist/index.js +0 -364
  24. package/dist/index.mjs +0 -330
  25. package/dist/provider.d.mts +1 -0
  26. package/dist/provider.d.ts +1 -0
  27. package/dist/provider.js +24 -0
  28. package/dist/provider.mjs +2 -0
  29. package/dist/services.d.mts +1 -0
  30. package/dist/services.d.ts +1 -0
  31. package/dist/services.js +24 -0
  32. package/dist/services.mjs +2 -0
  33. package/dist/store.d.mts +1 -0
  34. package/dist/store.d.ts +1 -0
  35. package/dist/store.js +24 -0
  36. package/dist/store.mjs +2 -0
  37. package/dist/utils.d.mts +38 -0
  38. package/dist/utils.d.ts +38 -0
  39. package/dist/utils.js +282 -0
  40. package/dist/utils.mjs +242 -0
  41. package/package.json +60 -22
  42. package/dist/action.d.mts +0 -68
  43. package/dist/action.d.ts +0 -68
  44. package/dist/action.js +0 -152
  45. package/dist/action.mjs +0 -122
  46. package/dist/common.d.mts +0 -13
  47. package/dist/common.d.ts +0 -13
  48. package/dist/common.js +0 -60
  49. package/dist/common.mjs +0 -33
  50. package/dist/form.d.mts +0 -41
  51. package/dist/form.d.ts +0 -41
  52. package/dist/form.js +0 -116
  53. package/dist/form.mjs +0 -87
  54. package/dist/table.d.mts +0 -22
  55. package/dist/table.d.ts +0 -22
  56. package/dist/table.js +0 -118
  57. package/dist/table.mjs +0 -91
@@ -0,0 +1,9 @@
1
+ declare const EyeIcon: React.FC<React.SVGProps<SVGSVGElement>>;
2
+
3
+ declare const LoadingIcon: ({ width, height, ...props }: React.SVGProps<SVGSVGElement>) => JSX.Element;
4
+
5
+ declare const CloseIcon: ({ className }: {
6
+ className?: string;
7
+ }) => JSX.Element;
8
+
9
+ export { CloseIcon, EyeIcon, LoadingIcon };
@@ -0,0 +1,9 @@
1
+ declare const EyeIcon: React.FC<React.SVGProps<SVGSVGElement>>;
2
+
3
+ declare const LoadingIcon: ({ width, height, ...props }: React.SVGProps<SVGSVGElement>) => JSX.Element;
4
+
5
+ declare const CloseIcon: ({ className }: {
6
+ className?: string;
7
+ }) => JSX.Element;
8
+
9
+ export { CloseIcon, EyeIcon, LoadingIcon };
package/dist/icons.js ADDED
@@ -0,0 +1,139 @@
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/icons.ts
21
+ var icons_exports = {};
22
+ __export(icons_exports, {
23
+ CloseIcon: () => CloseIcon,
24
+ EyeIcon: () => EyeIcon,
25
+ LoadingIcon: () => LoadingIcon
26
+ });
27
+ module.exports = __toCommonJS(icons_exports);
28
+
29
+ // src/icons/eye-icon.tsx
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var EyeIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
32
+ "svg",
33
+ {
34
+ width: "20",
35
+ height: "21",
36
+ viewBox: "0 0 20 21",
37
+ fill: "none",
38
+ xmlns: "http://www.w3.org/2000/svg",
39
+ children: [
40
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
+ "path",
42
+ {
43
+ d: "M2.72904 13.5776C2.02076 12.6574 1.66663 12.1974 1.66663 10.8312C1.66663 9.46507 2.02076 9.00499 2.72904 8.08483C4.14326 6.24752 6.51505 4.16455 9.99996 4.16455C13.4849 4.16455 15.8567 6.24752 17.2709 8.08483C17.9792 9.00499 18.3333 9.46507 18.3333 10.8312C18.3333 12.1974 17.9792 12.6574 17.2709 13.5776C15.8567 15.4149 13.4849 17.4979 9.99996 17.4979C6.51505 17.4979 4.14326 15.4149 2.72904 13.5776Z",
44
+ stroke: "#ABACAE",
45
+ strokeWidth: "1.5"
46
+ }
47
+ ),
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ "path",
50
+ {
51
+ d: "M12.5 10.8311C12.5 12.2118 11.3807 13.3311 10 13.3311C8.61929 13.3311 7.5 12.2118 7.5 10.8311C7.5 9.45034 8.61929 8.33105 10 8.33105C11.3807 8.33105 12.5 9.45034 12.5 10.8311Z",
52
+ stroke: "#ABACAE",
53
+ strokeWidth: "1.5"
54
+ }
55
+ )
56
+ ]
57
+ }
58
+ );
59
+
60
+ // src/icons/loading-icon.tsx
61
+ var import_jsx_runtime2 = require("react/jsx-runtime");
62
+ var LoadingIcon = ({
63
+ width = 15,
64
+ height = 15,
65
+ ...props
66
+ }) => {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
68
+ "svg",
69
+ {
70
+ xmlns: "http://www.w3.org/2000/svg",
71
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
72
+ viewBox: "0 0 100 100",
73
+ preserveAspectRatio: "xMidYMid",
74
+ width,
75
+ height,
76
+ style: {
77
+ shapeRendering: "auto",
78
+ display: "block",
79
+ background: "transparent"
80
+ },
81
+ ...props,
82
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { children: [
83
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
84
+ "circle",
85
+ {
86
+ strokeDasharray: "141.37166941154067 49.12388980384689",
87
+ r: "30",
88
+ strokeWidth: "10",
89
+ stroke: "currentColor",
90
+ fill: "none",
91
+ cy: "50",
92
+ cx: "50",
93
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
94
+ "animateTransform",
95
+ {
96
+ keyTimes: "0;1",
97
+ values: "0 50 50;360 50 50",
98
+ dur: "0.5050505050505051s",
99
+ repeatCount: "indefinite",
100
+ type: "rotate",
101
+ attributeName: "transform"
102
+ }
103
+ )
104
+ }
105
+ ),
106
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("g", {})
107
+ ] })
108
+ }
109
+ );
110
+ };
111
+
112
+ // src/icons/close-icon.tsx
113
+ var import_jsx_runtime3 = require("react/jsx-runtime");
114
+ var CloseIcon = ({ className = "" }) => {
115
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
116
+ "svg",
117
+ {
118
+ width: "24",
119
+ height: "24",
120
+ viewBox: "0 0 24 24",
121
+ fill: "none",
122
+ xmlns: "http://www.w3.org/2000/svg",
123
+ className,
124
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
125
+ "path",
126
+ {
127
+ d: "M12.0001 10.7275L16.4551 6.27246L17.7277 7.54506L13.2727 12.0001L17.7277 16.4551L16.4551 17.7277L12.0001 13.2727L7.54506 17.7277L6.27246 16.4551L10.7275 12.0001L6.27246 7.54506L7.54506 6.27246L12.0001 10.7275Z",
128
+ fill: "#A4A4A4"
129
+ }
130
+ )
131
+ }
132
+ );
133
+ };
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ CloseIcon,
137
+ EyeIcon,
138
+ LoadingIcon
139
+ });
package/dist/icons.mjs ADDED
@@ -0,0 +1,110 @@
1
+ // src/icons/eye-icon.tsx
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ var EyeIcon = () => /* @__PURE__ */ jsxs(
4
+ "svg",
5
+ {
6
+ width: "20",
7
+ height: "21",
8
+ viewBox: "0 0 20 21",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: [
12
+ /* @__PURE__ */ jsx(
13
+ "path",
14
+ {
15
+ d: "M2.72904 13.5776C2.02076 12.6574 1.66663 12.1974 1.66663 10.8312C1.66663 9.46507 2.02076 9.00499 2.72904 8.08483C4.14326 6.24752 6.51505 4.16455 9.99996 4.16455C13.4849 4.16455 15.8567 6.24752 17.2709 8.08483C17.9792 9.00499 18.3333 9.46507 18.3333 10.8312C18.3333 12.1974 17.9792 12.6574 17.2709 13.5776C15.8567 15.4149 13.4849 17.4979 9.99996 17.4979C6.51505 17.4979 4.14326 15.4149 2.72904 13.5776Z",
16
+ stroke: "#ABACAE",
17
+ strokeWidth: "1.5"
18
+ }
19
+ ),
20
+ /* @__PURE__ */ jsx(
21
+ "path",
22
+ {
23
+ d: "M12.5 10.8311C12.5 12.2118 11.3807 13.3311 10 13.3311C8.61929 13.3311 7.5 12.2118 7.5 10.8311C7.5 9.45034 8.61929 8.33105 10 8.33105C11.3807 8.33105 12.5 9.45034 12.5 10.8311Z",
24
+ stroke: "#ABACAE",
25
+ strokeWidth: "1.5"
26
+ }
27
+ )
28
+ ]
29
+ }
30
+ );
31
+
32
+ // src/icons/loading-icon.tsx
33
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
34
+ var LoadingIcon = ({
35
+ width = 15,
36
+ height = 15,
37
+ ...props
38
+ }) => {
39
+ return /* @__PURE__ */ jsx2(
40
+ "svg",
41
+ {
42
+ xmlns: "http://www.w3.org/2000/svg",
43
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
44
+ viewBox: "0 0 100 100",
45
+ preserveAspectRatio: "xMidYMid",
46
+ width,
47
+ height,
48
+ style: {
49
+ shapeRendering: "auto",
50
+ display: "block",
51
+ background: "transparent"
52
+ },
53
+ ...props,
54
+ children: /* @__PURE__ */ jsxs2("g", { children: [
55
+ /* @__PURE__ */ jsx2(
56
+ "circle",
57
+ {
58
+ strokeDasharray: "141.37166941154067 49.12388980384689",
59
+ r: "30",
60
+ strokeWidth: "10",
61
+ stroke: "currentColor",
62
+ fill: "none",
63
+ cy: "50",
64
+ cx: "50",
65
+ children: /* @__PURE__ */ jsx2(
66
+ "animateTransform",
67
+ {
68
+ keyTimes: "0;1",
69
+ values: "0 50 50;360 50 50",
70
+ dur: "0.5050505050505051s",
71
+ repeatCount: "indefinite",
72
+ type: "rotate",
73
+ attributeName: "transform"
74
+ }
75
+ )
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsx2("g", {})
79
+ ] })
80
+ }
81
+ );
82
+ };
83
+
84
+ // src/icons/close-icon.tsx
85
+ import { jsx as jsx3 } from "react/jsx-runtime";
86
+ var CloseIcon = ({ className = "" }) => {
87
+ return /* @__PURE__ */ jsx3(
88
+ "svg",
89
+ {
90
+ width: "24",
91
+ height: "24",
92
+ viewBox: "0 0 24 24",
93
+ fill: "none",
94
+ xmlns: "http://www.w3.org/2000/svg",
95
+ className,
96
+ children: /* @__PURE__ */ jsx3(
97
+ "path",
98
+ {
99
+ d: "M12.0001 10.7275L16.4551 6.27246L17.7277 7.54506L13.2727 12.0001L17.7277 16.4551L16.4551 17.7277L12.0001 13.2727L7.54506 17.7277L6.27246 16.4551L10.7275 12.0001L6.27246 7.54506L7.54506 6.27246L12.0001 10.7275Z",
100
+ fill: "#A4A4A4"
101
+ }
102
+ )
103
+ }
104
+ );
105
+ };
106
+ export {
107
+ CloseIcon,
108
+ EyeIcon,
109
+ LoadingIcon
110
+ };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,2 @@
1
- export { useArchieveHandler, useDuplicateRowHandler, useExportExcelHandler, useGetFieldExportHandler } from './action.mjs';
2
- export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler } from './form.mjs';
3
- export { useTableHandler } from './table.mjs';
4
- export { useClickOutside } from './common.mjs';
5
- import 'react';
1
+
2
+ export { }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- export { useArchieveHandler, useDuplicateRowHandler, useExportExcelHandler, useGetFieldExportHandler } from './action.js';
2
- export { UseOnChangeFormHandler, useRemoveRowHandler, useSaveFormHandler } from './form.js';
3
- export { useTableHandler } from './table.js';
4
- export { useClickOutside } from './common.js';
5
- import 'react';
1
+
2
+ export { }
package/dist/index.js CHANGED
@@ -1,365 +1 @@
1
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/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- UseOnChangeFormHandler: () => UseOnChangeFormHandler,
24
- useArchieveHandler: () => useArchieveHandler,
25
- useClickOutside: () => useClickOutside,
26
- useDuplicateRowHandler: () => useDuplicateRowHandler,
27
- useExportExcelHandler: () => useExportExcelHandler,
28
- useGetFieldExportHandler: () => useGetFieldExportHandler,
29
- useRemoveRowHandler: () => useRemoveRowHandler,
30
- useSaveFormHandler: () => useSaveFormHandler,
31
- useTableHandler: () => useTableHandler
32
- });
33
- module.exports = __toCommonJS(index_exports);
34
-
35
- // src/action/use-archieve-row.ts
36
- var import_interface_logic = require("@fctc/interface-logic");
37
- var useArchieveHandler = ({
38
- data,
39
- onSuccess,
40
- onError,
41
- onSettled
42
- }) => {
43
- const archieve = (0, import_interface_logic.useButton)();
44
- const handleDuplicateRecord = () => {
45
- archieve.mutate(
46
- {
47
- method: `action_${data.actionName}`,
48
- model: data.model,
49
- ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
50
- context: data.context
51
- },
52
- {
53
- onSuccess,
54
- onError,
55
- onSettled
56
- }
57
- );
58
- };
59
- return handleDuplicateRecord;
60
- };
61
-
62
- // src/action/use-duplicate-row.ts
63
- var import_interface_logic2 = require("@fctc/interface-logic");
64
- var useDuplicateRowHandler = ({
65
- data,
66
- onSuccess,
67
- onError,
68
- onSettled
69
- }) => {
70
- const duplicateRecord = (0, import_interface_logic2.useDuplicateRecord)();
71
- const handleDuplicateRecord = () => {
72
- duplicateRecord.mutate(
73
- {
74
- model: data.model,
75
- id: Array.isArray(data.ids) ? [...data.ids] : data.ids,
76
- context: data.context
77
- },
78
- {
79
- onSuccess,
80
- onError,
81
- onSettled
82
- }
83
- );
84
- };
85
- return handleDuplicateRecord;
86
- };
87
-
88
- // src/action/use-get-field-export.ts
89
- var import_interface_logic3 = require("@fctc/interface-logic");
90
- var useGetFieldExportHandler = ({
91
- data,
92
- onSuccess,
93
- onError,
94
- onSettled
95
- }) => {
96
- const fieldExport = (0, import_interface_logic3.useGetFieldExport)();
97
- const handleGetFieldExport = () => {
98
- fieldExport.mutate(
99
- {
100
- context: data.context,
101
- ids: data.ids,
102
- model: data.model,
103
- isShow: data.isShow,
104
- fieldType: data.fieldType,
105
- importCompat: data.importCompat,
106
- name: data.name,
107
- parentField: data.parentField,
108
- parentName: data.parentName,
109
- prefix: data.prefix
110
- },
111
- {
112
- onSuccess,
113
- onError,
114
- onSettled
115
- }
116
- );
117
- };
118
- return handleGetFieldExport;
119
- };
120
-
121
- // src/action/use-export-excel.ts
122
- var import_interface_logic4 = require("@fctc/interface-logic");
123
- var useExportExcelHandler = ({
124
- data,
125
- onSuccess,
126
- onError,
127
- onSettled
128
- }) => {
129
- const exportExcel = (0, import_interface_logic4.useExportExcel)();
130
- const handleExport = () => {
131
- exportExcel.mutate(
132
- {
133
- model: data.model,
134
- ids: data?.ids,
135
- fields: data.fields,
136
- domain: (0, import_interface_logic4.evalJSONDomain)(data.domain, data.context),
137
- importCompat: data?.importCompat,
138
- type: data.type,
139
- context: data.context,
140
- groupby: data?.groupby
141
- },
142
- {
143
- onSuccess,
144
- onError,
145
- onSettled
146
- }
147
- );
148
- };
149
- return handleExport;
150
- };
151
-
152
- // src/widget/form/use-on-change-form.ts
153
- var import_interface_logic5 = require("@fctc/interface-logic");
154
- var UseOnChangeFormHandler = ({
155
- data,
156
- onSuccess,
157
- onError,
158
- onSettled
159
- }) => {
160
- const fetchOnchange = (0, import_interface_logic5.useOnChangeForm)();
161
- const handleOnChangeForm = () => {
162
- fetchOnchange.mutate(
163
- {
164
- ids: data.id ? data.id : [],
165
- model: data.model,
166
- specification: data.specification,
167
- context: data.context,
168
- object: data.object,
169
- fieldChange: [data.nameField]
170
- },
171
- {
172
- onSuccess,
173
- onError,
174
- onSettled
175
- }
176
- );
177
- };
178
- return handleOnChangeForm;
179
- };
180
-
181
- // src/widget/form/use-save-form.ts
182
- var import_interface_logic6 = require("@fctc/interface-logic");
183
- var useSaveFormHandler = ({
184
- data,
185
- onSuccess,
186
- onError,
187
- onSettled
188
- }) => {
189
- const fetchSave = (0, import_interface_logic6.useSave)();
190
- const handleSaveForm = () => {
191
- fetchSave.mutate(
192
- {
193
- ids: data.id ? [data.id] : [],
194
- model: data.model,
195
- data,
196
- specification: data.specification,
197
- context: data.context
198
- },
199
- {
200
- onSuccess,
201
- onError,
202
- onSettled
203
- }
204
- );
205
- };
206
- return handleSaveForm;
207
- };
208
-
209
- // src/widget/form/use-remove-row.ts
210
- var import_interface_logic7 = require("@fctc/interface-logic");
211
- var useRemoveRowHandler = ({
212
- data,
213
- onSuccess,
214
- onError,
215
- onSettled
216
- }) => {
217
- const remove = (0, import_interface_logic7.useRemoveRow)();
218
- const handleRemoveRow = () => {
219
- remove.mutate(
220
- {
221
- model: data.model,
222
- ids: Array.isArray(data.ids) ? [...data.ids] : data.ids,
223
- context: data.context
224
- },
225
- {
226
- onSuccess,
227
- onError,
228
- onSettled
229
- }
230
- );
231
- };
232
- return handleRemoveRow;
233
- };
234
-
235
- // src/widget/table/use-table.ts
236
- var import_interface_logic8 = require("@fctc/interface-logic");
237
- var import_react = require("react");
238
- function mergeButtons(fields) {
239
- const buttons = fields?.filter((f) => f.type_co === "button");
240
- const others = fields?.filter((f) => f.type_co !== "button");
241
- if (buttons?.length) {
242
- others.push({
243
- type_co: "buttons",
244
- buttons
245
- });
246
- }
247
- return others;
248
- }
249
- var useTableHandler = ({ data }) => {
250
- const [rows, setRows] = (0, import_react.useState)(data.records || []);
251
- const [columns, setColumns] = (0, import_react.useState)([]);
252
- const dataModelFields = data.fields?.map((field) => {
253
- return {
254
- ...data.dataModel?.[field?.name],
255
- ...field,
256
- string: field?.string || data.dataModel?.[field?.name]?.string
257
- };
258
- });
259
- const mergeFields = mergeButtons(dataModelFields);
260
- const transformData = (dataList) => {
261
- if (!dataList) return;
262
- return dataList?.map((item) => {
263
- const transformedItem = { ...item };
264
- Object.keys(item).forEach((field) => {
265
- if (field !== "__domain") {
266
- if (item[field] && typeof item[field] === "object" && item[field].display_name) {
267
- transformedItem[field] = item[field];
268
- } else if (Array.isArray(item[field]) && item[field].length > 0) {
269
- if (data.typeTable === "group" && item[field]?.length === 2 && typeof item[field]?.[1] === "string") {
270
- transformedItem["string"] = item[field]?.[1];
271
- }
272
- transformedItem[field] = item[field];
273
- }
274
- }
275
- });
276
- return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
277
- });
278
- };
279
- (0, import_react.useEffect)(() => {
280
- setRows(transformData(data.records || null));
281
- }, [data.records]);
282
- const handleGetColumns = () => {
283
- let cols = [];
284
- try {
285
- cols = mergeFields?.filter((item) => {
286
- return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_interface_logic8.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_interface_logic8.domainHelper.matchDomains(data.context, item?.invisible) : false);
287
- })?.map((field) => {
288
- return {
289
- name: field?.name,
290
- optional: field?.optional,
291
- title: field?.type_co === "button" ? "" : field?.string,
292
- field: { ...field }
293
- };
294
- });
295
- } catch (error) {
296
- console.error("Error in useTable:", error);
297
- }
298
- return cols;
299
- };
300
- (0, import_react.useEffect)(() => {
301
- const columns2 = handleGetColumns();
302
- setColumns(columns2);
303
- }, [data.records]);
304
- const onToggleColumnOptional = (item) => {
305
- const tempColumn = [...columns]?.map((val) => {
306
- if (item?.name === val?.name) {
307
- return {
308
- ...val,
309
- optional: item?.optional === "show" ? "hide" : "show"
310
- };
311
- }
312
- return val;
313
- });
314
- setColumns(tempColumn);
315
- };
316
- return {
317
- rows,
318
- columns,
319
- onToggleColumnOptional,
320
- typeTable: data.typeTable
321
- };
322
- };
323
-
324
- // src/common/use-click-outside.ts
325
- var import_react2 = require("react");
326
- var DEFAULT_EVENTS = ["mousedown", "touchstart"];
327
- var useClickOutside = ({
328
- handler,
329
- events = DEFAULT_EVENTS,
330
- nodes = [],
331
- refs
332
- }) => {
333
- const ref = (0, import_react2.useRef)(null);
334
- (0, import_react2.useEffect)(() => {
335
- const listener = (event) => {
336
- const { target } = event;
337
- if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
338
- return;
339
- }
340
- if (!(target instanceof HTMLElement)) return;
341
- const shouldIgnore = target.hasAttribute("data-ignore-outside-clicks") || !document.body.contains(target) && target.tagName !== "HTML";
342
- const shouldTrigger = nodes.length > 0 ? nodes.every((node) => node && !event.composedPath().includes(node)) : ref.current && !ref.current.contains(target);
343
- if (shouldTrigger && !shouldIgnore) {
344
- handler(event);
345
- }
346
- };
347
- events.forEach((event) => document.addEventListener(event, listener));
348
- return () => {
349
- events.forEach((event) => document.removeEventListener(event, listener));
350
- };
351
- }, [handler, nodes, events]);
352
- return ref;
353
- };
354
- // Annotate the CommonJS export names for ESM import in node:
355
- 0 && (module.exports = {
356
- UseOnChangeFormHandler,
357
- useArchieveHandler,
358
- useClickOutside,
359
- useDuplicateRowHandler,
360
- useExportExcelHandler,
361
- useGetFieldExportHandler,
362
- useRemoveRowHandler,
363
- useSaveFormHandler,
364
- useTableHandler
365
- });