@fctc/widget-logic 1.8.2 → 1.8.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/hooks.js +17 -11
- package/dist/hooks.mjs +48 -20
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +88 -52
- package/dist/index.mjs +103 -60
- package/dist/utils.d.mts +10 -1
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +39 -0
- package/dist/utils.mjs +61 -1
- package/dist/widget.d.mts +1 -1
- package/dist/widget.d.ts +1 -1
- package/dist/widget.js +50 -48
- package/dist/widget.mjs +62 -53
- package/package.json +1 -1
package/dist/hooks.js
CHANGED
|
@@ -156,6 +156,12 @@ var import_react5 = require("react");
|
|
|
156
156
|
|
|
157
157
|
// src/utils/function.ts
|
|
158
158
|
var import_react4 = require("react");
|
|
159
|
+
|
|
160
|
+
// src/store.ts
|
|
161
|
+
var store_exports = {};
|
|
162
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
163
|
+
|
|
164
|
+
// src/utils/function.ts
|
|
159
165
|
var getDateRange = (currentDate, unit) => {
|
|
160
166
|
const date = new Date(currentDate);
|
|
161
167
|
let dateStart, dateEnd;
|
|
@@ -292,19 +298,19 @@ function useStorageState(key) {
|
|
|
292
298
|
|
|
293
299
|
// src/hooks/core/use-list-data.ts
|
|
294
300
|
var import_hooks3 = require("@fctc/interface-logic/hooks");
|
|
295
|
-
var
|
|
301
|
+
var import_store4 = require("@fctc/interface-logic/store");
|
|
296
302
|
var import_utils = require("@fctc/interface-logic/utils");
|
|
297
303
|
var useListData = ({
|
|
298
304
|
action,
|
|
299
305
|
context,
|
|
300
306
|
viewResponse
|
|
301
307
|
}) => {
|
|
302
|
-
const { groupByDomain } = (0,
|
|
308
|
+
const { groupByDomain } = (0, import_store4.useAppSelector)(import_store4.selectSearch);
|
|
303
309
|
const initModel = (0, import_hooks3.useModel)();
|
|
304
310
|
const [type, setType] = (0, import_react5.useState)("list");
|
|
305
311
|
const [mode, setMode] = (0, import_react5.useState)("month");
|
|
306
312
|
const [currentDate, setCurrentDate] = (0, import_react5.useState)(/* @__PURE__ */ new Date());
|
|
307
|
-
const { pageLimit, page, order } = (0,
|
|
313
|
+
const { pageLimit, page, order } = (0, import_store4.useAppSelector)(import_store4.selectList);
|
|
308
314
|
const listDataProps = (0, import_react5.useMemo)(() => {
|
|
309
315
|
const actData = action?.result;
|
|
310
316
|
if (!viewResponse || !actData || !context) {
|
|
@@ -436,10 +442,10 @@ var import_react7 = require("react");
|
|
|
436
442
|
var import_react_i18next = require("react-i18next");
|
|
437
443
|
var import_environment3 = require("@fctc/interface-logic/environment");
|
|
438
444
|
var import_hooks5 = require("@fctc/interface-logic/hooks");
|
|
439
|
-
var
|
|
445
|
+
var import_store5 = require("@fctc/interface-logic/store");
|
|
440
446
|
var useProfile = (accessToken) => {
|
|
441
447
|
const getProfile = (0, import_hooks5.useGetProfile)();
|
|
442
|
-
const dispatch = (0,
|
|
448
|
+
const dispatch = (0, import_store5.useAppDispatch)();
|
|
443
449
|
const { i18n } = (0, import_react_i18next.useTranslation)();
|
|
444
450
|
const fetchUserProfile = async () => {
|
|
445
451
|
return await getProfile.mutateAsync();
|
|
@@ -454,7 +460,7 @@ var useProfile = (accessToken) => {
|
|
|
454
460
|
const userInfo = userInfoQuery.data;
|
|
455
461
|
const env = (0, import_environment3.getEnv)();
|
|
456
462
|
env.setUid(userInfo?.sub);
|
|
457
|
-
dispatch((0,
|
|
463
|
+
dispatch((0, import_store5.setDataUser)(userInfo));
|
|
458
464
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
459
465
|
env.setLang(userLocale?.id);
|
|
460
466
|
i18n.changeLanguage(userLocale?.id.split("_")[0]);
|
|
@@ -519,11 +525,11 @@ var useViewV2 = ({
|
|
|
519
525
|
|
|
520
526
|
// src/hooks/core/use-auth.ts
|
|
521
527
|
var import_hooks7 = require("@fctc/interface-logic/hooks");
|
|
522
|
-
var
|
|
528
|
+
var import_store6 = require("@fctc/interface-logic/store");
|
|
523
529
|
var useAuth = () => {
|
|
524
530
|
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
525
531
|
const loginMutate = (0, import_hooks7.useLoginCredential)();
|
|
526
|
-
const dispatch = (0,
|
|
532
|
+
const dispatch = (0, import_store6.useAppDispatch)();
|
|
527
533
|
const signIn = async (email, password) => {
|
|
528
534
|
try {
|
|
529
535
|
loginMutate.mutate(
|
|
@@ -544,9 +550,9 @@ var useAuth = () => {
|
|
|
544
550
|
}
|
|
545
551
|
};
|
|
546
552
|
const signOut = async () => {
|
|
547
|
-
dispatch((0,
|
|
548
|
-
dispatch((0,
|
|
549
|
-
dispatch((0,
|
|
553
|
+
dispatch((0, import_store6.setMenuList)([]));
|
|
554
|
+
dispatch((0, import_store6.setDataUser)({}));
|
|
555
|
+
dispatch((0, import_store6.setProfile)({}));
|
|
550
556
|
setAccessToken(null);
|
|
551
557
|
};
|
|
552
558
|
return {
|
package/dist/hooks.mjs
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
|
|
1
15
|
// src/hooks/core/use-call-action.ts
|
|
2
16
|
import { useState } from "react";
|
|
3
17
|
import { getEnv } from "@fctc/interface-logic/environment";
|
|
@@ -113,10 +127,24 @@ var useDetail = (accessToken, sub) => {
|
|
|
113
127
|
};
|
|
114
128
|
|
|
115
129
|
// src/hooks/core/use-list-data.ts
|
|
116
|
-
import { useMemo as
|
|
130
|
+
import { useMemo as useMemo3, useState as useState3 } from "react";
|
|
131
|
+
|
|
132
|
+
// src/utils/function.ts
|
|
133
|
+
import {
|
|
134
|
+
useCallback,
|
|
135
|
+
useEffect as useEffect3,
|
|
136
|
+
useMemo as useMemo2,
|
|
137
|
+
useReducer,
|
|
138
|
+
useRef,
|
|
139
|
+
useState as useState2
|
|
140
|
+
} from "react";
|
|
141
|
+
|
|
142
|
+
// src/store.ts
|
|
143
|
+
var store_exports = {};
|
|
144
|
+
__reExport(store_exports, store_star);
|
|
145
|
+
import * as store_star from "@fctc/interface-logic/store";
|
|
117
146
|
|
|
118
147
|
// src/utils/function.ts
|
|
119
|
-
import { useCallback, useEffect as useEffect3, useReducer, useRef, useState as useState2 } from "react";
|
|
120
148
|
var getDateRange = (currentDate, unit) => {
|
|
121
149
|
const date = new Date(currentDate);
|
|
122
150
|
let dateStart, dateEnd;
|
|
@@ -254,9 +282,9 @@ function useStorageState(key) {
|
|
|
254
282
|
// src/hooks/core/use-list-data.ts
|
|
255
283
|
import { useModel, useGetListData } from "@fctc/interface-logic/hooks";
|
|
256
284
|
import {
|
|
257
|
-
useAppSelector,
|
|
258
|
-
selectSearch,
|
|
259
|
-
selectList
|
|
285
|
+
useAppSelector as useAppSelector2,
|
|
286
|
+
selectSearch as selectSearch2,
|
|
287
|
+
selectList as selectList2
|
|
260
288
|
} from "@fctc/interface-logic/store";
|
|
261
289
|
import {
|
|
262
290
|
evalJSONDomain,
|
|
@@ -267,13 +295,13 @@ var useListData = ({
|
|
|
267
295
|
context,
|
|
268
296
|
viewResponse
|
|
269
297
|
}) => {
|
|
270
|
-
const { groupByDomain } =
|
|
298
|
+
const { groupByDomain } = useAppSelector2(selectSearch2);
|
|
271
299
|
const initModel = useModel();
|
|
272
300
|
const [type, setType] = useState3("list");
|
|
273
301
|
const [mode, setMode] = useState3("month");
|
|
274
302
|
const [currentDate, setCurrentDate] = useState3(/* @__PURE__ */ new Date());
|
|
275
|
-
const { pageLimit, page, order } =
|
|
276
|
-
const listDataProps =
|
|
303
|
+
const { pageLimit, page, order } = useAppSelector2(selectList2);
|
|
304
|
+
const listDataProps = useMemo3(() => {
|
|
277
305
|
const actData = action?.result;
|
|
278
306
|
if (!viewResponse || !actData || !context) {
|
|
279
307
|
return null;
|
|
@@ -334,7 +362,7 @@ var useListData = ({
|
|
|
334
362
|
};
|
|
335
363
|
|
|
336
364
|
// src/hooks/core/use-menu.ts
|
|
337
|
-
import { useEffect as useEffect4, useMemo as
|
|
365
|
+
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState4 } from "react";
|
|
338
366
|
|
|
339
367
|
// src/utils/constants.ts
|
|
340
368
|
var languages = [
|
|
@@ -353,7 +381,7 @@ var useMenu = ({ context }) => {
|
|
|
353
381
|
const menuData = useGetMenu(context, !!context);
|
|
354
382
|
const [menuid, setMenuId] = useState4(void 0);
|
|
355
383
|
const [action, setAction] = useCallAction();
|
|
356
|
-
const configedIconData =
|
|
384
|
+
const configedIconData = useMemo4(() => {
|
|
357
385
|
const data = menuData.data;
|
|
358
386
|
return data?.map((item) => {
|
|
359
387
|
return {
|
|
@@ -400,7 +428,7 @@ var useMenu = ({ context }) => {
|
|
|
400
428
|
|
|
401
429
|
// src/hooks/core/use-profile.ts
|
|
402
430
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
403
|
-
import { useEffect as useEffect5, useMemo as
|
|
431
|
+
import { useEffect as useEffect5, useMemo as useMemo5 } from "react";
|
|
404
432
|
import { useTranslation } from "react-i18next";
|
|
405
433
|
import { getEnv as getEnv3 } from "@fctc/interface-logic/environment";
|
|
406
434
|
import { useGetProfile } from "@fctc/interface-logic/hooks";
|
|
@@ -428,7 +456,7 @@ var useProfile = (accessToken) => {
|
|
|
428
456
|
i18n.changeLanguage(userLocale?.id.split("_")[0]);
|
|
429
457
|
}
|
|
430
458
|
}, [dispatch, userInfoQuery.data]);
|
|
431
|
-
const context =
|
|
459
|
+
const context = useMemo5(() => {
|
|
432
460
|
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
433
461
|
return {
|
|
434
462
|
uid: Number(userInfoQuery.data.sub),
|
|
@@ -450,13 +478,13 @@ var useUser = (accessToken) => {
|
|
|
450
478
|
};
|
|
451
479
|
|
|
452
480
|
// src/hooks/core/use-view-v2.ts
|
|
453
|
-
import { useMemo as
|
|
481
|
+
import { useMemo as useMemo6 } from "react";
|
|
454
482
|
import { useGetView } from "@fctc/interface-logic/hooks";
|
|
455
483
|
var useViewV2 = ({
|
|
456
484
|
action,
|
|
457
485
|
context
|
|
458
486
|
}) => {
|
|
459
|
-
const viewParams =
|
|
487
|
+
const viewParams = useMemo6(() => {
|
|
460
488
|
if (!action?.result) {
|
|
461
489
|
return void 0;
|
|
462
490
|
}
|
|
@@ -531,11 +559,11 @@ var useAuth = () => {
|
|
|
531
559
|
};
|
|
532
560
|
|
|
533
561
|
// src/hooks/core/use-app-provider.tsx
|
|
534
|
-
import { createContext, useContext, useMemo as
|
|
562
|
+
import { createContext, useContext, useMemo as useMemo8 } from "react";
|
|
535
563
|
|
|
536
564
|
// src/hooks/core/use-company.ts
|
|
537
565
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
538
|
-
import { useEffect as useEffect6, useMemo as
|
|
566
|
+
import { useEffect as useEffect6, useMemo as useMemo7 } from "react";
|
|
539
567
|
import { getEnv as getEnv4 } from "@fctc/interface-logic/environment";
|
|
540
568
|
import {
|
|
541
569
|
useGetCurrentCompany,
|
|
@@ -551,7 +579,7 @@ var useCompany = (accessToken) => {
|
|
|
551
579
|
queryFn: fetchCurrentCompany,
|
|
552
580
|
enabled: !!accessToken
|
|
553
581
|
});
|
|
554
|
-
const current_company_id =
|
|
582
|
+
const current_company_id = useMemo7(() => {
|
|
555
583
|
return currentCompany.data?.current_company_id;
|
|
556
584
|
}, [currentCompany.data]);
|
|
557
585
|
useEffect6(() => {
|
|
@@ -604,14 +632,14 @@ var AppProvider = ({ children }) => {
|
|
|
604
632
|
const auth = useAuth();
|
|
605
633
|
const user = useUser(auth.accessToken);
|
|
606
634
|
const company = use_company_default(auth.accessToken);
|
|
607
|
-
const menuContext =
|
|
635
|
+
const menuContext = useMemo8(() => {
|
|
608
636
|
return combineContexts([user.context, company.context]);
|
|
609
637
|
}, [user.context, company.context]);
|
|
610
638
|
const menu = useMenu({ context: menuContext });
|
|
611
|
-
const action =
|
|
639
|
+
const action = useMemo8(() => {
|
|
612
640
|
return menu.state.action;
|
|
613
641
|
}, [menu.state.action]);
|
|
614
|
-
const viewContext =
|
|
642
|
+
const viewContext = useMemo8(() => {
|
|
615
643
|
return combineContexts([
|
|
616
644
|
menuContext,
|
|
617
645
|
{ ...evalJSONContext(action?.result?.context) }
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIc
|
|
|
5
5
|
export { ISelctionStateProps, ITableBodyProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController } from './widget.mjs';
|
|
6
6
|
export * from '@fctc/interface-logic/types';
|
|
7
7
|
export { IInputFieldProps, ValuePropsType } from './types.mjs';
|
|
8
|
-
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useStorageState } from './utils.mjs';
|
|
8
|
+
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useSelectionState, useStorageState } from './utils.mjs';
|
|
9
9
|
export * from '@fctc/interface-logic/utils';
|
|
10
10
|
export * from '@fctc/interface-logic/store';
|
|
11
11
|
export * from '@fctc/interface-logic/constants';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { CheckIcon, ChevronBottomIcon, CloseIcon, EyeIcon, FilterIcon, GroupByIc
|
|
|
5
5
|
export { ISelctionStateProps, ITableBodyProps, ITableHeadProps, ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController } from './widget.js';
|
|
6
6
|
export * from '@fctc/interface-logic/types';
|
|
7
7
|
export { IInputFieldProps, ValuePropsType } from './types.js';
|
|
8
|
-
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useStorageState } from './utils.js';
|
|
8
|
+
export { API_APP_URL, API_PRESCHOOL_URL, STORAGES, combineContexts, convertFieldsToArray, countSum, getDateRange, languages, mergeButtons, setStorageItemAsync, useGetRowIds, useSelectionState, useStorageState } from './utils.js';
|
|
9
9
|
export * from '@fctc/interface-logic/utils';
|
|
10
10
|
export * from '@fctc/interface-logic/store';
|
|
11
11
|
export * from '@fctc/interface-logic/constants';
|