@intlayer/design-system 5.1.6 → 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 (39) hide show
  1. package/dist/.vite/manifest.json +21 -1
  2. package/dist/components/Auth/useAuth/index.cjs +13 -26
  3. package/dist/components/Auth/useAuth/index.cjs.map +1 -1
  4. package/dist/components/Auth/useAuth/index.d.ts.map +1 -1
  5. package/dist/components/Auth/useAuth/index.mjs +13 -26
  6. package/dist/components/Auth/useAuth/index.mjs.map +1 -1
  7. package/dist/components/Auth/useAuth/useOAuth2.cjs +3 -5
  8. package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -1
  9. package/dist/components/Auth/useAuth/useOAuth2.d.ts +1 -1
  10. package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -1
  11. package/dist/components/Auth/useAuth/useOAuth2.mjs +3 -5
  12. package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -1
  13. package/dist/components/ContentEditor/ContentEditorTextArea.cjs +30 -0
  14. package/dist/components/ContentEditor/ContentEditorTextArea.cjs.map +1 -1
  15. package/dist/components/ContentEditor/ContentEditorTextArea.d.ts.map +1 -1
  16. package/dist/components/ContentEditor/ContentEditorTextArea.mjs +30 -0
  17. package/dist/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
  18. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
  19. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
  20. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
  21. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +6 -4
  22. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  23. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +6 -4
  25. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  26. package/dist/hooks/useAsync/useAsync.cjs +89 -126
  27. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  28. package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
  29. package/dist/hooks/useAsync/useAsync.mjs +90 -127
  30. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  31. package/dist/hooks/useIntlayerAPI.cjs +11 -21
  32. package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
  33. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  34. package/dist/hooks/useIntlayerAPI.mjs +11 -21
  35. package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
  36. package/dist/index-BCuMWKyy.js.map +1 -1
  37. package/dist/index-BYzBot7l.cjs.map +1 -1
  38. package/dist/tailwind.css +1 -1
  39. package/package.json +19 -19
@@ -658,7 +658,27 @@
658
658
  "src/components/Button/Button.tsx",
659
659
  "src/components/Input/Input.tsx",
660
660
  "src/components/Input/Checkbox.tsx",
661
- "src/components/TextArea/AutocompleteTextArea.tsx"
661
+ "src/components/TextArea/AutocompleteTextArea.tsx",
662
+ "_index-a_-DkvMQ.cjs",
663
+ "src/components/Auth/useUser/index.ts",
664
+ "src/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.ts",
665
+ "src/components/Form/FormField.tsx",
666
+ "_Form-BpxW17v4.cjs",
667
+ "src/components/Auth/SignInForm/signIn.content.ts",
668
+ "src/components/Auth/SignInForm/useSignInSchema.content.ts",
669
+ "src/components/Auth/SignUpForm/signUpForm.content.ts",
670
+ "src/components/Auth/SignUpForm/useSignUpSchema.content.ts",
671
+ "src/components/Auth/ChangePasswordForm/changePasswordForm.content.ts",
672
+ "src/components/Auth/ChangePasswordForm/useChangePasswordSchema.content.ts",
673
+ "src/components/Auth/ResetPasswordForm/resetPasswordContent.content.ts",
674
+ "src/components/Auth/ResetPasswordForm/useResetPasswordSchema.content.ts",
675
+ "src/hooks/useScrollBlockage/useScrollBlockageStore.ts",
676
+ "src/hooks/useAsync/useAsyncStateStore.tsx",
677
+ "src/components/Toaster/Toast.tsx",
678
+ "src/components/Modal/Modal.tsx",
679
+ "src/components/Auth/VerifyEmailForm/index.content.ts",
680
+ "src/components/Auth/DefineNewPasswordForm/defineNewPasswordForm.content.ts",
681
+ "src/components/Auth/DefineNewPasswordForm/useDefineNewPasswordSchema.content.ts"
662
682
  ]
663
683
  },
664
684
  "src/components/ContentEditor/index.ts": {
@@ -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":[],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./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;"}
@@ -10,6 +10,34 @@ require("tailwind-merge");
10
10
  require("../Input/Input.cjs");
11
11
  require("../Input/Checkbox.cjs");
12
12
  const components_TextArea_AutocompleteTextArea = require("../TextArea/AutocompleteTextArea.cjs");
13
+ require("react-intlayer");
14
+ require("../../index-a_-DkvMQ.cjs");
15
+ require("@intlayer/config/client");
16
+ const components_Auth_useUser_index = require("../Auth/useUser/index.cjs");
17
+ require("../Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs");
18
+ require("@hookform/resolvers");
19
+ require("react-hook-form");
20
+ require("../Form/FormField.cjs");
21
+ require("../../Form-BpxW17v4.cjs");
22
+ require("../Auth/SignInForm/signIn.content.cjs");
23
+ require("zod");
24
+ require("../Auth/SignInForm/useSignInSchema.content.cjs");
25
+ require("../Auth/SignUpForm/signUpForm.content.cjs");
26
+ require("../Auth/SignUpForm/useSignUpSchema.content.cjs");
27
+ require("../Auth/ChangePasswordForm/changePasswordForm.content.cjs");
28
+ require("../Auth/ChangePasswordForm/useChangePasswordSchema.content.cjs");
29
+ require("../Auth/ResetPasswordForm/resetPasswordContent.content.cjs");
30
+ require("../Auth/ResetPasswordForm/useResetPasswordSchema.content.cjs");
31
+ require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
32
+ require("../../hooks/useAsync/useAsyncStateStore.cjs");
33
+ require("@intlayer/editor-react");
34
+ require("@intlayer/api");
35
+ require("../Toaster/Toast.cjs");
36
+ require("deepmerge");
37
+ require("../Modal/Modal.cjs");
38
+ require("../Auth/VerifyEmailForm/index.content.cjs");
39
+ require("../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.cjs");
40
+ require("../Auth/DefineNewPasswordForm/useDefineNewPasswordSchema.content.cjs");
13
41
  const ContentEditorTextArea = ({
14
42
  children,
15
43
  onContentChange,
@@ -18,6 +46,7 @@ const ContentEditorTextArea = ({
18
46
  additionalButtons,
19
47
  ...props
20
48
  }) => {
49
+ const { isAuthenticated } = components_Auth_useUser_index.useUser();
21
50
  const [newValue, setNewValue] = ReactExports.useState(children);
22
51
  const [resetIncrementor, setResetIncrementor] = ReactExports.useState(0);
23
52
  const isEdited = newValue !== children;
@@ -45,6 +74,7 @@ const ContentEditorTextArea = ({
45
74
  variant: "invisible",
46
75
  className: "size-full",
47
76
  defaultValue: children,
77
+ isActive: isAuthenticated,
48
78
  ...props
49
79
  },
50
80
  resetIncrementor
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditorTextArea.cjs","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"sourcesContent":["'use client';\n\nimport { Check, X } from 'lucide-react';\nimport {\n type ReactNode,\n useState,\n type FC,\n type ChangeEventHandler,\n useEffect,\n} from 'react';\nimport { Button } from '../Button';\nimport { type AutoSizedTextAreaProps, AutoCompleteTextarea } from '../TextArea';\n\nexport type ContentEditorTextAreaProps = {\n children: string;\n onContentChange: (content: string) => void;\n disabled?: boolean;\n validate?: (content: string) => boolean;\n additionalButtons?: ReactNode;\n} & Omit<AutoSizedTextAreaProps, 'children'>;\n\nexport const ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n children,\n onContentChange,\n disabled,\n validate,\n additionalButtons,\n ...props\n}) => {\n const [newValue, setNewValue] = useState<string>(children);\n const [resetIncrementor, setResetIncrementor] = useState<number>(0); // To reset the div on cancel\n const isEdited: boolean = newValue !== children;\n\n const handleCancel = () => {\n setNewValue(children);\n setResetIncrementor((prev) => prev + 1);\n };\n const handleValid = () => {\n onContentChange(newValue);\n };\n\n const handleOnContentChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setNewValue(e.currentTarget.value ?? '');\n\n useEffect(() => {\n setNewValue(children);\n }, [children]);\n\n const isValid = validate?.(newValue) ?? true;\n\n return (\n <div\n className=\"flex size-full flex-col items-center justify-between gap-2\"\n key={children}\n >\n <AutoCompleteTextarea\n onChange={handleOnContentChange}\n key={resetIncrementor}\n variant=\"invisible\"\n className=\"size-full\"\n defaultValue={children}\n {...props}\n />\n {(isEdited || additionalButtons) && (\n <div className=\"flex w-full items-center justify-end gap-2\">\n {isEdited && (\n <>\n <Button\n Icon={Check}\n label=\"Validate\"\n variant=\"hoverable\"\n color=\"text\"\n size=\"icon-sm\"\n className=\"cursor-pointer hover:scale-110\"\n disabled={disabled || !isValid}\n onClick={handleValid}\n />\n <Button\n Icon={X}\n label=\"Cancel\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n onClick={handleCancel}\n />\n </>\n )}\n {additionalButtons}\n </div>\n )}\n </div>\n );\n};\n"],"names":["useState","useEffect","jsxs","jsx","AutoCompleteTextarea","Fragment","Button","Check","X"],"mappings":";;;;;;;;;;;;AAqBO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,CAAC,UAAU,WAAW,IAAIA,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AA,gBACV,SAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UACX,GACF;AAAA,UAED;AAAA,QAAA,EACH,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IApCG;AAAA,EAsCP;AAEJ;;"}
1
+ {"version":3,"file":"ContentEditorTextArea.cjs","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"sourcesContent":["'use client';\n\nimport { Check, X } from 'lucide-react';\nimport {\n type ReactNode,\n useState,\n type FC,\n type ChangeEventHandler,\n useEffect,\n} from 'react';\nimport { Button } from '../Button';\nimport { type AutoSizedTextAreaProps, AutoCompleteTextarea } from '../TextArea';\nimport { useUser } from '../Auth';\n\nexport type ContentEditorTextAreaProps = {\n children: string;\n onContentChange: (content: string) => void;\n disabled?: boolean;\n validate?: (content: string) => boolean;\n additionalButtons?: ReactNode;\n} & Omit<AutoSizedTextAreaProps, 'children'>;\n\nexport const ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n children,\n onContentChange,\n disabled,\n validate,\n additionalButtons,\n ...props\n}) => {\n const { isAuthenticated } = useUser();\n const [newValue, setNewValue] = useState<string>(children);\n const [resetIncrementor, setResetIncrementor] = useState<number>(0); // To reset the div on cancel\n const isEdited: boolean = newValue !== children;\n\n const handleCancel = () => {\n setNewValue(children);\n setResetIncrementor((prev) => prev + 1);\n };\n const handleValid = () => {\n onContentChange(newValue);\n };\n\n const handleOnContentChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setNewValue(e.currentTarget.value ?? '');\n\n useEffect(() => {\n setNewValue(children);\n }, [children]);\n\n const isValid = validate?.(newValue) ?? true;\n\n return (\n <div\n className=\"flex size-full flex-col items-center justify-between gap-2\"\n key={children}\n >\n <AutoCompleteTextarea\n onChange={handleOnContentChange}\n key={resetIncrementor}\n variant=\"invisible\"\n className=\"size-full\"\n defaultValue={children}\n isActive={isAuthenticated}\n {...props}\n />\n {(isEdited || additionalButtons) && (\n <div className=\"flex w-full items-center justify-end gap-2\">\n {isEdited && (\n <>\n <Button\n Icon={Check}\n label=\"Validate\"\n variant=\"hoverable\"\n color=\"text\"\n size=\"icon-sm\"\n className=\"cursor-pointer hover:scale-110\"\n disabled={disabled || !isValid}\n onClick={handleValid}\n />\n <Button\n Icon={X}\n label=\"Cancel\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n onClick={handleCancel}\n />\n </>\n )}\n {additionalButtons}\n </div>\n )}\n </div>\n );\n};\n"],"names":["useUser","useState","useEffect","jsxs","jsx","AutoCompleteTextarea","Fragment","Button","Check","X"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,gBAAgB,IAAIA,sCAAQ;AACpC,QAAM,CAAC,UAAU,WAAW,IAAIC,aAAAA,SAAiB,QAAQ;AACzD,QAAM,CAAC,kBAAkB,mBAAmB,IAAIA,aAAAA,SAAiB,CAAC;AAClE,QAAM,WAAoB,aAAa;AAEvC,QAAM,eAAe,MAAM;AACzB,gBAAY,QAAQ;AACA,wBAAA,CAAC,SAAS,OAAO,CAAC;AAAA,EACxC;AACA,QAAM,cAAc,MAAM;AACxB,oBAAgB,QAAQ;AAAA,EAC1B;AAEA,QAAM,wBAAiE,CAAC,MACtE,YAAY,EAAE,cAAc,SAAS,EAAE;AAEzCC,eAAAA,UAAU,MAAM;AACd,gBAAY,QAAQ;AAAA,EAAA,GACnB,CAAC,QAAQ,CAAC;AAEP,QAAA,UAAU,WAAW,QAAQ,KAAK;AAGtC,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MAGV,UAAA;AAAA,QAAAC,2BAAA;AAAA,UAACC,yCAAA;AAAA,UAAA;AAAA,YACC,UAAU;AAAA,YAEV,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,cAAc;AAAA,YACd,UAAU;AAAA,YACT,GAAG;AAAA,UAAA;AAAA,UALC;AAAA,QAMP;AAAA,SACE,YAAY,sBACXF,2BAAA,KAAA,OAAA,EAAI,WAAU,8CACZ,UAAA;AAAA,UAAA,YAEGA,2BAAA,KAAAG,qBAAA,EAAA,UAAA;AAAA,YAAAF,2BAAA;AAAA,cAACG,yBAAA;AAAA,cAAA;AAAA,gBACC,MAAMC,YAAA;AAAA,gBACN,OAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,UAAU,YAAY,CAAC;AAAA,gBACvB,SAAS;AAAA,cAAA;AAAA,YACX;AAAA,YACAJ,2BAAA;AAAA,cAACG,yBAAA;AAAA,cAAA;AAAA,gBACC,MAAME,YAAA;AAAA,gBACN,OAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UACX,GACF;AAAA,UAED;AAAA,QAAA,EACH,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IArCG;AAAA,EAuCP;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditorTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,sBAAsB,EAAwB,MAAM,aAAa,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,iBAAiB,CAAC,EAAE,SAAS,CAAC;CAC/B,GAAG,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;AAE7C,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAwEhE,CAAC"}
1
+ {"version":3,"file":"ContentEditorTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,sBAAsB,EAAwB,MAAM,aAAa,CAAC;AAGhF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,iBAAiB,CAAC,EAAE,SAAS,CAAC;CAC/B,GAAG,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;AAE7C,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CA0EhE,CAAC"}
@@ -8,6 +8,34 @@ import "tailwind-merge";
8
8
  import "../Input/Input.mjs";
9
9
  import "../Input/Checkbox.mjs";
10
10
  import { AutoCompleteTextarea } from "../TextArea/AutocompleteTextArea.mjs";
11
+ import "react-intlayer";
12
+ import "../../index-DixKT3Hi.js";
13
+ import "@intlayer/config/client";
14
+ import { useUser } from "../Auth/useUser/index.mjs";
15
+ import "../Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs";
16
+ import "@hookform/resolvers";
17
+ import "react-hook-form";
18
+ import "../Form/FormField.mjs";
19
+ import "../../Form-MjLzPGze.js";
20
+ import "../Auth/SignInForm/signIn.content.mjs";
21
+ import "zod";
22
+ import "../Auth/SignInForm/useSignInSchema.content.mjs";
23
+ import "../Auth/SignUpForm/signUpForm.content.mjs";
24
+ import "../Auth/SignUpForm/useSignUpSchema.content.mjs";
25
+ import "../Auth/ChangePasswordForm/changePasswordForm.content.mjs";
26
+ import "../Auth/ChangePasswordForm/useChangePasswordSchema.content.mjs";
27
+ import "../Auth/ResetPasswordForm/resetPasswordContent.content.mjs";
28
+ import "../Auth/ResetPasswordForm/useResetPasswordSchema.content.mjs";
29
+ import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
30
+ import "../../hooks/useAsync/useAsyncStateStore.mjs";
31
+ import "@intlayer/editor-react";
32
+ import "@intlayer/api";
33
+ import "../Toaster/Toast.mjs";
34
+ import "deepmerge";
35
+ import "../Modal/Modal.mjs";
36
+ import "../Auth/VerifyEmailForm/index.content.mjs";
37
+ import "../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.mjs";
38
+ import "../Auth/DefineNewPasswordForm/useDefineNewPasswordSchema.content.mjs";
11
39
  const ContentEditorTextArea = ({
12
40
  children,
13
41
  onContentChange,
@@ -16,6 +44,7 @@ const ContentEditorTextArea = ({
16
44
  additionalButtons,
17
45
  ...props
18
46
  }) => {
47
+ const { isAuthenticated } = useUser();
19
48
  const [newValue, setNewValue] = useState(children);
20
49
  const [resetIncrementor, setResetIncrementor] = useState(0);
21
50
  const isEdited = newValue !== children;
@@ -43,6 +72,7 @@ const ContentEditorTextArea = ({
43
72
  variant: "invisible",
44
73
  className: "size-full",
45
74
  defaultValue: children,
75
+ isActive: isAuthenticated,
46
76
  ...props
47
77
  },
48
78
  resetIncrementor
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditorTextArea.mjs","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"sourcesContent":["'use client';\n\nimport { Check, X } from 'lucide-react';\nimport {\n type ReactNode,\n useState,\n type FC,\n type ChangeEventHandler,\n useEffect,\n} from 'react';\nimport { Button } from '../Button';\nimport { type AutoSizedTextAreaProps, AutoCompleteTextarea } from '../TextArea';\n\nexport type ContentEditorTextAreaProps = {\n children: string;\n onContentChange: (content: string) => void;\n disabled?: boolean;\n validate?: (content: string) => boolean;\n additionalButtons?: ReactNode;\n} & Omit<AutoSizedTextAreaProps, 'children'>;\n\nexport const ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n children,\n onContentChange,\n disabled,\n validate,\n additionalButtons,\n ...props\n}) => {\n const [newValue, setNewValue] = useState<string>(children);\n const [resetIncrementor, setResetIncrementor] = useState<number>(0); // To reset the div on cancel\n const isEdited: boolean = newValue !== children;\n\n const handleCancel = () => {\n setNewValue(children);\n setResetIncrementor((prev) => prev + 1);\n };\n const handleValid = () => {\n onContentChange(newValue);\n };\n\n const handleOnContentChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setNewValue(e.currentTarget.value ?? '');\n\n useEffect(() => {\n setNewValue(children);\n }, [children]);\n\n const isValid = validate?.(newValue) ?? true;\n\n return (\n <div\n className=\"flex size-full flex-col items-center justify-between gap-2\"\n key={children}\n >\n <AutoCompleteTextarea\n onChange={handleOnContentChange}\n key={resetIncrementor}\n variant=\"invisible\"\n className=\"size-full\"\n defaultValue={children}\n {...props}\n />\n {(isEdited || additionalButtons) && (\n <div className=\"flex w-full items-center justify-end gap-2\">\n {isEdited && (\n <>\n <Button\n Icon={Check}\n label=\"Validate\"\n variant=\"hoverable\"\n color=\"text\"\n size=\"icon-sm\"\n className=\"cursor-pointer hover:scale-110\"\n disabled={disabled || !isValid}\n onClick={handleValid}\n />\n <Button\n Icon={X}\n label=\"Cancel\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n onClick={handleCancel}\n />\n </>\n )}\n {additionalButtons}\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAqBO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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;AAAA,UAED;AAAA,QAAA,EACH,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IApCG;AAAA,EAsCP;AAEJ;"}
1
+ {"version":3,"file":"ContentEditorTextArea.mjs","sources":["../../../src/components/ContentEditor/ContentEditorTextArea.tsx"],"sourcesContent":["'use client';\n\nimport { Check, X } from 'lucide-react';\nimport {\n type ReactNode,\n useState,\n type FC,\n type ChangeEventHandler,\n useEffect,\n} from 'react';\nimport { Button } from '../Button';\nimport { type AutoSizedTextAreaProps, AutoCompleteTextarea } from '../TextArea';\nimport { useUser } from '../Auth';\n\nexport type ContentEditorTextAreaProps = {\n children: string;\n onContentChange: (content: string) => void;\n disabled?: boolean;\n validate?: (content: string) => boolean;\n additionalButtons?: ReactNode;\n} & Omit<AutoSizedTextAreaProps, 'children'>;\n\nexport const ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n children,\n onContentChange,\n disabled,\n validate,\n additionalButtons,\n ...props\n}) => {\n const { isAuthenticated } = useUser();\n const [newValue, setNewValue] = useState<string>(children);\n const [resetIncrementor, setResetIncrementor] = useState<number>(0); // To reset the div on cancel\n const isEdited: boolean = newValue !== children;\n\n const handleCancel = () => {\n setNewValue(children);\n setResetIncrementor((prev) => prev + 1);\n };\n const handleValid = () => {\n onContentChange(newValue);\n };\n\n const handleOnContentChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setNewValue(e.currentTarget.value ?? '');\n\n useEffect(() => {\n setNewValue(children);\n }, [children]);\n\n const isValid = validate?.(newValue) ?? true;\n\n return (\n <div\n className=\"flex size-full flex-col items-center justify-between gap-2\"\n key={children}\n >\n <AutoCompleteTextarea\n onChange={handleOnContentChange}\n key={resetIncrementor}\n variant=\"invisible\"\n className=\"size-full\"\n defaultValue={children}\n isActive={isAuthenticated}\n {...props}\n />\n {(isEdited || additionalButtons) && (\n <div className=\"flex w-full items-center justify-end gap-2\">\n {isEdited && (\n <>\n <Button\n Icon={Check}\n label=\"Validate\"\n variant=\"hoverable\"\n color=\"text\"\n size=\"icon-sm\"\n className=\"cursor-pointer hover:scale-110\"\n disabled={disabled || !isValid}\n onClick={handleValid}\n />\n <Button\n Icon={X}\n label=\"Cancel\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n onClick={handleCancel}\n />\n </>\n )}\n {additionalButtons}\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,gBAAgB,IAAI,QAAQ;AACpC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAiB,QAAQ;AACzD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAiB,CAAC;AAClE,QAAM,WAAoB,aAAa;AAEvC,QAAM,eAAe,MAAM;AACzB,gBAAY,QAAQ;AACA,wBAAA,CAAC,SAAS,OAAO,CAAC;AAAA,EACxC;AACA,QAAM,cAAc,MAAM;AACxB,oBAAgB,QAAQ;AAAA,EAC1B;AAEA,QAAM,wBAAiE,CAAC,MACtE,YAAY,EAAE,cAAc,SAAS,EAAE;AAEzC,YAAU,MAAM;AACd,gBAAY,QAAQ;AAAA,EAAA,GACnB,CAAC,QAAQ,CAAC;AAEP,QAAA,UAAU,WAAW,QAAQ,KAAK;AAGtC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MAGV,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,UAAU;AAAA,YAEV,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,cAAc;AAAA,YACd,UAAU;AAAA,YACT,GAAG;AAAA,UAAA;AAAA,UALC;AAAA,QAMP;AAAA,SACE,YAAY,sBACX,qBAAA,OAAA,EAAI,WAAU,8CACZ,UAAA;AAAA,UAAA,YAEG,qBAAA,UAAA,EAAA,UAAA;AAAA,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAM;AAAA,gBACN,OAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,UAAU,YAAY,CAAC;AAAA,gBACvB,SAAS;AAAA,cAAA;AAAA,YACX;AAAA,YACA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAM;AAAA,gBACN,OAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UACX,GACF;AAAA,UAED;AAAA,QAAA,EACH,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IArCG;AAAA,EAuCP;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringWrapper.cjs","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { cn } from '../../../utils/cn';\nimport { EditableFieldTextArea } from '../../EditableField';\nimport type { NodeWrapperProps } from './index';\n\ntype StringWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: string;\n};\n\nexport const StringWrapper: FC<StringWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const editedContentValue = getContentNodeByKeyPath(editedContent, keyPath);\n\n if (editedContentValue && typeof editedContentValue !== 'string') {\n return <>Error loading section</>;\n }\n\n const level = keyPath.length;\n\n const content = editedContentValue ?? section;\n\n return (\n <span\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <EditableFieldTextArea\n defaultValue={String(content)}\n onSave={(newValue) => onContentChange({ keyPath, newValue })}\n onCancel={() => null}\n />\n </span>\n );\n};\n"],"names":["getContentNodeByKeyPath","jsx","cn","EditableFieldTextArea"],"mappings":";;;;;;;;;;;AAWO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,qBAAqBA,KAAAA,wBAAwB,eAAe,OAAO;AAErE,MAAA,sBAAsB,OAAO,uBAAuB,UAAU;AAChE,iEAAS,UAAqB,wBAAA,CAAA;AAAA,EAAA;AAGhC,QAAM,QAAQ,QAAQ;AAEtB,QAAM,UAAU,sBAAsB;AAGpC,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAWC,SAAA;AAAA,QACT;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA,QACf,SAAS,KAAK;AAAA,MAChB;AAAA,MACA,SAAS,CAAC,MAAM;AACd,UAAE,gBAAgB;AAClB,uBAAe,OAAO;AAAA,MACxB;AAAA,MAEA,UAAAD,2BAAA;AAAA,QAACE,+CAAA;AAAA,QAAA;AAAA,UACC,cAAc,OAAO,OAAO;AAAA,UAC5B,QAAQ,CAAC,aAAa,gBAAgB,EAAE,SAAS,UAAU;AAAA,UAC3D,UAAU,MAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAEJ;;"}
1
+ {"version":3,"file":"StringWrapper.cjs","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"sourcesContent":["import { getContentNodeByKeyPath } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { cn } from '../../../utils/cn';\nimport { EditableFieldTextArea } from '../../EditableField';\nimport type { NodeWrapperProps } from './index';\n\ntype StringWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: string;\n};\n\nexport const StringWrapper: FC<StringWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const editedContentValue = getContentNodeByKeyPath(editedContent, keyPath);\n\n if (editedContentValue && typeof editedContentValue !== 'string') {\n return <>Error loading section</>;\n }\n\n const level = keyPath.length;\n\n const content = editedContentValue ?? section;\n\n return (\n <span\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <EditableFieldTextArea\n defaultValue={String(content)}\n onSave={(newValue) => onContentChange({ keyPath, newValue })}\n onCancel={() => null}\n />\n </span>\n );\n};\n"],"names":["getContentNodeByKeyPath","jsx","cn","EditableFieldTextArea"],"mappings":";;;;;;;;;;;AAUO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,qBAAqBA,KAAAA,wBAAwB,eAAe,OAAO;AAErE,MAAA,sBAAsB,OAAO,uBAAuB,UAAU;AAChE,iEAAS,UAAqB,wBAAA,CAAA;AAAA,EAAA;AAGhC,QAAM,QAAQ,QAAQ;AAEtB,QAAM,UAAU,sBAAsB;AAGpC,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAWC,SAAA;AAAA,QACT;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA,QACf,SAAS,KAAK;AAAA,MAChB;AAAA,MACA,SAAS,CAAC,MAAM;AACd,UAAE,gBAAgB;AAClB,uBAAe,OAAO;AAAA,MACxB;AAAA,MAEA,UAAAD,2BAAA;AAAA,QAACE,+CAAA;AAAA,QAAA;AAAA,UACC,cAAc,OAAO,OAAO;AAAA,UAC5B,QAAQ,CAAC,aAAa,gBAAgB,EAAE,SAAS,UAAU;AAAA,UAC3D,UAAU,MAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IAC5D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAuChD,CAAC"}
1
+ {"version":3,"file":"StringWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IAC5D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAuChD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringWrapper.mjs","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { cn } from '../../../utils/cn';\nimport { EditableFieldTextArea } from '../../EditableField';\nimport type { NodeWrapperProps } from './index';\n\ntype StringWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: string;\n};\n\nexport const StringWrapper: FC<StringWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const editedContentValue = getContentNodeByKeyPath(editedContent, keyPath);\n\n if (editedContentValue && typeof editedContentValue !== 'string') {\n return <>Error loading section</>;\n }\n\n const level = keyPath.length;\n\n const content = editedContentValue ?? section;\n\n return (\n <span\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <EditableFieldTextArea\n defaultValue={String(content)}\n onSave={(newValue) => onContentChange({ keyPath, newValue })}\n onCancel={() => null}\n />\n </span>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAWO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,qBAAqB,wBAAwB,eAAe,OAAO;AAErE,MAAA,sBAAsB,OAAO,uBAAuB,UAAU;AAChE,2CAAS,UAAqB,wBAAA,CAAA;AAAA,EAAA;AAGhC,QAAM,QAAQ,QAAQ;AAEtB,QAAM,UAAU,sBAAsB;AAGpC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA,QACf,SAAS,KAAK;AAAA,MAChB;AAAA,MACA,SAAS,CAAC,MAAM;AACd,UAAE,gBAAgB;AAClB,uBAAe,OAAO;AAAA,MACxB;AAAA,MAEA,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,cAAc,OAAO,OAAO;AAAA,UAC5B,QAAQ,CAAC,aAAa,gBAAgB,EAAE,SAAS,UAAU;AAAA,UAC3D,UAAU,MAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"StringWrapper.mjs","sources":["../../../../src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"],"sourcesContent":["import { getContentNodeByKeyPath } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { cn } from '../../../utils/cn';\nimport { EditableFieldTextArea } from '../../EditableField';\nimport type { NodeWrapperProps } from './index';\n\ntype StringWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: string;\n};\n\nexport const StringWrapper: FC<StringWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const editedContentValue = getContentNodeByKeyPath(editedContent, keyPath);\n\n if (editedContentValue && typeof editedContentValue !== 'string') {\n return <>Error loading section</>;\n }\n\n const level = keyPath.length;\n\n const content = editedContentValue ?? section;\n\n return (\n <span\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <EditableFieldTextArea\n defaultValue={String(content)}\n onSave={(newValue) => onContentChange({ keyPath, newValue })}\n onCancel={() => null}\n />\n </span>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAUO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,qBAAqB,wBAAwB,eAAe,OAAO;AAErE,MAAA,sBAAsB,OAAO,uBAAuB,UAAU;AAChE,2CAAS,UAAqB,wBAAA,CAAA;AAAA,EAAA;AAGhC,QAAM,QAAQ,QAAQ;AAEtB,QAAM,UAAU,sBAAsB;AAGpC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA,QACf,SAAS,KAAK;AAAA,MAChB;AAAA,MACA,SAAS,CAAC,MAAM;AACd,UAAE,gBAAgB;AAClB,uBAAe,OAAO;AAAA,MACxB;AAAA,MAEA,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,cAAc,OAAO,OAAO;AAAA,UAC5B,QAAQ,CAAC,aAAa,gBAAgB,EAAE,SAAS,UAAU;AAAA,UAC3D,UAAU,MAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAEJ;"}
@@ -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,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A;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.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,gBA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AK,mBAAmB,qBAC7CH,2BAAA;AAAA,UAACC,sCAAAA,KAAK;AAAA,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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B,UAAU,CAAC;AAAA,YACX,MAAM;AAAA,YACN,SAAQ;AAAA,YACR,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,kBAA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