@intlayer/design-system 5.1.7 → 5.1.8

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.
Files changed (27) hide show
  1. package/dist/components/Auth/useAuth/index.cjs +13 -26
  2. package/dist/components/Auth/useAuth/index.cjs.map +1 -1
  3. package/dist/components/Auth/useAuth/index.d.ts.map +1 -1
  4. package/dist/components/Auth/useAuth/index.mjs +13 -26
  5. package/dist/components/Auth/useAuth/index.mjs.map +1 -1
  6. package/dist/components/Auth/useAuth/useOAuth2.cjs +3 -5
  7. package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -1
  8. package/dist/components/Auth/useAuth/useOAuth2.d.ts +1 -1
  9. package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -1
  10. package/dist/components/Auth/useAuth/useOAuth2.mjs +3 -5
  11. package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -1
  12. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +6 -4
  13. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  14. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  15. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +6 -4
  16. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  17. package/dist/hooks/useAsync/useAsync.cjs +89 -126
  18. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  19. package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
  20. package/dist/hooks/useAsync/useAsync.mjs +90 -127
  21. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  22. package/dist/hooks/useIntlayerAPI.cjs +11 -21
  23. package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
  24. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  25. package/dist/hooks/useIntlayerAPI.mjs +11 -21
  26. package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
  27. package/package.json +19 -19
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const ReactExports = require("react");
5
4
  const components_Auth_useAuth_useCSRF = require("./useCSRF.cjs");
6
5
  const components_Auth_useAuth_useOAuth2 = require("./useOAuth2.cjs");
7
6
  const components_Auth_useAuth_useSession = require("./useSession.cjs");
@@ -14,31 +13,19 @@ const useAuth = ({
14
13
  sessionProp,
15
14
  intlayerConfiguration
16
15
  );
17
- const { oAuth2AccessToken } = components_Auth_useAuth_useOAuth2.useOAuth2(csrfToken, intlayerConfiguration);
18
- const memoValue = ReactExports.useMemo(
19
- () => ({
20
- session,
21
- fetchSession,
22
- setSession,
23
- revalidateSession,
24
- csrfToken,
25
- csrfTokenFetched,
26
- oAuth2AccessToken,
27
- isAuthenticated: Boolean(session || oAuth2AccessToken),
28
- isProjectAdmin: session?.isProjectAdmin,
29
- isOrganizationAdmin: session?.isOrganizationAdmin
30
- }),
31
- [
32
- session,
33
- setSession,
34
- fetchSession,
35
- revalidateSession,
36
- csrfToken,
37
- csrfTokenFetched,
38
- oAuth2AccessToken
39
- ]
40
- );
41
- return memoValue;
16
+ const { oAuth2AccessToken } = components_Auth_useAuth_useOAuth2.useOAuth2(intlayerConfiguration);
17
+ return {
18
+ session,
19
+ fetchSession,
20
+ setSession,
21
+ revalidateSession,
22
+ csrfToken,
23
+ csrfTokenFetched,
24
+ oAuth2AccessToken,
25
+ isAuthenticated: Boolean(session || oAuth2AccessToken),
26
+ isProjectAdmin: session?.isProjectAdmin,
27
+ isOrganizationAdmin: session?.isOrganizationAdmin
28
+ };
42
29
  };
43
30
  exports.useAuth = useAuth;
44
31
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/components/Auth/useAuth/index.tsx"],"sourcesContent":["'use client';\n\nimport type {\n OAuth2Token,\n OrganizationAPI,\n ProjectAPI,\n UserAPI,\n} from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { useMemo } from 'react';\nimport { useCSRF } from './useCSRF';\nimport { useOAuth2 } from './useOAuth2';\nimport { useSession } from './useSession';\n\nexport type Session = {\n user: UserAPI | null;\n organization: OrganizationAPI | null;\n project: ProjectAPI | null;\n isOrganizationAdmin: boolean;\n isProjectAdmin: boolean;\n};\n\ntype SessionContextProps = {\n session: Session | null | undefined;\n setSession: (session: Session | null) => void;\n fetchSession: () => Promise<Session | null | undefined>;\n revalidateSession: () => Promise<Session | null | undefined>;\n csrfToken: string | null | undefined;\n csrfTokenFetched: boolean;\n isAuthenticated: boolean;\n oAuth2AccessToken: OAuth2Token | null | undefined;\n isProjectAdmin: boolean | null | undefined;\n isOrganizationAdmin: boolean | null | undefined;\n};\n\nexport const useAuth = ({\n session: sessionProp,\n intlayerConfiguration,\n}: {\n session?: Session | null;\n intlayerConfiguration?: IntlayerConfig;\n} = {}) => {\n const { csrfToken, csrfTokenFetched } = useCSRF(intlayerConfiguration);\n const { session, fetchSession, revalidateSession, setSession } = useSession(\n sessionProp,\n intlayerConfiguration\n );\n const { oAuth2AccessToken } = useOAuth2(csrfToken, intlayerConfiguration);\n\n const memoValue: SessionContextProps = useMemo(\n () => ({\n session,\n fetchSession,\n setSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n isAuthenticated: Boolean(session || oAuth2AccessToken),\n isProjectAdmin: session?.isProjectAdmin,\n isOrganizationAdmin: session?.isOrganizationAdmin,\n }),\n [\n session,\n setSession,\n fetchSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n ]\n );\n\n return memoValue;\n};\n"],"names":["useCSRF","useSession","useOAuth2","useMemo"],"mappings":";;;;;;;AAmCO,MAAM,UAAU,CAAC;AAAA,EACtB,SAAS;AAAA,EACT;AACF,IAGI,OAAO;AACT,QAAM,EAAE,WAAW,qBAAqBA,gCAAAA,QAAQ,qBAAqB;AACrE,QAAM,EAAE,SAAS,cAAc,mBAAmB,WAAe,IAAAC,mCAAA;AAAA,IAC/D;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,kBAAsB,IAAAC,4CAAU,WAAW,qBAAqB;AAExE,QAAM,YAAiCC,aAAA;AAAA,IACrC,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,QAAQ,WAAW,iBAAiB;AAAA,MACrD,gBAAgB,SAAS;AAAA,MACzB,qBAAqB,SAAS;AAAA,IAAA;AAAA,IAEhC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/Auth/useAuth/index.tsx"],"sourcesContent":["'use client';\n\nimport type {\n OAuth2Token,\n OrganizationAPI,\n ProjectAPI,\n UserAPI,\n} from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { useMemo } from 'react';\nimport { useCSRF } from './useCSRF';\nimport { useOAuth2 } from './useOAuth2';\nimport { useSession } from './useSession';\n\nexport type Session = {\n user: UserAPI | null;\n organization: OrganizationAPI | null;\n project: ProjectAPI | null;\n isOrganizationAdmin: boolean;\n isProjectAdmin: boolean;\n};\n\ntype SessionContextProps = {\n session: Session | null | undefined;\n setSession: (session: Session | null) => void;\n fetchSession: () => Promise<Session | null | undefined>;\n revalidateSession: () => Promise<Session | null | undefined>;\n csrfToken: string | null | undefined;\n csrfTokenFetched: boolean;\n isAuthenticated: boolean;\n oAuth2AccessToken: OAuth2Token | null | undefined;\n isProjectAdmin: boolean | null | undefined;\n isOrganizationAdmin: boolean | null | undefined;\n};\n\nexport const useAuth = ({\n session: sessionProp,\n intlayerConfiguration,\n}: {\n session?: Session | null;\n intlayerConfiguration?: IntlayerConfig;\n} = {}): SessionContextProps => {\n const { csrfToken, csrfTokenFetched } = useCSRF(intlayerConfiguration);\n const { session, fetchSession, revalidateSession, setSession } = useSession(\n sessionProp,\n intlayerConfiguration\n );\n const { oAuth2AccessToken } = useOAuth2(intlayerConfiguration);\n\n return {\n session,\n fetchSession,\n setSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n isAuthenticated: Boolean(session || oAuth2AccessToken),\n isProjectAdmin: session?.isProjectAdmin,\n isOrganizationAdmin: session?.isOrganizationAdmin,\n };\n};\n"],"names":["useCSRF","useSession","useOAuth2"],"mappings":";;;;;;AAmCO,MAAM,UAAU,CAAC;AAAA,EACtB,SAAS;AAAA,EACT;AACF,IAGI,OAA4B;AAC9B,QAAM,EAAE,WAAW,qBAAqBA,gCAAAA,QAAQ,qBAAqB;AACrE,QAAM,EAAE,SAAS,cAAc,mBAAmB,WAAe,IAAAC,mCAAA;AAAA,IAC/D;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,kBAAA,IAAsBC,kCAAA,UAAU,qBAAqB;AAEtD,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,QAAQ,WAAW,iBAAiB;AAAA,IACrD,gBAAgB,SAAS;AAAA,IACzB,qBAAqB,SAAS;AAAA,EAChC;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Auth/useAuth/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAM9D,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IACrC,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,GAAG,IAAI,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACxD,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAC7D,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,mBAAmB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,OAAO,sDAGjB;IACD,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,qBAAqB,CAAC,EAAE,cAAc,CAAC;CACxC,KAAQ,mBAoBR,CAAC"}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- import { useMemo } from "react";
3
2
  import { useCSRF } from "./useCSRF.mjs";
4
3
  import { useOAuth2 } from "./useOAuth2.mjs";
5
4
  import { useSession } from "./useSession.mjs";
@@ -12,31 +11,19 @@ const useAuth = ({
12
11
  sessionProp,
13
12
  intlayerConfiguration
14
13
  );
15
- const { oAuth2AccessToken } = useOAuth2(csrfToken, intlayerConfiguration);
16
- const memoValue = useMemo(
17
- () => ({
18
- session,
19
- fetchSession,
20
- setSession,
21
- revalidateSession,
22
- csrfToken,
23
- csrfTokenFetched,
24
- oAuth2AccessToken,
25
- isAuthenticated: Boolean(session || oAuth2AccessToken),
26
- isProjectAdmin: session?.isProjectAdmin,
27
- isOrganizationAdmin: session?.isOrganizationAdmin
28
- }),
29
- [
30
- session,
31
- setSession,
32
- fetchSession,
33
- revalidateSession,
34
- csrfToken,
35
- csrfTokenFetched,
36
- oAuth2AccessToken
37
- ]
38
- );
39
- return memoValue;
14
+ const { oAuth2AccessToken } = useOAuth2(intlayerConfiguration);
15
+ return {
16
+ session,
17
+ fetchSession,
18
+ setSession,
19
+ revalidateSession,
20
+ csrfToken,
21
+ csrfTokenFetched,
22
+ oAuth2AccessToken,
23
+ isAuthenticated: Boolean(session || oAuth2AccessToken),
24
+ isProjectAdmin: session?.isProjectAdmin,
25
+ isOrganizationAdmin: session?.isOrganizationAdmin
26
+ };
40
27
  };
41
28
  export {
42
29
  useAuth
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/components/Auth/useAuth/index.tsx"],"sourcesContent":["'use client';\n\nimport type {\n OAuth2Token,\n OrganizationAPI,\n ProjectAPI,\n UserAPI,\n} from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { useMemo } from 'react';\nimport { useCSRF } from './useCSRF';\nimport { useOAuth2 } from './useOAuth2';\nimport { useSession } from './useSession';\n\nexport type Session = {\n user: UserAPI | null;\n organization: OrganizationAPI | null;\n project: ProjectAPI | null;\n isOrganizationAdmin: boolean;\n isProjectAdmin: boolean;\n};\n\ntype SessionContextProps = {\n session: Session | null | undefined;\n setSession: (session: Session | null) => void;\n fetchSession: () => Promise<Session | null | undefined>;\n revalidateSession: () => Promise<Session | null | undefined>;\n csrfToken: string | null | undefined;\n csrfTokenFetched: boolean;\n isAuthenticated: boolean;\n oAuth2AccessToken: OAuth2Token | null | undefined;\n isProjectAdmin: boolean | null | undefined;\n isOrganizationAdmin: boolean | null | undefined;\n};\n\nexport const useAuth = ({\n session: sessionProp,\n intlayerConfiguration,\n}: {\n session?: Session | null;\n intlayerConfiguration?: IntlayerConfig;\n} = {}) => {\n const { csrfToken, csrfTokenFetched } = useCSRF(intlayerConfiguration);\n const { session, fetchSession, revalidateSession, setSession } = useSession(\n sessionProp,\n intlayerConfiguration\n );\n const { oAuth2AccessToken } = useOAuth2(csrfToken, intlayerConfiguration);\n\n const memoValue: SessionContextProps = useMemo(\n () => ({\n session,\n fetchSession,\n setSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n isAuthenticated: Boolean(session || oAuth2AccessToken),\n isProjectAdmin: session?.isProjectAdmin,\n isOrganizationAdmin: session?.isOrganizationAdmin,\n }),\n [\n session,\n setSession,\n fetchSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n ]\n );\n\n return memoValue;\n};\n"],"names":[],"mappings":";;;;;AAmCO,MAAM,UAAU,CAAC;AAAA,EACtB,SAAS;AAAA,EACT;AACF,IAGI,OAAO;AACT,QAAM,EAAE,WAAW,qBAAqB,QAAQ,qBAAqB;AACrE,QAAM,EAAE,SAAS,cAAc,mBAAmB,WAAe,IAAA;AAAA,IAC/D;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,kBAAsB,IAAA,UAAU,WAAW,qBAAqB;AAExE,QAAM,YAAiC;AAAA,IACrC,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,QAAQ,WAAW,iBAAiB;AAAA,MACrD,gBAAgB,SAAS;AAAA,MACzB,qBAAqB,SAAS;AAAA,IAAA;AAAA,IAEhC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/components/Auth/useAuth/index.tsx"],"sourcesContent":["'use client';\n\nimport type {\n OAuth2Token,\n OrganizationAPI,\n ProjectAPI,\n UserAPI,\n} from '@intlayer/backend';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { useMemo } from 'react';\nimport { useCSRF } from './useCSRF';\nimport { useOAuth2 } from './useOAuth2';\nimport { useSession } from './useSession';\n\nexport type Session = {\n user: UserAPI | null;\n organization: OrganizationAPI | null;\n project: ProjectAPI | null;\n isOrganizationAdmin: boolean;\n isProjectAdmin: boolean;\n};\n\ntype SessionContextProps = {\n session: Session | null | undefined;\n setSession: (session: Session | null) => void;\n fetchSession: () => Promise<Session | null | undefined>;\n revalidateSession: () => Promise<Session | null | undefined>;\n csrfToken: string | null | undefined;\n csrfTokenFetched: boolean;\n isAuthenticated: boolean;\n oAuth2AccessToken: OAuth2Token | null | undefined;\n isProjectAdmin: boolean | null | undefined;\n isOrganizationAdmin: boolean | null | undefined;\n};\n\nexport const useAuth = ({\n session: sessionProp,\n intlayerConfiguration,\n}: {\n session?: Session | null;\n intlayerConfiguration?: IntlayerConfig;\n} = {}): SessionContextProps => {\n const { csrfToken, csrfTokenFetched } = useCSRF(intlayerConfiguration);\n const { session, fetchSession, revalidateSession, setSession } = useSession(\n sessionProp,\n intlayerConfiguration\n );\n const { oAuth2AccessToken } = useOAuth2(intlayerConfiguration);\n\n return {\n session,\n fetchSession,\n setSession,\n revalidateSession,\n csrfToken,\n csrfTokenFetched,\n oAuth2AccessToken,\n isAuthenticated: Boolean(session || oAuth2AccessToken),\n isProjectAdmin: session?.isProjectAdmin,\n isOrganizationAdmin: session?.isOrganizationAdmin,\n };\n};\n"],"names":[],"mappings":";;;;AAmCO,MAAM,UAAU,CAAC;AAAA,EACtB,SAAS;AAAA,EACT;AACF,IAGI,OAA4B;AAC9B,QAAM,EAAE,WAAW,qBAAqB,QAAQ,qBAAqB;AACrE,QAAM,EAAE,SAAS,cAAc,mBAAmB,WAAe,IAAA;AAAA,IAC/D;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,kBAAA,IAAsB,UAAU,qBAAqB;AAEtD,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,QAAQ,WAAW,iBAAiB;AAAA,IACrD,gBAAgB,SAAS;AAAA,IACzB,qBAAqB,SAAS;AAAA,EAChC;AACF;"}
@@ -5,19 +5,17 @@ const api = require("@intlayer/api");
5
5
  const client = require("@intlayer/config/client");
6
6
  const editorReact = require("@intlayer/editor-react");
7
7
  const hooks_useAsync_useAsync = require("../../../hooks/useAsync/useAsync.cjs");
8
- const useOAuth2 = (csrfToken, intlayerConfiguration) => {
8
+ const useOAuth2 = (intlayerConfiguration) => {
9
9
  const configuration = editorReact.useConfiguration();
10
10
  const config = intlayerConfiguration ?? configuration ?? client.getConfiguration();
11
11
  const intlayerAPI = api.getIntlayerAPI(void 0, config);
12
12
  const { data } = hooks_useAsync_useAsync.useAsync(
13
13
  "getOAuth2AccessToken",
14
- () => intlayerAPI.auth.getOAuth2AccessToken({
15
- body: { csrf_token: csrfToken }
16
- }),
14
+ () => intlayerAPI.auth.getOAuth2AccessToken(),
17
15
  {
18
16
  cache: true,
19
17
  autoFetch: true,
20
- enable: !!(config.editor.clientId && config.editor.clientSecret && csrfToken)
18
+ enable: !!(config.editor.clientId && config.editor.clientSecret)
21
19
  }
22
20
  );
23
21
  const oAuth2AccessToken = data?.data;
@@ -1 +1 @@
1
- {"version":3,"file":"useOAuth2.cjs","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAsync } from '../../../hooks/useAsync/useAsync';\n\nexport const useOAuth2 = (\n csrfToken: string | null | undefined,\n intlayerConfiguration?: IntlayerConfig\n) => {\n const configuration = useConfiguration();\n const config = intlayerConfiguration ?? configuration ?? getConfiguration();\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n const { data } = useAsync(\n 'getOAuth2AccessToken',\n () =>\n intlayerAPI.auth.getOAuth2AccessToken({\n body: { csrf_token: csrfToken },\n }),\n {\n cache: true,\n autoFetch: true,\n enable: !!(\n config.editor.clientId &&\n config.editor.clientSecret &&\n csrfToken\n ),\n }\n );\n\n const oAuth2AccessToken = data?.data;\n\n return {\n oAuth2AccessToken,\n };\n};\n"],"names":["useConfiguration","getConfiguration","getIntlayerAPI","useAsync"],"mappings":";;;;;;;AAOa,MAAA,YAAY,CACvB,WACA,0BACG;AACH,QAAM,gBAAgBA,YAAAA,iBAAiB;AACjC,QAAA,SAAS,yBAAyB,iBAAiBC,wBAAiB;AACpE,QAAA,cAAcC,IAAAA,eAAe,QAAW,MAAM;AAE9C,QAAA,EAAE,SAASC,wBAAA;AAAA,IACf;AAAA,IACA,MACE,YAAY,KAAK,qBAAqB;AAAA,MACpC,MAAM,EAAE,YAAY,UAAU;AAAA,IAAA,CAC/B;AAAA,IACH;AAAA,MACE,OAAO;AAAA,MACP,WAAW;AAAA,MACX,QAAQ,CAAC,EACP,OAAO,OAAO,YACd,OAAO,OAAO,gBACd;AAAA,IAAA;AAAA,EAGN;AAEA,QAAM,oBAAoB,MAAM;AAEzB,SAAA;AAAA,IACL;AAAA,EACF;AACF;;"}
1
+ {"version":3,"file":"useOAuth2.cjs","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAsync } from '../../../hooks/useAsync/useAsync';\n\nexport const useOAuth2 = (intlayerConfiguration?: IntlayerConfig) => {\n const configuration = useConfiguration();\n const config = intlayerConfiguration ?? configuration ?? getConfiguration();\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n const { data } = useAsync(\n 'getOAuth2AccessToken',\n () => intlayerAPI.auth.getOAuth2AccessToken(),\n {\n cache: true,\n autoFetch: true,\n enable: !!(config.editor.clientId && config.editor.clientSecret),\n }\n );\n\n const oAuth2AccessToken = data?.data;\n\n return {\n oAuth2AccessToken,\n };\n};\n"],"names":["useConfiguration","getConfiguration","getIntlayerAPI","useAsync"],"mappings":";;;;;;;AAOa,MAAA,YAAY,CAAC,0BAA2C;AACnE,QAAM,gBAAgBA,YAAAA,iBAAiB;AACjC,QAAA,SAAS,yBAAyB,iBAAiBC,wBAAiB;AACpE,QAAA,cAAcC,IAAAA,eAAe,QAAW,MAAM;AAE9C,QAAA,EAAE,SAASC,wBAAA;AAAA,IACf;AAAA,IACA,MAAM,YAAY,KAAK,qBAAqB;AAAA,IAC5C;AAAA,MACE,OAAO;AAAA,MACP,WAAW;AAAA,MACX,QAAQ,CAAC,EAAE,OAAO,OAAO,YAAY,OAAO,OAAO;AAAA,IAAA;AAAA,EAEvD;AAEA,QAAM,oBAAoB,MAAM;AAEzB,SAAA;AAAA,IACL;AAAA,EACF;AACF;;"}
@@ -1,5 +1,5 @@
1
1
  import { IntlayerConfig } from '@intlayer/config/client';
2
- export declare const useOAuth2: (csrfToken: string | null | undefined, intlayerConfiguration?: IntlayerConfig) => {
2
+ export declare const useOAuth2: (intlayerConfiguration?: IntlayerConfig) => {
3
3
  oAuth2AccessToken: import('@intlayer/backend').OAuth2Token | null | undefined;
4
4
  };
5
5
  //# sourceMappingURL=useOAuth2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useOAuth2.d.ts","sourceRoot":"","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIhF,eAAO,MAAM,SAAS,cACT,MAAM,GAAG,IAAI,GAAG,SAAS,0BACZ,cAAc;;CA4BvC,CAAC"}
1
+ {"version":3,"file":"useOAuth2.d.ts","sourceRoot":"","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIhF,eAAO,MAAM,SAAS,2BAA4B,cAAc;;CAoB/D,CAAC"}
@@ -3,19 +3,17 @@ import { getIntlayerAPI } from "@intlayer/api";
3
3
  import { getConfiguration } from "@intlayer/config/client";
4
4
  import { useConfiguration } from "@intlayer/editor-react";
5
5
  import { useAsync } from "../../../hooks/useAsync/useAsync.mjs";
6
- const useOAuth2 = (csrfToken, intlayerConfiguration) => {
6
+ const useOAuth2 = (intlayerConfiguration) => {
7
7
  const configuration = useConfiguration();
8
8
  const config = intlayerConfiguration ?? configuration ?? getConfiguration();
9
9
  const intlayerAPI = getIntlayerAPI(void 0, config);
10
10
  const { data } = useAsync(
11
11
  "getOAuth2AccessToken",
12
- () => intlayerAPI.auth.getOAuth2AccessToken({
13
- body: { csrf_token: csrfToken }
14
- }),
12
+ () => intlayerAPI.auth.getOAuth2AccessToken(),
15
13
  {
16
14
  cache: true,
17
15
  autoFetch: true,
18
- enable: !!(config.editor.clientId && config.editor.clientSecret && csrfToken)
16
+ enable: !!(config.editor.clientId && config.editor.clientSecret)
19
17
  }
20
18
  );
21
19
  const oAuth2AccessToken = data?.data;
@@ -1 +1 @@
1
- {"version":3,"file":"useOAuth2.mjs","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAsync } from '../../../hooks/useAsync/useAsync';\n\nexport const useOAuth2 = (\n csrfToken: string | null | undefined,\n intlayerConfiguration?: IntlayerConfig\n) => {\n const configuration = useConfiguration();\n const config = intlayerConfiguration ?? configuration ?? getConfiguration();\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n const { data } = useAsync(\n 'getOAuth2AccessToken',\n () =>\n intlayerAPI.auth.getOAuth2AccessToken({\n body: { csrf_token: csrfToken },\n }),\n {\n cache: true,\n autoFetch: true,\n enable: !!(\n config.editor.clientId &&\n config.editor.clientSecret &&\n csrfToken\n ),\n }\n );\n\n const oAuth2AccessToken = data?.data;\n\n return {\n oAuth2AccessToken,\n };\n};\n"],"names":[],"mappings":";;;;;AAOa,MAAA,YAAY,CACvB,WACA,0BACG;AACH,QAAM,gBAAgB,iBAAiB;AACjC,QAAA,SAAS,yBAAyB,iBAAiB,iBAAiB;AACpE,QAAA,cAAc,eAAe,QAAW,MAAM;AAE9C,QAAA,EAAE,SAAS;AAAA,IACf;AAAA,IACA,MACE,YAAY,KAAK,qBAAqB;AAAA,MACpC,MAAM,EAAE,YAAY,UAAU;AAAA,IAAA,CAC/B;AAAA,IACH;AAAA,MACE,OAAO;AAAA,MACP,WAAW;AAAA,MACX,QAAQ,CAAC,EACP,OAAO,OAAO,YACd,OAAO,OAAO,gBACd;AAAA,IAAA;AAAA,EAGN;AAEA,QAAM,oBAAoB,MAAM;AAEzB,SAAA;AAAA,IACL;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useOAuth2.mjs","sources":["../../../../src/components/Auth/useAuth/useOAuth2.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config/client';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAsync } from '../../../hooks/useAsync/useAsync';\n\nexport const useOAuth2 = (intlayerConfiguration?: IntlayerConfig) => {\n const configuration = useConfiguration();\n const config = intlayerConfiguration ?? configuration ?? getConfiguration();\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n const { data } = useAsync(\n 'getOAuth2AccessToken',\n () => intlayerAPI.auth.getOAuth2AccessToken(),\n {\n cache: true,\n autoFetch: true,\n enable: !!(config.editor.clientId && config.editor.clientSecret),\n }\n );\n\n const oAuth2AccessToken = data?.data;\n\n return {\n oAuth2AccessToken,\n };\n};\n"],"names":[],"mappings":";;;;;AAOa,MAAA,YAAY,CAAC,0BAA2C;AACnE,QAAM,gBAAgB,iBAAiB;AACjC,QAAA,SAAS,yBAAyB,iBAAiB,iBAAiB;AACpE,QAAA,cAAc,eAAe,QAAW,MAAM;AAE9C,QAAA,EAAE,SAAS;AAAA,IACf;AAAA,IACA,MAAM,YAAY,KAAK,qBAAqB;AAAA,IAC5C;AAAA,MACE,OAAO;AAAA,MACP,WAAW;AAAA,MACX,QAAQ,CAAC,EAAE,OAAO,OAAO,YAAY,OAAO,OAAO;AAAA,IAAA;AAAA,EAEvD;AAEA,QAAM,oBAAoB,MAAM;AAEzB,SAAA;AAAA,IACL;AAAA,EACF;AACF;"}
@@ -77,9 +77,11 @@ const SaveForm = ({
77
77
  ...dictionary,
78
78
  ...editedContent?.[dictionary.key]
79
79
  };
80
- await pushDictionaries([updatedDictionary]).then(() => {
81
- setLocaleDictionary(editedContent?.[dictionary.key]);
82
- restoreEditedContent(dictionary.key);
80
+ await pushDictionaries([updatedDictionary]).then((res) => {
81
+ if (res) {
82
+ setLocaleDictionary(editedContent?.[dictionary.key]);
83
+ restoreEditedContent(dictionary.key);
84
+ }
83
85
  });
84
86
  };
85
87
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -119,7 +121,7 @@ const SaveForm = ({
119
121
  components_Form_layout_FormItemLayout.Form.Button,
120
122
  {
121
123
  label: publishButton.label.value,
122
- disabled: !isEdited,
124
+ disabled: isLoading,
123
125
  Icon: lucideReact.ArrowUpFromLine,
124
126
  color: "text",
125
127
  className: "max-md:w-full",
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={!isEdited}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":["useDictionariesRecordActions","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","useMemo","jsxs","cn","jsx","Form","RotateCcw","Download","ArrowUpFromLine","Save"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAIA,yCAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;AACrE,QAAM,EAAE,kBAA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YACX,SAAS;AAAA,YAER,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAEN;AAEJ;;"}
1
+ {"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":["useDictionariesRecordActions","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","useMemo","jsxs","cn","jsx","Form","RotateCcw","Download","ArrowUpFromLine","Save"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAIA,yCAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAcC,uBAAAA,oBAAoB;AACvE,QAAM,YAAY,aAAa;AAE/B,QAAM,EAAE,eAAe,qBAAqB,IAAIC,6BAAiB;AACjE,QAAM,EAAE,aAAa,YAAY,eAAe,eAAe,IAC7DC,4BAAcC,gFAAqB;AAC/B,QAAA,EAAE,gBAAgB,IAAIC,sCAAQ;AAEpC,QAAM,mBAAmBC,aAAA;AAAA,IACvB,MAAM,gBAAgB,WAAW,GAAG;AAAA,IACpC,CAAC,eAAe,WAAW,GAAG;AAAA,EAChC;AAEA,QAAM,WAAWA,aAAA;AAAA,IACf,MACE,oBACA,KAAK,UAAU,gBAAgB,MAAM,KAAK,UAAU,UAAU;AAAA,IAChE,CAAC,kBAAkB,YAAY,IAAI;AAAA,EACrC;AAEA,QAAM,oBAAoBA,aAAA;AAAA,IACxB,MAAM,OAAQ,YAAkC,QAAQ;AAAA,IACxD,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,uBAAuB,YAAY;AACvC,QAAI,CAAC,gBAAgB,WAAW,GAAG,EAAG;AAEtC,UAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,GAAG,gBAAgB,WAAW,GAAG;AAAA,IACnC;AAEA,UAAM,gBAAgB,iBAAiB,EAAE,KAAK,MAAM;AAC9B,0BAAA,gBAAgB,WAAW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A,UAAL;AAAA,YACC,OAAO,cAAc,MAAM;AAAA,YAC3B,UAAU;AAAA,YACV,MAAMG,YAAA;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAc,cAAA;AAAA,UAAA;AAAA,QACjB;AAAA,QAED,KAAK,SAAS,QAAQ,KACrB,mBACA,CAAC,qBACD,YACEJ,2BAAA;AAAA,UAACC,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,WAAW,MAAM;AAAA,YACxB,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMI,YAAA;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAEN;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAEvB,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAQf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC9B,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CA4H/C,CAAC"}
1
+ {"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAEvB,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAQf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC9B,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CA8H/C,CAAC"}
@@ -75,9 +75,11 @@ const SaveForm = ({
75
75
  ...dictionary,
76
76
  ...editedContent?.[dictionary.key]
77
77
  };
78
- await pushDictionaries([updatedDictionary]).then(() => {
79
- setLocaleDictionary(editedContent?.[dictionary.key]);
80
- restoreEditedContent(dictionary.key);
78
+ await pushDictionaries([updatedDictionary]).then((res) => {
79
+ if (res) {
80
+ setLocaleDictionary(editedContent?.[dictionary.key]);
81
+ restoreEditedContent(dictionary.key);
82
+ }
81
83
  });
82
84
  };
83
85
  return /* @__PURE__ */ jsxs(
@@ -117,7 +119,7 @@ const SaveForm = ({
117
119
  Form.Button,
118
120
  {
119
121
  label: publishButton.label.value,
120
- disabled: !isEdited,
122
+ disabled: isLoading,
121
123
  Icon: ArrowUpFromLine,
122
124
  color: "text",
123
125
  className: "max-md:w-full",
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={!isEdited}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAc,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAc,oBAAoB;AACvE,QAAM,YAAY,aAAa;AAE/B,QAAM,EAAE,eAAe,qBAAqB,IAAI,iBAAiB;AACjE,QAAM,EAAE,aAAa,YAAY,eAAe,eAAe,IAC7D,cAAc,qBAAqB;AAC/B,QAAA,EAAE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,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,qBAAqB,WAAW,GAAG;AAAA,YAEjD,UAAY,YAAA;AAAA,UAAA;AAAA,QACf;AAAA,QAED,KAAK,SAAS,OAAO,KACpB;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,eAAe,MAAM;AAAA,YAC5B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAM;AAAA,YACN,OAAM;AAAA,YACN,SAAS,kBAAkB,YAAY;AAAA,YACvC,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAe,eAAA;AAAA,UAAA;AAAA,QAClB;AAAA,QAED,KAAK,SAAS,QAAQ,KAAK,mBAAmB,qBAC7C;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,cAAc,MAAM;AAAA,YAC3B,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAc,cAAA;AAAA,UAAA;AAAA,QACjB;AAAA,QAED,KAAK,SAAS,QAAQ,KACrB,mBACA,CAAC,qBACD,YACE;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,WAAW,MAAM;AAAA,YACxB,UAAU,CAAC,YAAY;AAAA,YACvB,MAAM;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAEN;AAEJ;"}
1
+ {"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAc,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAc,oBAAoB;AACvE,QAAM,YAAY,aAAa;AAE/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(keyWithArgs);
46
- const fetch = ReactExports.useCallback(
47
- async (...args2) => {
48
- const keyWithArgs2 = getKeyWithArgs(key, args2);
49
- if (controllerRef.current) {
50
- controllerRef.current.abort();
51
- }
52
- const controller = new AbortController();
53
- controllerRef.current = controller;
54
- if (pendingPromises.has(keyWithArgs2)) {
55
- return pendingPromises.get(keyWithArgs2);
56
- }
57
- const promise = (async () => {
58
- setQueryState(keyWithArgs2, { isLoading: true });
59
- let response = null;
60
- await asyncFunction(...args2).then((result) => {
61
- response = result;
62
- setQueryState(keyWithArgs2, {
63
- data: result,
64
- errorCount: 0,
65
- isLoading: false,
66
- isFetched: true,
67
- fetchedDateTime: /* @__PURE__ */ new Date(),
68
- isSuccess: true,
69
- isInvalidated: false,
70
- error: null
71
- });
72
- onSuccess?.(result);
73
- if (invalidateQueries.length > 0) {
74
- setQueriesState(invalidateQueries, {
75
- isInvalidated: true
76
- });
77
- }
78
- if (updateQueries.length > 0) {
79
- setQueriesState(updateQueries, {
80
- data: result
81
- });
82
- }
83
- if (storeEnabled) {
84
- localStorage.setItem(keyWithArgs2, JSON.stringify(result));
85
- }
86
- }).catch((error2) => {
87
- const msg = error2 instanceof Error ? error2.message : String(error2);
88
- makeQueryInError(keyWithArgs2, msg);
89
- onError?.(error2.message);
90
- }).finally(() => {
91
- pendingPromises.delete(keyWithArgs2);
46
+ const fetch = async (...args2) => {
47
+ const keyWithArgs2 = getKeyWithArgs(key, args2);
48
+ if (controllerRef.current) {
49
+ controllerRef.current.abort();
50
+ }
51
+ const controller = new AbortController();
52
+ controllerRef.current = controller;
53
+ if (pendingPromises.has(keyWithArgs2)) {
54
+ return pendingPromises.get(keyWithArgs2);
55
+ }
56
+ const promise = (async () => {
57
+ setQueryState(keyWithArgs2, { isLoading: true });
58
+ let response = null;
59
+ await asyncFunction(...args2).then((result) => {
60
+ response = result;
61
+ setQueryState(keyWithArgs2, {
62
+ data: result,
63
+ errorCount: 0,
64
+ isLoading: false,
65
+ isFetched: true,
66
+ fetchedDateTime: /* @__PURE__ */ new Date(),
67
+ isSuccess: true,
68
+ isInvalidated: false,
69
+ error: null
92
70
  });
93
- return response;
94
- })();
95
- pendingPromises.set(keyWithArgs2, promise);
96
- return await promise;
97
- },
98
- [asyncFunction, keyWithArgs, storeEnabled, cacheEnabled, onSuccess, onError]
99
- );
100
- const revalidate = ReactExports.useCallback(
101
- async (...args2) => {
102
- if (!isEnabled || !enabled) return;
103
- if (args2) {
104
- storedArgsRef.current = getArgs(args2);
105
- }
106
- return await fetch(...storedArgsRef.current);
107
- },
108
- [isEnabled, enabled, storedArgsRef, fetch]
109
- );
110
- const execute = ReactExports.useCallback(
111
- async (...args2) => {
112
- if (!isEnabled || !enabled) return;
113
- if (isLoading) return;
114
- const shouldReturnData = !isInvalidated && // If data are invalidated, we should refetch to revalidate the data
115
- isSuccess && cacheEnabled && data;
116
- if (shouldReturnData) return data;
117
- return await revalidate(...args2);
118
- },
119
- [
120
- isEnabled,
121
- enabled,
122
- isInvalidated,
123
- cacheEnabled,
124
- isSuccess,
125
- data,
126
- isLoading,
127
- revalidate
128
- ]
129
- );
71
+ onSuccess?.(result);
72
+ if (invalidateQueries.length > 0) {
73
+ setQueriesState(invalidateQueries, {
74
+ isInvalidated: true
75
+ });
76
+ }
77
+ if (updateQueries.length > 0) {
78
+ setQueriesState(updateQueries, {
79
+ data: result
80
+ });
81
+ }
82
+ if (storeEnabled) {
83
+ localStorage.setItem(keyWithArgs2, JSON.stringify(result));
84
+ }
85
+ }).catch((error2) => {
86
+ const msg = error2 instanceof Error ? error2.message : String(error2);
87
+ makeQueryInError(keyWithArgs2, msg);
88
+ onError?.(error2.message);
89
+ }).finally(() => {
90
+ pendingPromises.delete(keyWithArgs2);
91
+ });
92
+ return response;
93
+ })();
94
+ pendingPromises.set(keyWithArgs2, promise);
95
+ return await promise;
96
+ };
97
+ const revalidate = async (...args2) => {
98
+ if (!isEnabled || !enabled) return;
99
+ if (args2) {
100
+ storedArgsRef.current = getArgs(args2);
101
+ }
102
+ return await fetch(...storedArgsRef.current);
103
+ };
104
+ const execute = async (...args2) => {
105
+ if (!isEnabled || !enabled) return;
106
+ if (isLoading) return;
107
+ const shouldReturnData = !isInvalidated && // If data are invalidated, we should refetch to revalidate the data
108
+ isSuccess && cacheEnabled && data;
109
+ if (shouldReturnData) return data;
110
+ return await revalidate(...args2);
111
+ };
130
112
  ReactExports.useEffect(() => {
131
113
  if (enabled !== isEnabled) {
132
114
  setQueryState(keyWithArgs, {
@@ -219,49 +201,30 @@ const useAsync = (key, asyncFunction, options) => {
219
201
  enabled,
220
202
  fetch
221
203
  ]);
222
- const setDataMemo = ReactExports.useCallback(
223
- (data2) => {
224
- setQueryState(keyWithArgs, {
225
- data: data2
226
- });
227
- },
228
- [keyWithArgs]
229
- );
230
- const memoResult = ReactExports.useMemo(
231
- () => ({
232
- isFetched,
233
- isInvalidated,
234
- error,
235
- data,
236
- errorCount,
237
- isSuccess,
238
- isEnabled,
239
- isDisabled: !isEnabled,
240
- isLoading,
241
- isWaitingData: isLoading && !isFetched && !data,
242
- // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage
243
- isRevalidating: isLoading && isFetched,
244
- // Check if the data is valid and is being revalidated
245
- [key]: execute,
246
- // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)
247
- revalidate,
248
- setData: setDataMemo
249
- }),
250
- [
251
- isFetched,
252
- isLoading,
253
- isInvalidated,
254
- error,
255
- isSuccess,
256
- data,
257
- errorCount,
258
- isEnabled,
259
- key,
260
- execute,
261
- revalidate,
262
- setDataMemo
263
- ]
264
- );
204
+ const setDataMemo = (data2) => {
205
+ setQueryState(keyWithArgs, {
206
+ data: data2
207
+ });
208
+ };
209
+ const memoResult = {
210
+ isFetched,
211
+ isInvalidated,
212
+ error,
213
+ data,
214
+ errorCount,
215
+ isSuccess,
216
+ isEnabled,
217
+ isDisabled: !isEnabled,
218
+ isLoading,
219
+ isWaitingData: isLoading && !isFetched && !data,
220
+ // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage
221
+ isRevalidating: isLoading && isFetched,
222
+ // Check if the data is valid and is being revalidated
223
+ [key]: execute,
224
+ // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)
225
+ revalidate,
226
+ setData: setDataMemo
227
+ };
265
228
  ReactExports.useEffect(
266
229
  () => () => {
267
230
  if (controllerRef.current) {