@fctc/widget-logic 2.0.4 → 2.0.7
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 -12
- package/dist/hooks.d.ts +1 -12
- package/dist/hooks.js +6 -179
- package/dist/hooks.mjs +2 -179
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +246 -321
- package/dist/index.mjs +158 -237
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widget.d.mts +45 -17
- package/dist/widget.d.ts +45 -17
- package/dist/widget.js +238 -311
- package/dist/widget.mjs +154 -231
- package/package.json +96 -96
package/dist/hooks.d.mts
CHANGED
|
@@ -955,17 +955,6 @@ declare const AppProvider: ({ children }: {
|
|
|
955
955
|
}) => react_jsx_runtime.JSX.Element;
|
|
956
956
|
declare const useAppProvider: () => AppProviderType;
|
|
957
957
|
|
|
958
|
-
interface TActionDetailType {
|
|
959
|
-
id: number;
|
|
960
|
-
res_model: string;
|
|
961
|
-
views: any[][];
|
|
962
|
-
}
|
|
963
|
-
declare const useMenuItem: (props: any) => {
|
|
964
|
-
handleClick: () => void;
|
|
965
|
-
path: string;
|
|
966
|
-
queryActionDetail: TActionDetailType;
|
|
967
|
-
};
|
|
968
|
-
|
|
969
958
|
declare const DEFAULT_EVENTS: readonly ["mousedown", "touchstart"];
|
|
970
959
|
type EventType = (typeof DEFAULT_EVENTS)[number];
|
|
971
960
|
interface UseClickOutsideOptions {
|
|
@@ -978,4 +967,4 @@ declare const useClickOutside: ({ handler, events, nodes, refs, }: UseClickOutsi
|
|
|
978
967
|
|
|
979
968
|
declare function useDebounce<T>(value: T, delay: number): [T];
|
|
980
969
|
|
|
981
|
-
export { type ActionResultType, AppProvider, type ContextProfile, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useListData, type useListDataType, useMenu,
|
|
970
|
+
export { type ActionResultType, AppProvider, type ContextProfile, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useListData, type useListDataType, useMenu, type useMenuType, useProfile, useUser, type useUserType, useViewV2, type useViewV2Type };
|
package/dist/hooks.d.ts
CHANGED
|
@@ -955,17 +955,6 @@ declare const AppProvider: ({ children }: {
|
|
|
955
955
|
}) => react_jsx_runtime.JSX.Element;
|
|
956
956
|
declare const useAppProvider: () => AppProviderType;
|
|
957
957
|
|
|
958
|
-
interface TActionDetailType {
|
|
959
|
-
id: number;
|
|
960
|
-
res_model: string;
|
|
961
|
-
views: any[][];
|
|
962
|
-
}
|
|
963
|
-
declare const useMenuItem: (props: any) => {
|
|
964
|
-
handleClick: () => void;
|
|
965
|
-
path: string;
|
|
966
|
-
queryActionDetail: TActionDetailType;
|
|
967
|
-
};
|
|
968
|
-
|
|
969
958
|
declare const DEFAULT_EVENTS: readonly ["mousedown", "touchstart"];
|
|
970
959
|
type EventType = (typeof DEFAULT_EVENTS)[number];
|
|
971
960
|
interface UseClickOutsideOptions {
|
|
@@ -978,4 +967,4 @@ declare const useClickOutside: ({ handler, events, nodes, refs, }: UseClickOutsi
|
|
|
978
967
|
|
|
979
968
|
declare function useDebounce<T>(value: T, delay: number): [T];
|
|
980
969
|
|
|
981
|
-
export { type ActionResultType, AppProvider, type ContextProfile, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useListData, type useListDataType, useMenu,
|
|
970
|
+
export { type ActionResultType, AppProvider, type ContextProfile, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useListData, type useListDataType, useMenu, type useMenuType, useProfile, useUser, type useUserType, useViewV2, type useViewV2Type };
|
package/dist/hooks.js
CHANGED
|
@@ -31,7 +31,6 @@ __export(hooks_exports, {
|
|
|
31
31
|
useDetail: () => useDetail,
|
|
32
32
|
useListData: () => useListData,
|
|
33
33
|
useMenu: () => useMenu,
|
|
34
|
-
useMenuItem: () => useMenuItem,
|
|
35
34
|
useProfile: () => useProfile,
|
|
36
35
|
useUser: () => useUser,
|
|
37
36
|
useViewV2: () => useViewV2
|
|
@@ -163,109 +162,6 @@ var store_exports = {};
|
|
|
163
162
|
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
164
163
|
|
|
165
164
|
// src/utils/function.ts
|
|
166
|
-
var countSum = (data, field) => {
|
|
167
|
-
if (!data || !field) return 0;
|
|
168
|
-
return data.reduce(
|
|
169
|
-
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
170
|
-
0
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
function mergeButtons(fields) {
|
|
174
|
-
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
175
|
-
const others = fields?.filter((f) => f.type_co !== "button");
|
|
176
|
-
if (buttons?.length) {
|
|
177
|
-
others.push({
|
|
178
|
-
type_co: "buttons",
|
|
179
|
-
buttons
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
return others;
|
|
183
|
-
}
|
|
184
|
-
function isElementVisible(el) {
|
|
185
|
-
const style = window.getComputedStyle(el);
|
|
186
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
187
|
-
}
|
|
188
|
-
function arraysAreEqual(a, b) {
|
|
189
|
-
if (a.length !== b.length) return false;
|
|
190
|
-
const setA = new Set(a);
|
|
191
|
-
const setB = new Set(b);
|
|
192
|
-
if (setA.size !== setB.size) return false;
|
|
193
|
-
for (const val of setA) {
|
|
194
|
-
if (!setB.has(val)) return false;
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
function useGetRowIds(tableRef) {
|
|
199
|
-
const [rowIds, setRowIds] = (0, import_react4.useState)([]);
|
|
200
|
-
const lastRowIdsRef = (0, import_react4.useRef)([]);
|
|
201
|
-
const updateVisibleRowIds = (0, import_react4.useCallback)(() => {
|
|
202
|
-
const table = tableRef?.current;
|
|
203
|
-
if (!table) return;
|
|
204
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
205
|
-
const ids = [];
|
|
206
|
-
rows.forEach((row) => {
|
|
207
|
-
const el = row;
|
|
208
|
-
if (isElementVisible(el)) {
|
|
209
|
-
const id = el.getAttribute("data-row-id");
|
|
210
|
-
if (id) ids.push(id);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
214
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
215
|
-
lastRowIdsRef.current = uniqueIds;
|
|
216
|
-
setRowIds(uniqueIds);
|
|
217
|
-
}
|
|
218
|
-
}, [tableRef]);
|
|
219
|
-
(0, import_react4.useEffect)(() => {
|
|
220
|
-
const table = tableRef?.current;
|
|
221
|
-
if (!table) return;
|
|
222
|
-
const observer = new MutationObserver(() => {
|
|
223
|
-
updateVisibleRowIds();
|
|
224
|
-
});
|
|
225
|
-
observer.observe(table, {
|
|
226
|
-
childList: true,
|
|
227
|
-
subtree: true,
|
|
228
|
-
attributes: true,
|
|
229
|
-
attributeFilter: ["style", "class"]
|
|
230
|
-
});
|
|
231
|
-
updateVisibleRowIds();
|
|
232
|
-
return () => {
|
|
233
|
-
observer.disconnect();
|
|
234
|
-
};
|
|
235
|
-
}, [updateVisibleRowIds, tableRef]);
|
|
236
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
237
|
-
}
|
|
238
|
-
var useSelectionState = ({
|
|
239
|
-
typeTable,
|
|
240
|
-
tableRef,
|
|
241
|
-
rows
|
|
242
|
-
}) => {
|
|
243
|
-
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
244
|
-
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
245
|
-
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
246
|
-
const selectedRowKeysRef = (0, import_react4.useRef)(recordIds);
|
|
247
|
-
const isGroupTable = typeTable === "group";
|
|
248
|
-
const recordsCheckedGroup = (0, import_react4.useMemo)(() => {
|
|
249
|
-
if (!rows || !groupByDomain) return 0;
|
|
250
|
-
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
251
|
-
return countSum(rows, groupBy);
|
|
252
|
-
}, [rows, groupByDomain]);
|
|
253
|
-
const isAllGroupChecked = (0, import_react4.useMemo)(() => {
|
|
254
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
255
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
256
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
257
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
258
|
-
return allGroupsSelected || allRecordsSelected;
|
|
259
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
260
|
-
const isAllNormalChecked = (0, import_react4.useMemo)(() => {
|
|
261
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
262
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
263
|
-
(id) => rows.some((record) => record.id === id)
|
|
264
|
-
);
|
|
265
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
266
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
267
|
-
return { checkedAll, selectedRowKeysRef };
|
|
268
|
-
};
|
|
269
165
|
var getDateRange = (currentDate, unit) => {
|
|
270
166
|
const date = new Date(currentDate);
|
|
271
167
|
let dateStart, dateEnd;
|
|
@@ -363,10 +259,6 @@ function combineContexts(contexts) {
|
|
|
363
259
|
return res;
|
|
364
260
|
}
|
|
365
261
|
}
|
|
366
|
-
var STORAGES = {
|
|
367
|
-
TOKEN: "accessToken",
|
|
368
|
-
USER_INFO: "USER_INFO"
|
|
369
|
-
};
|
|
370
262
|
function useAsyncState(initialValue = [true, null]) {
|
|
371
263
|
return (0, import_react4.useReducer)(
|
|
372
264
|
(_state, action = null) => [false, action],
|
|
@@ -487,9 +379,6 @@ var languages = [
|
|
|
487
379
|
{ id: "vi_VN", name: "VIE" },
|
|
488
380
|
{ id: "en_US", name: "ENG" }
|
|
489
381
|
];
|
|
490
|
-
var API_PRESCHOOL_URL = {
|
|
491
|
-
baseURL: "https://preschool.vitrust.app"
|
|
492
|
-
};
|
|
493
382
|
var API_APP_URL = {
|
|
494
383
|
baseUrl: "https://api.vitrust.app",
|
|
495
384
|
c2: "https://api.vitrust.app/c2",
|
|
@@ -792,69 +681,8 @@ var useAppProvider = () => {
|
|
|
792
681
|
return context;
|
|
793
682
|
};
|
|
794
683
|
|
|
795
|
-
// src/hooks/core/use-menu-item.tsx
|
|
796
|
-
var import_environment5 = require("@fctc/interface-logic/environment");
|
|
797
|
-
var import_hooks9 = require("@fctc/interface-logic/hooks");
|
|
798
|
-
var import_react11 = require("react");
|
|
799
|
-
|
|
800
|
-
// src/utils.ts
|
|
801
|
-
var utils_exports = {};
|
|
802
|
-
__export(utils_exports, {
|
|
803
|
-
API_APP_URL: () => API_APP_URL,
|
|
804
|
-
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
805
|
-
STORAGES: () => STORAGES,
|
|
806
|
-
combineContexts: () => combineContexts,
|
|
807
|
-
convertFieldsToArray: () => convertFieldsToArray,
|
|
808
|
-
countSum: () => countSum,
|
|
809
|
-
getDateRange: () => getDateRange,
|
|
810
|
-
languages: () => languages,
|
|
811
|
-
mergeButtons: () => mergeButtons,
|
|
812
|
-
setStorageItemAsync: () => setStorageItemAsync,
|
|
813
|
-
useGetRowIds: () => useGetRowIds,
|
|
814
|
-
useSelectionState: () => useSelectionState,
|
|
815
|
-
useStorageState: () => useStorageState
|
|
816
|
-
});
|
|
817
|
-
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
818
|
-
|
|
819
|
-
// src/hooks/core/use-menu-item.tsx
|
|
820
|
-
var useMenuItem = (props) => {
|
|
821
|
-
const { menu, activeMenuId } = props;
|
|
822
|
-
const model = menu?.action?.res_model;
|
|
823
|
-
const aid = menu?.action?.id?.id;
|
|
824
|
-
const id = menu?.id;
|
|
825
|
-
const context = (0, import_environment5.getEnv)().context;
|
|
826
|
-
const queryActionDetail = (0, import_hooks9.useGetActionDetail)({
|
|
827
|
-
aid,
|
|
828
|
-
id,
|
|
829
|
-
model,
|
|
830
|
-
context,
|
|
831
|
-
enabled: true,
|
|
832
|
-
queryKey: [`action-${aid}`]
|
|
833
|
-
}).data;
|
|
834
|
-
const [path, setPath] = (0, import_react11.useState)("");
|
|
835
|
-
const handleClick = () => {
|
|
836
|
-
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
const hasListView = queryActionDetail.views.some(
|
|
840
|
-
([id2, type]) => type === "list"
|
|
841
|
-
);
|
|
842
|
-
const viewType = hasListView ? "list" : "form";
|
|
843
|
-
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
844
|
-
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
845
|
-
const path2 = (0, utils_exports.formatUrlPath)({
|
|
846
|
-
viewType,
|
|
847
|
-
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
848
|
-
aid: menu?.action?.id?.id,
|
|
849
|
-
model: queryActionDetail.res_model
|
|
850
|
-
});
|
|
851
|
-
setPath(path2);
|
|
852
|
-
};
|
|
853
|
-
return { handleClick, path, queryActionDetail };
|
|
854
|
-
};
|
|
855
|
-
|
|
856
684
|
// src/hooks/utils/use-click-outside.ts
|
|
857
|
-
var
|
|
685
|
+
var import_react11 = require("react");
|
|
858
686
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
859
687
|
var useClickOutside = ({
|
|
860
688
|
handler,
|
|
@@ -862,8 +690,8 @@ var useClickOutside = ({
|
|
|
862
690
|
nodes = [],
|
|
863
691
|
refs
|
|
864
692
|
}) => {
|
|
865
|
-
const ref = (0,
|
|
866
|
-
(0,
|
|
693
|
+
const ref = (0, import_react11.useRef)(null);
|
|
694
|
+
(0, import_react11.useEffect)(() => {
|
|
867
695
|
const listener = (event) => {
|
|
868
696
|
const { target } = event;
|
|
869
697
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -885,10 +713,10 @@ var useClickOutside = ({
|
|
|
885
713
|
};
|
|
886
714
|
|
|
887
715
|
// src/hooks/utils/use-debounce.ts
|
|
888
|
-
var
|
|
716
|
+
var import_react12 = require("react");
|
|
889
717
|
function useDebounce(value, delay) {
|
|
890
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
891
|
-
(0,
|
|
718
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react12.useState)(value);
|
|
719
|
+
(0, import_react12.useEffect)(() => {
|
|
892
720
|
const handler = setTimeout(() => {
|
|
893
721
|
setDebouncedValue(value);
|
|
894
722
|
}, delay);
|
|
@@ -913,7 +741,6 @@ __reExport(hooks_exports, require("@fctc/interface-logic/hooks"), module.exports
|
|
|
913
741
|
useDetail,
|
|
914
742
|
useListData,
|
|
915
743
|
useMenu,
|
|
916
|
-
useMenuItem,
|
|
917
744
|
useProfile,
|
|
918
745
|
useUser,
|
|
919
746
|
useViewV2,
|
package/dist/hooks.mjs
CHANGED
|
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
5
|
var __copyProps = (to, from, except, desc) => {
|
|
10
6
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
7
|
for (let key of __getOwnPropNames(from))
|
|
@@ -149,109 +145,6 @@ __reExport(store_exports, store_star);
|
|
|
149
145
|
import * as store_star from "@fctc/interface-logic/store";
|
|
150
146
|
|
|
151
147
|
// src/utils/function.ts
|
|
152
|
-
var countSum = (data, field) => {
|
|
153
|
-
if (!data || !field) return 0;
|
|
154
|
-
return data.reduce(
|
|
155
|
-
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
156
|
-
0
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
function mergeButtons(fields) {
|
|
160
|
-
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
161
|
-
const others = fields?.filter((f) => f.type_co !== "button");
|
|
162
|
-
if (buttons?.length) {
|
|
163
|
-
others.push({
|
|
164
|
-
type_co: "buttons",
|
|
165
|
-
buttons
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return others;
|
|
169
|
-
}
|
|
170
|
-
function isElementVisible(el) {
|
|
171
|
-
const style = window.getComputedStyle(el);
|
|
172
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
173
|
-
}
|
|
174
|
-
function arraysAreEqual(a, b) {
|
|
175
|
-
if (a.length !== b.length) return false;
|
|
176
|
-
const setA = new Set(a);
|
|
177
|
-
const setB = new Set(b);
|
|
178
|
-
if (setA.size !== setB.size) return false;
|
|
179
|
-
for (const val of setA) {
|
|
180
|
-
if (!setB.has(val)) return false;
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
function useGetRowIds(tableRef) {
|
|
185
|
-
const [rowIds, setRowIds] = useState2([]);
|
|
186
|
-
const lastRowIdsRef = useRef([]);
|
|
187
|
-
const updateVisibleRowIds = useCallback(() => {
|
|
188
|
-
const table = tableRef?.current;
|
|
189
|
-
if (!table) return;
|
|
190
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
191
|
-
const ids = [];
|
|
192
|
-
rows.forEach((row) => {
|
|
193
|
-
const el = row;
|
|
194
|
-
if (isElementVisible(el)) {
|
|
195
|
-
const id = el.getAttribute("data-row-id");
|
|
196
|
-
if (id) ids.push(id);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
200
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
201
|
-
lastRowIdsRef.current = uniqueIds;
|
|
202
|
-
setRowIds(uniqueIds);
|
|
203
|
-
}
|
|
204
|
-
}, [tableRef]);
|
|
205
|
-
useEffect3(() => {
|
|
206
|
-
const table = tableRef?.current;
|
|
207
|
-
if (!table) return;
|
|
208
|
-
const observer = new MutationObserver(() => {
|
|
209
|
-
updateVisibleRowIds();
|
|
210
|
-
});
|
|
211
|
-
observer.observe(table, {
|
|
212
|
-
childList: true,
|
|
213
|
-
subtree: true,
|
|
214
|
-
attributes: true,
|
|
215
|
-
attributeFilter: ["style", "class"]
|
|
216
|
-
});
|
|
217
|
-
updateVisibleRowIds();
|
|
218
|
-
return () => {
|
|
219
|
-
observer.disconnect();
|
|
220
|
-
};
|
|
221
|
-
}, [updateVisibleRowIds, tableRef]);
|
|
222
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
223
|
-
}
|
|
224
|
-
var useSelectionState = ({
|
|
225
|
-
typeTable,
|
|
226
|
-
tableRef,
|
|
227
|
-
rows
|
|
228
|
-
}) => {
|
|
229
|
-
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
230
|
-
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
231
|
-
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
232
|
-
const selectedRowKeysRef = useRef(recordIds);
|
|
233
|
-
const isGroupTable = typeTable === "group";
|
|
234
|
-
const recordsCheckedGroup = useMemo2(() => {
|
|
235
|
-
if (!rows || !groupByDomain) return 0;
|
|
236
|
-
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
237
|
-
return countSum(rows, groupBy);
|
|
238
|
-
}, [rows, groupByDomain]);
|
|
239
|
-
const isAllGroupChecked = useMemo2(() => {
|
|
240
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
241
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
242
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
243
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
244
|
-
return allGroupsSelected || allRecordsSelected;
|
|
245
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
246
|
-
const isAllNormalChecked = useMemo2(() => {
|
|
247
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
248
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
249
|
-
(id) => rows.some((record) => record.id === id)
|
|
250
|
-
);
|
|
251
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
252
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
253
|
-
return { checkedAll, selectedRowKeysRef };
|
|
254
|
-
};
|
|
255
148
|
var getDateRange = (currentDate, unit) => {
|
|
256
149
|
const date = new Date(currentDate);
|
|
257
150
|
let dateStart, dateEnd;
|
|
@@ -349,10 +242,6 @@ function combineContexts(contexts) {
|
|
|
349
242
|
return res;
|
|
350
243
|
}
|
|
351
244
|
}
|
|
352
|
-
var STORAGES = {
|
|
353
|
-
TOKEN: "accessToken",
|
|
354
|
-
USER_INFO: "USER_INFO"
|
|
355
|
-
};
|
|
356
245
|
function useAsyncState(initialValue = [true, null]) {
|
|
357
246
|
return useReducer(
|
|
358
247
|
(_state, action = null) => [false, action],
|
|
@@ -480,9 +369,6 @@ var languages = [
|
|
|
480
369
|
{ id: "vi_VN", name: "VIE" },
|
|
481
370
|
{ id: "en_US", name: "ENG" }
|
|
482
371
|
];
|
|
483
|
-
var API_PRESCHOOL_URL = {
|
|
484
|
-
baseURL: "https://preschool.vitrust.app"
|
|
485
|
-
};
|
|
486
372
|
var API_APP_URL = {
|
|
487
373
|
baseUrl: "https://api.vitrust.app",
|
|
488
374
|
c2: "https://api.vitrust.app/c2",
|
|
@@ -793,68 +679,6 @@ var useAppProvider = () => {
|
|
|
793
679
|
return context;
|
|
794
680
|
};
|
|
795
681
|
|
|
796
|
-
// src/hooks/core/use-menu-item.tsx
|
|
797
|
-
import { getEnv as getEnv5 } from "@fctc/interface-logic/environment";
|
|
798
|
-
import { useGetActionDetail } from "@fctc/interface-logic/hooks";
|
|
799
|
-
import { useState as useState5 } from "react";
|
|
800
|
-
|
|
801
|
-
// src/utils.ts
|
|
802
|
-
var utils_exports = {};
|
|
803
|
-
__export(utils_exports, {
|
|
804
|
-
API_APP_URL: () => API_APP_URL,
|
|
805
|
-
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
806
|
-
STORAGES: () => STORAGES,
|
|
807
|
-
combineContexts: () => combineContexts,
|
|
808
|
-
convertFieldsToArray: () => convertFieldsToArray,
|
|
809
|
-
countSum: () => countSum,
|
|
810
|
-
getDateRange: () => getDateRange,
|
|
811
|
-
languages: () => languages,
|
|
812
|
-
mergeButtons: () => mergeButtons,
|
|
813
|
-
setStorageItemAsync: () => setStorageItemAsync,
|
|
814
|
-
useGetRowIds: () => useGetRowIds,
|
|
815
|
-
useSelectionState: () => useSelectionState,
|
|
816
|
-
useStorageState: () => useStorageState
|
|
817
|
-
});
|
|
818
|
-
__reExport(utils_exports, utils_star);
|
|
819
|
-
import * as utils_star from "@fctc/interface-logic/utils";
|
|
820
|
-
|
|
821
|
-
// src/hooks/core/use-menu-item.tsx
|
|
822
|
-
var useMenuItem = (props) => {
|
|
823
|
-
const { menu, activeMenuId } = props;
|
|
824
|
-
const model = menu?.action?.res_model;
|
|
825
|
-
const aid = menu?.action?.id?.id;
|
|
826
|
-
const id = menu?.id;
|
|
827
|
-
const context = getEnv5().context;
|
|
828
|
-
const queryActionDetail = useGetActionDetail({
|
|
829
|
-
aid,
|
|
830
|
-
id,
|
|
831
|
-
model,
|
|
832
|
-
context,
|
|
833
|
-
enabled: true,
|
|
834
|
-
queryKey: [`action-${aid}`]
|
|
835
|
-
}).data;
|
|
836
|
-
const [path, setPath] = useState5("");
|
|
837
|
-
const handleClick = () => {
|
|
838
|
-
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
const hasListView = queryActionDetail.views.some(
|
|
842
|
-
([id2, type]) => type === "list"
|
|
843
|
-
);
|
|
844
|
-
const viewType = hasListView ? "list" : "form";
|
|
845
|
-
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
846
|
-
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
847
|
-
const path2 = (0, utils_exports.formatUrlPath)({
|
|
848
|
-
viewType,
|
|
849
|
-
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
850
|
-
aid: menu?.action?.id?.id,
|
|
851
|
-
model: queryActionDetail.res_model
|
|
852
|
-
});
|
|
853
|
-
setPath(path2);
|
|
854
|
-
};
|
|
855
|
-
return { handleClick, path, queryActionDetail };
|
|
856
|
-
};
|
|
857
|
-
|
|
858
682
|
// src/hooks/utils/use-click-outside.ts
|
|
859
683
|
import { useEffect as useEffect7, useRef as useRef2 } from "react";
|
|
860
684
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
@@ -887,9 +711,9 @@ var useClickOutside = ({
|
|
|
887
711
|
};
|
|
888
712
|
|
|
889
713
|
// src/hooks/utils/use-debounce.ts
|
|
890
|
-
import { useEffect as useEffect8, useState as
|
|
714
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
|
891
715
|
function useDebounce(value, delay) {
|
|
892
|
-
const [debouncedValue, setDebouncedValue] =
|
|
716
|
+
const [debouncedValue, setDebouncedValue] = useState5(value);
|
|
893
717
|
useEffect8(() => {
|
|
894
718
|
const handler = setTimeout(() => {
|
|
895
719
|
setDebouncedValue(value);
|
|
@@ -914,7 +738,6 @@ export {
|
|
|
914
738
|
useDetail,
|
|
915
739
|
useListData,
|
|
916
740
|
useMenu,
|
|
917
|
-
useMenuItem,
|
|
918
741
|
useProfile,
|
|
919
742
|
useUser,
|
|
920
743
|
useViewV2
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ActionResultType, AppProvider, ContextProfile, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useListData, useListDataType, useMenu,
|
|
1
|
+
export { ActionResultType, AppProvider, ContextProfile, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useListData, useListDataType, useMenu, useMenuType, useProfile, useUser, useUserType, useViewV2, useViewV2Type } from './hooks.mjs';
|
|
2
2
|
export * from '@fctc/interface-logic/hooks';
|
|
3
3
|
export * from '@fctc/interface-logic/configs';
|
|
4
4
|
export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon } from './icons.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ActionResultType, AppProvider, ContextProfile, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useListData, useListDataType, useMenu,
|
|
1
|
+
export { ActionResultType, AppProvider, ContextProfile, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useListData, useListDataType, useMenu, useMenuType, useProfile, useUser, useUserType, useViewV2, useViewV2Type } from './hooks.js';
|
|
2
2
|
export * from '@fctc/interface-logic/hooks';
|
|
3
3
|
export * from '@fctc/interface-logic/configs';
|
|
4
4
|
export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIcon, LoadingIcon, SearchIcon } from './icons.js';
|