@fctc/widget-logic 1.2.5 → 1.2.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 CHANGED
@@ -951,9 +951,6 @@ type AppProviderType = {
951
951
  declare const AppProvider: ({ children }: {
952
952
  children: React.ReactNode;
953
953
  }) => JSX.Element;
954
- declare const MainAppProvider: ({ children, }: {
955
- children: React.ReactNode;
956
- }) => JSX.Element;
957
954
  declare const useAppProvider: () => AppProviderType;
958
955
 
959
956
  declare const DEFAULT_EVENTS: readonly ["mousedown", "touchstart"];
@@ -968,45 +965,4 @@ declare const useClickOutside: ({ handler, events, nodes, refs, }: UseClickOutsi
968
965
 
969
966
  declare function useDebounce<T>(value: T, delay: number): [T];
970
967
 
971
- declare const useSwitchLocaleHandler: () => {
972
- switchLocale: (langId: string) => Promise<void>;
973
- isLoading: boolean;
974
- error: Error | null;
975
- };
976
-
977
- declare const useLoginHandler: () => {
978
- login: ({ email, password, path, }: {
979
- email: string;
980
- password: string;
981
- path: string;
982
- }, { onSuccess, onError, }: {
983
- onSuccess?: (res: any) => void;
984
- onError?: (err: any) => void;
985
- }) => void;
986
- isLoading: boolean;
987
- error: Error | null;
988
- };
989
-
990
- declare const useForgotPasswordHandler: () => {
991
- sendForgotPassword: (email: string, { onSuccess, onError, }?: {
992
- onSuccess?: () => void;
993
- onError?: (err: any) => void;
994
- }) => void;
995
- isLoading: boolean;
996
- error: Error | null;
997
- };
998
-
999
- declare const useResetPasswordHandler: () => {
1000
- resetPassword: ({ password, confirmPassword, token, }: {
1001
- password: string;
1002
- confirmPassword: string;
1003
- token: string;
1004
- }, { onSuccess, onError, }: {
1005
- onSuccess?: () => void;
1006
- onError?: () => void;
1007
- }) => void;
1008
- isLoading: boolean;
1009
- error: Error | null;
1010
- };
1011
-
1012
- export { type ActionResultType, AppProvider, type Context, MainAppProvider, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useForgotPasswordHandler, useListData, type useListDataType, useLoginHandler, useMenu, type useMenuType, useProfile, useResetPasswordHandler, useSwitchLocaleHandler, useUser, type useUserType, useViewV2, type useViewV2Type };
968
+ export { type ActionResultType, AppProvider, type Context, 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
@@ -951,9 +951,6 @@ type AppProviderType = {
951
951
  declare const AppProvider: ({ children }: {
952
952
  children: React.ReactNode;
953
953
  }) => JSX.Element;
954
- declare const MainAppProvider: ({ children, }: {
955
- children: React.ReactNode;
956
- }) => JSX.Element;
957
954
  declare const useAppProvider: () => AppProviderType;
958
955
 
959
956
  declare const DEFAULT_EVENTS: readonly ["mousedown", "touchstart"];
@@ -968,45 +965,4 @@ declare const useClickOutside: ({ handler, events, nodes, refs, }: UseClickOutsi
968
965
 
969
966
  declare function useDebounce<T>(value: T, delay: number): [T];
970
967
 
971
- declare const useSwitchLocaleHandler: () => {
972
- switchLocale: (langId: string) => Promise<void>;
973
- isLoading: boolean;
974
- error: Error | null;
975
- };
976
-
977
- declare const useLoginHandler: () => {
978
- login: ({ email, password, path, }: {
979
- email: string;
980
- password: string;
981
- path: string;
982
- }, { onSuccess, onError, }: {
983
- onSuccess?: (res: any) => void;
984
- onError?: (err: any) => void;
985
- }) => void;
986
- isLoading: boolean;
987
- error: Error | null;
988
- };
989
-
990
- declare const useForgotPasswordHandler: () => {
991
- sendForgotPassword: (email: string, { onSuccess, onError, }?: {
992
- onSuccess?: () => void;
993
- onError?: (err: any) => void;
994
- }) => void;
995
- isLoading: boolean;
996
- error: Error | null;
997
- };
998
-
999
- declare const useResetPasswordHandler: () => {
1000
- resetPassword: ({ password, confirmPassword, token, }: {
1001
- password: string;
1002
- confirmPassword: string;
1003
- token: string;
1004
- }, { onSuccess, onError, }: {
1005
- onSuccess?: () => void;
1006
- onError?: () => void;
1007
- }) => void;
1008
- isLoading: boolean;
1009
- error: Error | null;
1010
- };
1011
-
1012
- export { type ActionResultType, AppProvider, type Context, MainAppProvider, type Record, type ViewResponse, useAppProvider, useAuth, type useAuthType, useCallAction, type useCallActionType, useClickOutside, useConfig, type useConfigType, useDebounce, useDetail, useForgotPasswordHandler, useListData, type useListDataType, useLoginHandler, useMenu, type useMenuType, useProfile, useResetPasswordHandler, useSwitchLocaleHandler, useUser, type useUserType, useViewV2, type useViewV2Type };
968
+ export { type ActionResultType, AppProvider, type Context, 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
@@ -15,13 +15,32 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
20
 
20
21
  // src/hooks.ts
22
+ var hooks_exports2 = {};
23
+ __export(hooks_exports2, {
24
+ AppProvider: () => AppProvider,
25
+ useAppProvider: () => useAppProvider,
26
+ useAuth: () => useAuth,
27
+ useCallAction: () => useCallAction,
28
+ useClickOutside: () => useClickOutside,
29
+ useConfig: () => useConfig,
30
+ useDebounce: () => useDebounce,
31
+ useDetail: () => useDetail,
32
+ useListData: () => useListData,
33
+ useMenu: () => useMenu,
34
+ useProfile: () => useProfile,
35
+ useUser: () => useUser,
36
+ useViewV2: () => useViewV2
37
+ });
38
+ module.exports = __toCommonJS(hooks_exports2);
39
+
40
+ // src/hooks/index.ts
21
41
  var hooks_exports = {};
22
42
  __export(hooks_exports, {
23
43
  AppProvider: () => AppProvider,
24
- MainAppProvider: () => MainAppProvider,
25
44
  useAppProvider: () => useAppProvider,
26
45
  useAuth: () => useAuth,
27
46
  useCallAction: () => useCallAction,
@@ -29,17 +48,12 @@ __export(hooks_exports, {
29
48
  useConfig: () => useConfig,
30
49
  useDebounce: () => useDebounce,
31
50
  useDetail: () => useDetail,
32
- useForgotPasswordHandler: () => useForgotPasswordHandler,
33
51
  useListData: () => useListData,
34
- useLoginHandler: () => useLoginHandler,
35
52
  useMenu: () => useMenu,
36
53
  useProfile: () => useProfile,
37
- useResetPasswordHandler: () => useResetPasswordHandler,
38
- useSwitchLocaleHandler: () => useSwitchLocaleHandler,
39
54
  useUser: () => useUser,
40
55
  useViewV2: () => useViewV2
41
56
  });
42
- module.exports = __toCommonJS(hooks_exports);
43
57
 
44
58
  // src/hooks/core/use-call-action.ts
45
59
  var import_interface_logic = require("@fctc/interface-logic");
@@ -628,7 +642,9 @@ var AppProvider = ({ children }) => {
628
642
  return combineContexts([user.context, company.context]);
629
643
  }, [user.context, company.context]);
630
644
  const menu = useMenu({ context: menuContext });
631
- const action = (0, import_react10.useMemo)(() => menu.state.action, [menu.state.action]);
645
+ const action = (0, import_react10.useMemo)(() => {
646
+ return menu.state.action;
647
+ }, [menu.state.action]);
632
648
  const viewContext = (0, import_react10.useMemo)(() => {
633
649
  return combineContexts([
634
650
  menuContext,
@@ -661,14 +677,11 @@ var AppProvider = ({ children }) => {
661
677
  }
662
678
  );
663
679
  };
664
- var MainAppProvider = ({
665
- children
666
- }) => {
667
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface_logic10.MainProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppProvider, { children }) });
668
- };
669
680
  var useAppProvider = () => {
670
681
  const context = (0, import_react10.useContext)(ReactContext);
671
- if (!context) return AppProviderInitialValue;
682
+ if (!context) {
683
+ return AppProviderInitialValue;
684
+ }
672
685
  return context;
673
686
  };
674
687
 
@@ -718,132 +731,11 @@ function useDebounce(value, delay) {
718
731
  return [debouncedValue];
719
732
  }
720
733
 
721
- // src/hooks/api/use-switch-locale.ts
722
- var import_interface_logic11 = require("@fctc/interface-logic");
723
- var import_react13 = require("react");
724
- var useSwitchLocaleHandler = () => {
725
- const switchUserLocale = (0, import_interface_logic11.useSwitchLocale)();
726
- const env = (0, import_interface_logic11.getEnv)();
727
- const { context } = (0, import_interface_logic11.useAppSelector)(import_interface_logic11.selectEnv);
728
- const switchLocale = (0, import_react13.useCallback)(
729
- async (langId) => {
730
- if (!langId) return;
731
- await switchUserLocale.mutateAsync({
732
- data: {
733
- id: parseInt(context?.uid),
734
- values: { lang: langId }
735
- }
736
- });
737
- env.setLang(langId);
738
- },
739
- [switchUserLocale]
740
- );
741
- return {
742
- switchLocale,
743
- isLoading: switchUserLocale.isPending,
744
- error: switchUserLocale.error
745
- };
746
- };
747
-
748
- // src/hooks/api/use-login.ts
749
- var import_interface_logic12 = require("@fctc/interface-logic");
750
- var import_react14 = require("react");
751
- var useLoginHandler = () => {
752
- const loginMutate = (0, import_interface_logic12.useLoginCredential)();
753
- const login = (0, import_react14.useCallback)(
754
- ({
755
- email,
756
- password,
757
- path
758
- }, {
759
- onSuccess,
760
- onError
761
- }) => {
762
- loginMutate.mutate(
763
- {
764
- email,
765
- password,
766
- path
767
- },
768
- {
769
- onSuccess,
770
- onError
771
- }
772
- );
773
- },
774
- [loginMutate]
775
- );
776
- return {
777
- login,
778
- isLoading: loginMutate.isPending,
779
- error: loginMutate.error
780
- };
781
- };
782
-
783
- // src/hooks/api/use-forgot-password.ts
784
- var import_interface_logic13 = require("@fctc/interface-logic");
785
- var import_react15 = require("react");
786
- var useForgotPasswordHandler = () => {
787
- const forgotPasswordMutate = (0, import_interface_logic13.useForgotPassword)();
788
- const sendForgotPassword = (0, import_react15.useCallback)(
789
- (email, {
790
- onSuccess,
791
- onError
792
- } = {}) => {
793
- forgotPasswordMutate.mutate(email, {
794
- onSuccess,
795
- onError
796
- });
797
- },
798
- [forgotPasswordMutate]
799
- );
800
- return {
801
- sendForgotPassword,
802
- isLoading: forgotPasswordMutate.isPending,
803
- error: forgotPasswordMutate.error
804
- };
805
- };
806
-
807
- // src/hooks/api/use-reset-password.ts
808
- var import_interface_logic14 = require("@fctc/interface-logic");
809
- var import_react16 = require("react");
810
- var useResetPasswordHandler = () => {
811
- const resetPasswordMutate = (0, import_interface_logic14.useResetPassword)();
812
- const resetPassword = (0, import_react16.useCallback)(
813
- ({
814
- password,
815
- confirmPassword,
816
- token
817
- }, {
818
- onSuccess,
819
- onError
820
- }) => {
821
- resetPasswordMutate.mutate(
822
- {
823
- data: {
824
- password,
825
- confirmPassword
826
- },
827
- token
828
- },
829
- {
830
- onSuccess,
831
- onError
832
- }
833
- );
834
- },
835
- [resetPasswordMutate]
836
- );
837
- return {
838
- resetPassword,
839
- isLoading: resetPasswordMutate.isPending,
840
- error: resetPasswordMutate.error
841
- };
842
- };
734
+ // src/hooks/index.ts
735
+ __reExport(hooks_exports, require("@fctc/interface-logic/hook"));
843
736
  // Annotate the CommonJS export names for ESM import in node:
844
737
  0 && (module.exports = {
845
738
  AppProvider,
846
- MainAppProvider,
847
739
  useAppProvider,
848
740
  useAuth,
849
741
  useCallAction,
@@ -851,13 +743,9 @@ var useResetPasswordHandler = () => {
851
743
  useConfig,
852
744
  useDebounce,
853
745
  useDetail,
854
- useForgotPasswordHandler,
855
746
  useListData,
856
- useLoginHandler,
857
747
  useMenu,
858
748
  useProfile,
859
- useResetPasswordHandler,
860
- useSwitchLocaleHandler,
861
749
  useUser,
862
750
  useViewV2
863
751
  });
package/dist/hooks.mjs CHANGED
@@ -1,3 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+ // src/hooks/index.ts
20
+ var hooks_exports = {};
21
+ __export(hooks_exports, {
22
+ AppProvider: () => AppProvider,
23
+ useAppProvider: () => useAppProvider,
24
+ useAuth: () => useAuth,
25
+ useCallAction: () => useCallAction,
26
+ useClickOutside: () => useClickOutside,
27
+ useConfig: () => useConfig,
28
+ useDebounce: () => useDebounce,
29
+ useDetail: () => useDetail,
30
+ useListData: () => useListData,
31
+ useMenu: () => useMenu,
32
+ useProfile: () => useProfile,
33
+ useUser: () => useUser,
34
+ useViewV2: () => useViewV2
35
+ });
36
+
1
37
  // src/hooks/core/use-call-action.ts
2
38
  import { getEnv, useLoadAction, useRunAction } from "@fctc/interface-logic";
3
39
  import { useState } from "react";
@@ -590,7 +626,7 @@ var useCompany = (accessToken) => {
590
626
  var use_company_default = useCompany;
591
627
 
592
628
  // src/hooks/core/use-app-provider.tsx
593
- import { evalJSONContext, MainProvider } from "@fctc/interface-logic";
629
+ import { evalJSONContext } from "@fctc/interface-logic";
594
630
  import { jsx } from "react/jsx-runtime";
595
631
  var AppProviderInitialValue = {
596
632
  config: {},
@@ -612,7 +648,9 @@ var AppProvider = ({ children }) => {
612
648
  return combineContexts([user.context, company.context]);
613
649
  }, [user.context, company.context]);
614
650
  const menu = useMenu({ context: menuContext });
615
- const action = useMemo7(() => menu.state.action, [menu.state.action]);
651
+ const action = useMemo7(() => {
652
+ return menu.state.action;
653
+ }, [menu.state.action]);
616
654
  const viewContext = useMemo7(() => {
617
655
  return combineContexts([
618
656
  menuContext,
@@ -645,14 +683,11 @@ var AppProvider = ({ children }) => {
645
683
  }
646
684
  );
647
685
  };
648
- var MainAppProvider = ({
649
- children
650
- }) => {
651
- return /* @__PURE__ */ jsx(MainProvider, { children: /* @__PURE__ */ jsx(AppProvider, { children }) });
652
- };
653
686
  var useAppProvider = () => {
654
687
  const context = useContext(ReactContext);
655
- if (!context) return AppProviderInitialValue;
688
+ if (!context) {
689
+ return AppProviderInitialValue;
690
+ }
656
691
  return context;
657
692
  };
658
693
 
@@ -702,136 +737,11 @@ function useDebounce(value, delay) {
702
737
  return [debouncedValue];
703
738
  }
704
739
 
705
- // src/hooks/api/use-switch-locale.ts
706
- import {
707
- getEnv as getEnv5,
708
- selectEnv,
709
- useAppSelector as useAppSelector2,
710
- useSwitchLocale
711
- } from "@fctc/interface-logic";
712
- import { useCallback as useCallback2 } from "react";
713
- var useSwitchLocaleHandler = () => {
714
- const switchUserLocale = useSwitchLocale();
715
- const env = getEnv5();
716
- const { context } = useAppSelector2(selectEnv);
717
- const switchLocale = useCallback2(
718
- async (langId) => {
719
- if (!langId) return;
720
- await switchUserLocale.mutateAsync({
721
- data: {
722
- id: parseInt(context?.uid),
723
- values: { lang: langId }
724
- }
725
- });
726
- env.setLang(langId);
727
- },
728
- [switchUserLocale]
729
- );
730
- return {
731
- switchLocale,
732
- isLoading: switchUserLocale.isPending,
733
- error: switchUserLocale.error
734
- };
735
- };
736
-
737
- // src/hooks/api/use-login.ts
738
- import { useLoginCredential as useLoginCredential2 } from "@fctc/interface-logic";
739
- import { useCallback as useCallback3 } from "react";
740
- var useLoginHandler = () => {
741
- const loginMutate = useLoginCredential2();
742
- const login = useCallback3(
743
- ({
744
- email,
745
- password,
746
- path
747
- }, {
748
- onSuccess,
749
- onError
750
- }) => {
751
- loginMutate.mutate(
752
- {
753
- email,
754
- password,
755
- path
756
- },
757
- {
758
- onSuccess,
759
- onError
760
- }
761
- );
762
- },
763
- [loginMutate]
764
- );
765
- return {
766
- login,
767
- isLoading: loginMutate.isPending,
768
- error: loginMutate.error
769
- };
770
- };
771
-
772
- // src/hooks/api/use-forgot-password.ts
773
- import { useForgotPassword } from "@fctc/interface-logic";
774
- import { useCallback as useCallback4 } from "react";
775
- var useForgotPasswordHandler = () => {
776
- const forgotPasswordMutate = useForgotPassword();
777
- const sendForgotPassword = useCallback4(
778
- (email, {
779
- onSuccess,
780
- onError
781
- } = {}) => {
782
- forgotPasswordMutate.mutate(email, {
783
- onSuccess,
784
- onError
785
- });
786
- },
787
- [forgotPasswordMutate]
788
- );
789
- return {
790
- sendForgotPassword,
791
- isLoading: forgotPasswordMutate.isPending,
792
- error: forgotPasswordMutate.error
793
- };
794
- };
795
-
796
- // src/hooks/api/use-reset-password.ts
797
- import { useResetPassword } from "@fctc/interface-logic";
798
- import { useCallback as useCallback5 } from "react";
799
- var useResetPasswordHandler = () => {
800
- const resetPasswordMutate = useResetPassword();
801
- const resetPassword = useCallback5(
802
- ({
803
- password,
804
- confirmPassword,
805
- token
806
- }, {
807
- onSuccess,
808
- onError
809
- }) => {
810
- resetPasswordMutate.mutate(
811
- {
812
- data: {
813
- password,
814
- confirmPassword
815
- },
816
- token
817
- },
818
- {
819
- onSuccess,
820
- onError
821
- }
822
- );
823
- },
824
- [resetPasswordMutate]
825
- );
826
- return {
827
- resetPassword,
828
- isLoading: resetPasswordMutate.isPending,
829
- error: resetPasswordMutate.error
830
- };
831
- };
740
+ // src/hooks/index.ts
741
+ __reExport(hooks_exports, hook_star);
742
+ import * as hook_star from "@fctc/interface-logic/hook";
832
743
  export {
833
744
  AppProvider,
834
- MainAppProvider,
835
745
  useAppProvider,
836
746
  useAuth,
837
747
  useCallAction,
@@ -839,13 +749,9 @@ export {
839
749
  useConfig,
840
750
  useDebounce,
841
751
  useDetail,
842
- useForgotPasswordHandler,
843
752
  useListData,
844
- useLoginHandler,
845
753
  useMenu,
846
754
  useProfile,
847
- useResetPasswordHandler,
848
- useSwitchLocaleHandler,
849
755
  useUser,
850
756
  useViewV2
851
757
  };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { ActionResultType, AppProvider, Context, MainAppProvider, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useForgotPasswordHandler, useListData, useListDataType, useLoginHandler, useMenu, useMenuType, useProfile, useResetPasswordHandler, useSwitchLocaleHandler, useUser, useUserType, useViewV2, useViewV2Type } from './hooks.mjs';
1
+ export { ActionResultType, AppProvider, Context, 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 { CloseIcon, EyeIcon, LoadingIcon } from './icons.mjs';
3
3
  import { IInputFieldProps, ValuePropsType } from './types.mjs';
4
4
  import * as react from 'react';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ActionResultType, AppProvider, Context, MainAppProvider, Record, ViewResponse, useAppProvider, useAuth, useAuthType, useCallAction, useCallActionType, useClickOutside, useConfig, useConfigType, useDebounce, useDetail, useForgotPasswordHandler, useListData, useListDataType, useLoginHandler, useMenu, useMenuType, useProfile, useResetPasswordHandler, useSwitchLocaleHandler, useUser, useUserType, useViewV2, useViewV2Type } from './hooks.js';
1
+ export { ActionResultType, AppProvider, Context, 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 { CloseIcon, EyeIcon, LoadingIcon } from './icons.js';
3
3
  import { IInputFieldProps, ValuePropsType } from './types.js';
4
4
  import * as react from 'react';