@fctc/widget-logic 3.0.4 → 3.0.6
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 +3 -1
- package/dist/hooks.d.ts +3 -1
- package/dist/hooks.js +63 -63
- package/dist/hooks.mjs +57 -57
- package/dist/index.js +144 -157
- package/dist/index.mjs +150 -167
- package/dist/widget.d.mts +17 -11
- package/dist/widget.d.ts +17 -11
- package/dist/widget.js +172 -100
- package/dist/widget.mjs +181 -113
- package/package.json +96 -96
package/dist/hooks.d.mts
CHANGED
|
@@ -56,6 +56,7 @@ interface RecordMenu {
|
|
|
56
56
|
};
|
|
57
57
|
res_model: string;
|
|
58
58
|
type: string;
|
|
59
|
+
context: string;
|
|
59
60
|
};
|
|
60
61
|
active: boolean;
|
|
61
62
|
child_id?: RecordMenu[];
|
|
@@ -74,10 +75,11 @@ interface RecordMenu {
|
|
|
74
75
|
interface UseMenuReturn {
|
|
75
76
|
data: RecordMenu[] | undefined;
|
|
76
77
|
action: {
|
|
77
|
-
handleChangeMenu: ({ menu, service, xNode, }: {
|
|
78
|
+
handleChangeMenu: ({ menu, service, xNode, context, }: {
|
|
78
79
|
menu?: RecordMenu;
|
|
79
80
|
service?: string;
|
|
80
81
|
xNode?: string;
|
|
82
|
+
context?: any;
|
|
81
83
|
}) => Promise<any>;
|
|
82
84
|
};
|
|
83
85
|
state: {
|
package/dist/hooks.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ interface RecordMenu {
|
|
|
56
56
|
};
|
|
57
57
|
res_model: string;
|
|
58
58
|
type: string;
|
|
59
|
+
context: string;
|
|
59
60
|
};
|
|
60
61
|
active: boolean;
|
|
61
62
|
child_id?: RecordMenu[];
|
|
@@ -74,10 +75,11 @@ interface RecordMenu {
|
|
|
74
75
|
interface UseMenuReturn {
|
|
75
76
|
data: RecordMenu[] | undefined;
|
|
76
77
|
action: {
|
|
77
|
-
handleChangeMenu: ({ menu, service, xNode, }: {
|
|
78
|
+
handleChangeMenu: ({ menu, service, xNode, context, }: {
|
|
78
79
|
menu?: RecordMenu;
|
|
79
80
|
service?: string;
|
|
80
81
|
xNode?: string;
|
|
82
|
+
context?: any;
|
|
81
83
|
}) => Promise<any>;
|
|
82
84
|
};
|
|
83
85
|
state: {
|
package/dist/hooks.js
CHANGED
|
@@ -117,12 +117,62 @@ 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_react = 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
|
+
|
|
126
176
|
// src/utils.ts
|
|
127
177
|
var utils_exports = {};
|
|
128
178
|
__export(utils_exports, {
|
|
@@ -144,7 +194,7 @@ var languages = [
|
|
|
144
194
|
];
|
|
145
195
|
|
|
146
196
|
// src/utils/function.ts
|
|
147
|
-
var
|
|
197
|
+
var import_react2 = require("react");
|
|
148
198
|
var countSum = (data, field) => {
|
|
149
199
|
if (!data || !field) return 0;
|
|
150
200
|
return data.reduce(
|
|
@@ -265,7 +315,7 @@ var STORAGES = {
|
|
|
265
315
|
USER_INFO: "USER_INFO"
|
|
266
316
|
};
|
|
267
317
|
function useAsyncState(initialValue = [true, null]) {
|
|
268
|
-
return (0,
|
|
318
|
+
return (0, import_react2.useReducer)(
|
|
269
319
|
(_state, action = null) => [false, action],
|
|
270
320
|
initialValue
|
|
271
321
|
);
|
|
@@ -283,7 +333,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
283
333
|
}
|
|
284
334
|
function useStorageState(key) {
|
|
285
335
|
const [state, setState] = useAsyncState();
|
|
286
|
-
(0,
|
|
336
|
+
(0, import_react2.useEffect)(() => {
|
|
287
337
|
try {
|
|
288
338
|
const storedValue = localStorage.getItem(key);
|
|
289
339
|
setState(storedValue);
|
|
@@ -291,7 +341,7 @@ function useStorageState(key) {
|
|
|
291
341
|
console.error("Local storage is unavailable:", e);
|
|
292
342
|
}
|
|
293
343
|
}, [key]);
|
|
294
|
-
const setValue = (0,
|
|
344
|
+
const setValue = (0, import_react2.useCallback)(
|
|
295
345
|
(value) => {
|
|
296
346
|
setState(value);
|
|
297
347
|
setStorageItemAsync(key, value);
|
|
@@ -304,58 +354,6 @@ function useStorageState(key) {
|
|
|
304
354
|
// src/utils.ts
|
|
305
355
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
306
356
|
|
|
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
|
-
|
|
359
357
|
// src/hooks/core/use-menu.ts
|
|
360
358
|
var useMenu = ({
|
|
361
359
|
context,
|
|
@@ -392,7 +390,8 @@ var useMenu = ({
|
|
|
392
390
|
const handleChangeMenu = async ({
|
|
393
391
|
menu,
|
|
394
392
|
service: service2,
|
|
395
|
-
xNode: xNode2
|
|
393
|
+
xNode: xNode2,
|
|
394
|
+
context: context2
|
|
396
395
|
}) => {
|
|
397
396
|
const aidMenu = menu?.action?.id?.id;
|
|
398
397
|
if (menu) {
|
|
@@ -402,7 +401,8 @@ var useMenu = ({
|
|
|
402
401
|
const actionResponse = await callAction({
|
|
403
402
|
aid: Number(aidMenu),
|
|
404
403
|
service: service2 ?? "",
|
|
405
|
-
xNode: xNode2
|
|
404
|
+
xNode: xNode2,
|
|
405
|
+
context: context2
|
|
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_utils5 = 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_utils5.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_utils5.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_utils5.isObjectEmpty)(specification) && !!domain,
|
|
934
934
|
service,
|
|
935
935
|
xNode
|
|
936
936
|
);
|
package/dist/hooks.mjs
CHANGED
|
@@ -96,13 +96,63 @@ 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
|
|
99
|
+
import { useCallback, 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
|
+
|
|
106
156
|
// src/utils.ts
|
|
107
157
|
var utils_exports = {};
|
|
108
158
|
__export(utils_exports, {
|
|
@@ -124,7 +174,7 @@ var languages = [
|
|
|
124
174
|
];
|
|
125
175
|
|
|
126
176
|
// src/utils/function.ts
|
|
127
|
-
import { useCallback, useEffect, useReducer } from "react";
|
|
177
|
+
import { useCallback as useCallback2, useEffect, useReducer } from "react";
|
|
128
178
|
var countSum = (data, field) => {
|
|
129
179
|
if (!data || !field) return 0;
|
|
130
180
|
return data.reduce(
|
|
@@ -271,7 +321,7 @@ function useStorageState(key) {
|
|
|
271
321
|
console.error("Local storage is unavailable:", e);
|
|
272
322
|
}
|
|
273
323
|
}, [key]);
|
|
274
|
-
const setValue =
|
|
324
|
+
const setValue = useCallback2(
|
|
275
325
|
(value) => {
|
|
276
326
|
setState(value);
|
|
277
327
|
setStorageItemAsync(key, value);
|
|
@@ -285,58 +335,6 @@ function useStorageState(key) {
|
|
|
285
335
|
__reExport(utils_exports, utils_star);
|
|
286
336
|
import * as utils_star from "@fctc/interface-logic/utils";
|
|
287
337
|
|
|
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
|
-
|
|
340
338
|
// src/hooks/core/use-menu.ts
|
|
341
339
|
var useMenu = ({
|
|
342
340
|
context,
|
|
@@ -373,7 +371,8 @@ var useMenu = ({
|
|
|
373
371
|
const handleChangeMenu = async ({
|
|
374
372
|
menu,
|
|
375
373
|
service: service2,
|
|
376
|
-
xNode: xNode2
|
|
374
|
+
xNode: xNode2,
|
|
375
|
+
context: context2
|
|
377
376
|
}) => {
|
|
378
377
|
const aidMenu = menu?.action?.id?.id;
|
|
379
378
|
if (menu) {
|
|
@@ -383,7 +382,8 @@ var useMenu = ({
|
|
|
383
382
|
const actionResponse = await callAction({
|
|
384
383
|
aid: Number(aidMenu),
|
|
385
384
|
service: service2 ?? "",
|
|
386
|
-
xNode: xNode2
|
|
385
|
+
xNode: xNode2,
|
|
386
|
+
context: context2
|
|
387
387
|
});
|
|
388
388
|
setService(service2 ?? "");
|
|
389
389
|
setXNode(xNode2 ?? "");
|