@fctc/widget-logic 3.0.2 → 3.0.4
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/hooks.d.mts +1 -3
- package/dist/hooks.d.ts +1 -3
- package/dist/hooks.js +63 -63
- package/dist/hooks.mjs +57 -57
- package/dist/index.js +96 -96
- package/dist/index.mjs +69 -69
- package/dist/widget.js +39 -39
- package/dist/widget.mjs +15 -15
- package/package.json +96 -96
package/dist/hooks.d.mts
CHANGED
|
@@ -56,7 +56,6 @@ interface RecordMenu {
|
|
|
56
56
|
};
|
|
57
57
|
res_model: string;
|
|
58
58
|
type: string;
|
|
59
|
-
context: string;
|
|
60
59
|
};
|
|
61
60
|
active: boolean;
|
|
62
61
|
child_id?: RecordMenu[];
|
|
@@ -75,11 +74,10 @@ interface RecordMenu {
|
|
|
75
74
|
interface UseMenuReturn {
|
|
76
75
|
data: RecordMenu[] | undefined;
|
|
77
76
|
action: {
|
|
78
|
-
handleChangeMenu: ({ menu, service, xNode,
|
|
77
|
+
handleChangeMenu: ({ menu, service, xNode, }: {
|
|
79
78
|
menu?: RecordMenu;
|
|
80
79
|
service?: string;
|
|
81
80
|
xNode?: string;
|
|
82
|
-
context?: any;
|
|
83
81
|
}) => Promise<any>;
|
|
84
82
|
};
|
|
85
83
|
state: {
|
package/dist/hooks.d.ts
CHANGED
|
@@ -56,7 +56,6 @@ interface RecordMenu {
|
|
|
56
56
|
};
|
|
57
57
|
res_model: string;
|
|
58
58
|
type: string;
|
|
59
|
-
context: string;
|
|
60
59
|
};
|
|
61
60
|
active: boolean;
|
|
62
61
|
child_id?: RecordMenu[];
|
|
@@ -75,11 +74,10 @@ interface RecordMenu {
|
|
|
75
74
|
interface UseMenuReturn {
|
|
76
75
|
data: RecordMenu[] | undefined;
|
|
77
76
|
action: {
|
|
78
|
-
handleChangeMenu: ({ menu, service, xNode,
|
|
77
|
+
handleChangeMenu: ({ menu, service, xNode, }: {
|
|
79
78
|
menu?: RecordMenu;
|
|
80
79
|
service?: string;
|
|
81
80
|
xNode?: string;
|
|
82
|
-
context?: any;
|
|
83
81
|
}) => Promise<any>;
|
|
84
82
|
};
|
|
85
83
|
state: {
|
package/dist/hooks.js
CHANGED
|
@@ -117,62 +117,12 @@ var import_react8 = require("react");
|
|
|
117
117
|
var import_react3 = require("react");
|
|
118
118
|
|
|
119
119
|
// src/hooks/core/use-call-action.ts
|
|
120
|
-
var
|
|
120
|
+
var import_react2 = require("react");
|
|
121
121
|
|
|
122
122
|
// src/provider.ts
|
|
123
123
|
var provider_exports = {};
|
|
124
124
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
125
125
|
|
|
126
|
-
// src/hooks/core/use-call-action.ts
|
|
127
|
-
var useCallAction = () => {
|
|
128
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
129
|
-
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
130
|
-
const queryLoadAction = useLoadAction2();
|
|
131
|
-
const queryRunAction = useRunAction2();
|
|
132
|
-
const [actionData, setActionData] = (0, import_react.useState)(
|
|
133
|
-
void 0
|
|
134
|
-
);
|
|
135
|
-
const callAction = (0, import_react.useCallback)(
|
|
136
|
-
async ({
|
|
137
|
-
aid,
|
|
138
|
-
service,
|
|
139
|
-
xNode,
|
|
140
|
-
context
|
|
141
|
-
}) => {
|
|
142
|
-
try {
|
|
143
|
-
const menuContext = {
|
|
144
|
-
...env?.context,
|
|
145
|
-
...context
|
|
146
|
-
};
|
|
147
|
-
const loadRes = await queryLoadAction.mutateAsync({
|
|
148
|
-
idAction: aid,
|
|
149
|
-
context: menuContext,
|
|
150
|
-
service,
|
|
151
|
-
xNode
|
|
152
|
-
});
|
|
153
|
-
if (loadRes?.result?.type === "ir.actions.server") {
|
|
154
|
-
const runRes = await queryRunAction.mutateAsync({
|
|
155
|
-
idAction: aid,
|
|
156
|
-
context: menuContext,
|
|
157
|
-
service,
|
|
158
|
-
xNode
|
|
159
|
-
});
|
|
160
|
-
setActionData(runRes?.result);
|
|
161
|
-
return runRes?.result;
|
|
162
|
-
} else {
|
|
163
|
-
setActionData(loadRes?.result);
|
|
164
|
-
return loadRes?.result;
|
|
165
|
-
}
|
|
166
|
-
} catch (err) {
|
|
167
|
-
console.error("callAction error:", err);
|
|
168
|
-
return void 0;
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
[env?.context?.lang]
|
|
172
|
-
);
|
|
173
|
-
return [actionData, callAction];
|
|
174
|
-
};
|
|
175
|
-
|
|
176
126
|
// src/utils.ts
|
|
177
127
|
var utils_exports = {};
|
|
178
128
|
__export(utils_exports, {
|
|
@@ -194,7 +144,7 @@ var languages = [
|
|
|
194
144
|
];
|
|
195
145
|
|
|
196
146
|
// src/utils/function.ts
|
|
197
|
-
var
|
|
147
|
+
var import_react = require("react");
|
|
198
148
|
var countSum = (data, field) => {
|
|
199
149
|
if (!data || !field) return 0;
|
|
200
150
|
return data.reduce(
|
|
@@ -315,7 +265,7 @@ var STORAGES = {
|
|
|
315
265
|
USER_INFO: "USER_INFO"
|
|
316
266
|
};
|
|
317
267
|
function useAsyncState(initialValue = [true, null]) {
|
|
318
|
-
return (0,
|
|
268
|
+
return (0, import_react.useReducer)(
|
|
319
269
|
(_state, action = null) => [false, action],
|
|
320
270
|
initialValue
|
|
321
271
|
);
|
|
@@ -333,7 +283,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
333
283
|
}
|
|
334
284
|
function useStorageState(key) {
|
|
335
285
|
const [state, setState] = useAsyncState();
|
|
336
|
-
(0,
|
|
286
|
+
(0, import_react.useEffect)(() => {
|
|
337
287
|
try {
|
|
338
288
|
const storedValue = localStorage.getItem(key);
|
|
339
289
|
setState(storedValue);
|
|
@@ -341,7 +291,7 @@ function useStorageState(key) {
|
|
|
341
291
|
console.error("Local storage is unavailable:", e);
|
|
342
292
|
}
|
|
343
293
|
}, [key]);
|
|
344
|
-
const setValue = (0,
|
|
294
|
+
const setValue = (0, import_react.useCallback)(
|
|
345
295
|
(value) => {
|
|
346
296
|
setState(value);
|
|
347
297
|
setStorageItemAsync(key, value);
|
|
@@ -354,6 +304,58 @@ function useStorageState(key) {
|
|
|
354
304
|
// src/utils.ts
|
|
355
305
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
356
306
|
|
|
307
|
+
// src/hooks/core/use-call-action.ts
|
|
308
|
+
var useCallAction = () => {
|
|
309
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
310
|
+
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
311
|
+
const queryLoadAction = useLoadAction2();
|
|
312
|
+
const queryRunAction = useRunAction2();
|
|
313
|
+
const [actionData, setActionData] = (0, import_react2.useState)(
|
|
314
|
+
void 0
|
|
315
|
+
);
|
|
316
|
+
const callAction = (0, import_react2.useCallback)(
|
|
317
|
+
async ({
|
|
318
|
+
aid,
|
|
319
|
+
service,
|
|
320
|
+
xNode,
|
|
321
|
+
context
|
|
322
|
+
}) => {
|
|
323
|
+
try {
|
|
324
|
+
const loadRes = await queryLoadAction.mutateAsync({
|
|
325
|
+
idAction: aid,
|
|
326
|
+
context: {
|
|
327
|
+
...env?.context,
|
|
328
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
329
|
+
},
|
|
330
|
+
service,
|
|
331
|
+
xNode
|
|
332
|
+
});
|
|
333
|
+
if (loadRes?.result?.type === "ir.actions.server") {
|
|
334
|
+
const runRes = await queryRunAction.mutateAsync({
|
|
335
|
+
idAction: aid,
|
|
336
|
+
context: {
|
|
337
|
+
...env?.context,
|
|
338
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
339
|
+
},
|
|
340
|
+
service,
|
|
341
|
+
xNode
|
|
342
|
+
});
|
|
343
|
+
setActionData(runRes?.result);
|
|
344
|
+
return runRes?.result;
|
|
345
|
+
} else {
|
|
346
|
+
setActionData(loadRes?.result);
|
|
347
|
+
return loadRes?.result;
|
|
348
|
+
}
|
|
349
|
+
} catch (err) {
|
|
350
|
+
console.error("callAction error:", err);
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
[env?.context?.lang]
|
|
355
|
+
);
|
|
356
|
+
return [actionData, callAction];
|
|
357
|
+
};
|
|
358
|
+
|
|
357
359
|
// src/hooks/core/use-menu.ts
|
|
358
360
|
var useMenu = ({
|
|
359
361
|
context,
|
|
@@ -390,8 +392,7 @@ var useMenu = ({
|
|
|
390
392
|
const handleChangeMenu = async ({
|
|
391
393
|
menu,
|
|
392
394
|
service: service2,
|
|
393
|
-
xNode: xNode2
|
|
394
|
-
context: context2
|
|
395
|
+
xNode: xNode2
|
|
395
396
|
}) => {
|
|
396
397
|
const aidMenu = menu?.action?.id?.id;
|
|
397
398
|
if (menu) {
|
|
@@ -401,8 +402,7 @@ var useMenu = ({
|
|
|
401
402
|
const actionResponse = await callAction({
|
|
402
403
|
aid: Number(aidMenu),
|
|
403
404
|
service: service2 ?? "",
|
|
404
|
-
xNode: xNode2
|
|
405
|
-
context: context2
|
|
405
|
+
xNode: xNode2
|
|
406
406
|
});
|
|
407
407
|
setService(service2 ?? "");
|
|
408
408
|
setXNode(xNode2 ?? "");
|
|
@@ -762,7 +762,7 @@ var useGetSpecification = ({
|
|
|
762
762
|
|
|
763
763
|
// src/hooks/core/use-list-data.ts
|
|
764
764
|
var import_react14 = require("react");
|
|
765
|
-
var
|
|
765
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
766
766
|
|
|
767
767
|
// src/hooks/utils/use-click-outside.ts
|
|
768
768
|
var import_react11 = require("react");
|
|
@@ -903,12 +903,12 @@ var useListData = ({
|
|
|
903
903
|
if (!viewData || !action || !context) {
|
|
904
904
|
return null;
|
|
905
905
|
}
|
|
906
|
-
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0,
|
|
906
|
+
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils6.evalJSONDomain)(action?.domain, context) : [];
|
|
907
907
|
const limit = pageLimit;
|
|
908
908
|
const offset = debouncedPage * pageLimit;
|
|
909
909
|
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
910
910
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
911
|
-
const sort = order ? order : viewData?.views?.list?.default_order ? (0,
|
|
911
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils6.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
912
912
|
return {
|
|
913
913
|
model: action?.res_model,
|
|
914
914
|
specification,
|
|
@@ -930,7 +930,7 @@ var useListData = ({
|
|
|
930
930
|
listDataProps?.offset,
|
|
931
931
|
listDataProps?.sort
|
|
932
932
|
],
|
|
933
|
-
!!listDataProps && !!specification && !(0,
|
|
933
|
+
!!listDataProps && !!specification && !(0, import_utils6.isObjectEmpty)(specification) && !!domain,
|
|
934
934
|
service,
|
|
935
935
|
xNode
|
|
936
936
|
);
|
package/dist/hooks.mjs
CHANGED
|
@@ -96,63 +96,13 @@ import { createContext, useContext, useMemo as useMemo5 } from "react";
|
|
|
96
96
|
import { useMemo, useState as useState2 } from "react";
|
|
97
97
|
|
|
98
98
|
// src/hooks/core/use-call-action.ts
|
|
99
|
-
import { useCallback, useState } from "react";
|
|
99
|
+
import { useCallback as useCallback2, useState } from "react";
|
|
100
100
|
|
|
101
101
|
// src/provider.ts
|
|
102
102
|
var provider_exports = {};
|
|
103
103
|
__reExport(provider_exports, provider_star);
|
|
104
104
|
import * as provider_star from "@fctc/interface-logic/provider";
|
|
105
105
|
|
|
106
|
-
// src/hooks/core/use-call-action.ts
|
|
107
|
-
var useCallAction = () => {
|
|
108
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
109
|
-
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
110
|
-
const queryLoadAction = useLoadAction2();
|
|
111
|
-
const queryRunAction = useRunAction2();
|
|
112
|
-
const [actionData, setActionData] = useState(
|
|
113
|
-
void 0
|
|
114
|
-
);
|
|
115
|
-
const callAction = useCallback(
|
|
116
|
-
async ({
|
|
117
|
-
aid,
|
|
118
|
-
service,
|
|
119
|
-
xNode,
|
|
120
|
-
context
|
|
121
|
-
}) => {
|
|
122
|
-
try {
|
|
123
|
-
const menuContext = {
|
|
124
|
-
...env?.context,
|
|
125
|
-
...context
|
|
126
|
-
};
|
|
127
|
-
const loadRes = await queryLoadAction.mutateAsync({
|
|
128
|
-
idAction: aid,
|
|
129
|
-
context: menuContext,
|
|
130
|
-
service,
|
|
131
|
-
xNode
|
|
132
|
-
});
|
|
133
|
-
if (loadRes?.result?.type === "ir.actions.server") {
|
|
134
|
-
const runRes = await queryRunAction.mutateAsync({
|
|
135
|
-
idAction: aid,
|
|
136
|
-
context: menuContext,
|
|
137
|
-
service,
|
|
138
|
-
xNode
|
|
139
|
-
});
|
|
140
|
-
setActionData(runRes?.result);
|
|
141
|
-
return runRes?.result;
|
|
142
|
-
} else {
|
|
143
|
-
setActionData(loadRes?.result);
|
|
144
|
-
return loadRes?.result;
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
console.error("callAction error:", err);
|
|
148
|
-
return void 0;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
[env?.context?.lang]
|
|
152
|
-
);
|
|
153
|
-
return [actionData, callAction];
|
|
154
|
-
};
|
|
155
|
-
|
|
156
106
|
// src/utils.ts
|
|
157
107
|
var utils_exports = {};
|
|
158
108
|
__export(utils_exports, {
|
|
@@ -174,7 +124,7 @@ var languages = [
|
|
|
174
124
|
];
|
|
175
125
|
|
|
176
126
|
// src/utils/function.ts
|
|
177
|
-
import { useCallback
|
|
127
|
+
import { useCallback, useEffect, useReducer } from "react";
|
|
178
128
|
var countSum = (data, field) => {
|
|
179
129
|
if (!data || !field) return 0;
|
|
180
130
|
return data.reduce(
|
|
@@ -321,7 +271,7 @@ function useStorageState(key) {
|
|
|
321
271
|
console.error("Local storage is unavailable:", e);
|
|
322
272
|
}
|
|
323
273
|
}, [key]);
|
|
324
|
-
const setValue =
|
|
274
|
+
const setValue = useCallback(
|
|
325
275
|
(value) => {
|
|
326
276
|
setState(value);
|
|
327
277
|
setStorageItemAsync(key, value);
|
|
@@ -335,6 +285,58 @@ function useStorageState(key) {
|
|
|
335
285
|
__reExport(utils_exports, utils_star);
|
|
336
286
|
import * as utils_star from "@fctc/interface-logic/utils";
|
|
337
287
|
|
|
288
|
+
// src/hooks/core/use-call-action.ts
|
|
289
|
+
var useCallAction = () => {
|
|
290
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
291
|
+
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
292
|
+
const queryLoadAction = useLoadAction2();
|
|
293
|
+
const queryRunAction = useRunAction2();
|
|
294
|
+
const [actionData, setActionData] = useState(
|
|
295
|
+
void 0
|
|
296
|
+
);
|
|
297
|
+
const callAction = useCallback2(
|
|
298
|
+
async ({
|
|
299
|
+
aid,
|
|
300
|
+
service,
|
|
301
|
+
xNode,
|
|
302
|
+
context
|
|
303
|
+
}) => {
|
|
304
|
+
try {
|
|
305
|
+
const loadRes = await queryLoadAction.mutateAsync({
|
|
306
|
+
idAction: aid,
|
|
307
|
+
context: {
|
|
308
|
+
...env?.context,
|
|
309
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
310
|
+
},
|
|
311
|
+
service,
|
|
312
|
+
xNode
|
|
313
|
+
});
|
|
314
|
+
if (loadRes?.result?.type === "ir.actions.server") {
|
|
315
|
+
const runRes = await queryRunAction.mutateAsync({
|
|
316
|
+
idAction: aid,
|
|
317
|
+
context: {
|
|
318
|
+
...env?.context,
|
|
319
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
320
|
+
},
|
|
321
|
+
service,
|
|
322
|
+
xNode
|
|
323
|
+
});
|
|
324
|
+
setActionData(runRes?.result);
|
|
325
|
+
return runRes?.result;
|
|
326
|
+
} else {
|
|
327
|
+
setActionData(loadRes?.result);
|
|
328
|
+
return loadRes?.result;
|
|
329
|
+
}
|
|
330
|
+
} catch (err) {
|
|
331
|
+
console.error("callAction error:", err);
|
|
332
|
+
return void 0;
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
[env?.context?.lang]
|
|
336
|
+
);
|
|
337
|
+
return [actionData, callAction];
|
|
338
|
+
};
|
|
339
|
+
|
|
338
340
|
// src/hooks/core/use-menu.ts
|
|
339
341
|
var useMenu = ({
|
|
340
342
|
context,
|
|
@@ -371,8 +373,7 @@ var useMenu = ({
|
|
|
371
373
|
const handleChangeMenu = async ({
|
|
372
374
|
menu,
|
|
373
375
|
service: service2,
|
|
374
|
-
xNode: xNode2
|
|
375
|
-
context: context2
|
|
376
|
+
xNode: xNode2
|
|
376
377
|
}) => {
|
|
377
378
|
const aidMenu = menu?.action?.id?.id;
|
|
378
379
|
if (menu) {
|
|
@@ -382,8 +383,7 @@ var useMenu = ({
|
|
|
382
383
|
const actionResponse = await callAction({
|
|
383
384
|
aid: Number(aidMenu),
|
|
384
385
|
service: service2 ?? "",
|
|
385
|
-
xNode: xNode2
|
|
386
|
-
context: context2
|
|
386
|
+
xNode: xNode2
|
|
387
387
|
});
|
|
388
388
|
setService(service2 ?? "");
|
|
389
389
|
setXNode(xNode2 ?? "");
|