@intlayer/design-system 9.0.0-canary.7 → 9.0.0-canary.9

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 (55) hide show
  1. package/dist/esm/api/index.mjs +2 -2
  2. package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
  3. package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs +41 -69
  4. package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  5. package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +2 -2
  6. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +47 -73
  7. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
  8. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs +0 -62
  9. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs.map +1 -1
  10. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs +2 -4
  11. package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs.map +1 -1
  12. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +70 -151
  13. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  14. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +1 -1
  15. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
  16. package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
  17. package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
  18. package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +2 -2
  19. package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -1
  20. package/dist/esm/components/Form/elements/OTPElement.mjs +1 -1
  21. package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
  22. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs +1 -1
  23. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
  24. package/dist/esm/components/Modal/Modal.mjs +2 -2
  25. package/dist/esm/components/Navbar/MobileNavbar.mjs +1 -1
  26. package/dist/esm/components/Pagination/Pagination.mjs +1 -1
  27. package/dist/esm/components/RightDrawer/RightDrawer.mjs +3 -3
  28. package/dist/esm/components/Tab/Tab.mjs +1 -1
  29. package/dist/esm/hooks/index.mjs +8 -8
  30. package/dist/types/api/useIntlayerAPI.d.ts +1 -1
  31. package/dist/types/components/Badge/index.d.ts +1 -1
  32. package/dist/types/components/Breadcrumb/index.d.ts +1 -1
  33. package/dist/types/components/Button/Button.d.ts +4 -4
  34. package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +1 -1
  35. package/dist/types/components/Command/index.d.ts +2 -2
  36. package/dist/types/components/Container/index.d.ts +6 -6
  37. package/dist/types/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
  38. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
  39. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +0 -62
  40. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts.map +1 -1
  41. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts +2 -4
  42. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts.map +1 -1
  43. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
  44. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +1 -1
  45. package/dist/types/components/Input/Checkbox.d.ts +3 -3
  46. package/dist/types/components/Input/Input.d.ts +1 -1
  47. package/dist/types/components/Input/Radio.d.ts +3 -3
  48. package/dist/types/components/Link/Link.d.ts +2 -2
  49. package/dist/types/components/Pagination/Pagination.d.ts +1 -1
  50. package/dist/types/components/SwitchSelector/SwitchSelector.d.ts +3 -3
  51. package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts +1 -1
  52. package/dist/types/components/TabSelector/TabSelector.d.ts +1 -1
  53. package/dist/types/components/Tag/index.d.ts +3 -3
  54. package/dist/types/components/Toaster/Toast.d.ts +1 -1
  55. package/package.json +15 -15
@@ -2,10 +2,11 @@ import { useOAuth2 } from "./useAuth/useOAuth2.mjs";
2
2
  import { useSession } from "./useAuth/useSession.mjs";
3
3
  import { useAuth } from "./useAuth/useAuth.mjs";
4
4
  import { useAiAPI, useAssetAPI, useAuditAPI, useBitbucketAPI, useDictionaryAPI, useEditorAPI, useEnvironmentAPI, useGithubAPI, useGitlabAPI, useIntlayerAuth, useIntlayerOAuth, useIntlayerOAuthOptions, useNewsletterAPI, useOAuthAPI, useOrganizationAPI, useProjectAPI, useReviewerAPI, useSearchAPI, useShowcaseProjectAPI, useStripeAPI, useTagAPI, useTranslateAPI, useUserAPI } from "./useIntlayerAPI.mjs";
5
+ import { useAddPasskey, useAskResetPassword, useChangePassword, useDeletePasskey, useDeleteSSOProvider, useDisableTwoFactor, useEnableTwoFactor, useGetUserByAccount, useGetVerifyEmailStatus, useLinkSocial, useListAccounts, useListPasskeys, useListSSOProviders, useLogin, useLogout, useRegister, useRegisterSSO, useResetPassword, useSignInMagicLink, useSignInPasskey, useSignInSSO, useUnlinkAccount, useVerifyBackupCode, useVerifyEmail, useVerifyTotp } from "./hooks/auth.mjs";
6
+ import { useUser } from "./useUser/index.mjs";
5
7
  import { useAskDocQuestion, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditTag, useAutocomplete, useChat, useCustomQuery, useGetAIStats, useTranslateJSONDeclaration } from "./hooks/ai.mjs";
6
8
  import { useDeleteAsset, useGetAssetById, useGetAssets, useUpdateAsset, useUploadAsset } from "./hooks/asset.mjs";
7
9
  import { useAuditScan, useGetRecursiveAuditStatus, useStartRecursiveAudit } from "./hooks/audit.mjs";
8
- import { useAddPasskey, useAskResetPassword, useChangePassword, useDeletePasskey, useDeleteSSOProvider, useDisableTwoFactor, useEnableTwoFactor, useGetUserByAccount, useGetVerifyEmailStatus, useLinkSocial, useListAccounts, useListPasskeys, useListSSOProviders, useLogin, useLogout, useRegister, useRegisterSSO, useResetPassword, useSignInMagicLink, useSignInPasskey, useSignInSSO, useUnlinkAccount, useVerifyBackupCode, useVerifyEmail, useVerifyTotp } from "./hooks/auth.mjs";
9
10
  import { useBitbucketAuth, useBitbucketCheckConfig, useBitbucketGetConfigFile, useBitbucketRepos } from "./hooks/bitbucket.mjs";
10
11
  import { useAddDictionary, useDeleteDictionary, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useInfiniteGetDictionaries, usePushDictionaries, useUpdateDictionary } from "./hooks/dictionary.mjs";
11
12
  import { useGetDiscussions, useGetDiscussionsData } from "./hooks/discussions.mjs";
@@ -23,6 +24,5 @@ import { useAcceptAffiliateInvitation, useCancelSubscription, useCreatePortalSes
23
24
  import { useAddTag, useDeleteTag, useGetTags, useUpdateTag } from "./hooks/tag.mjs";
24
25
  import { useFillAllTranslations, usePauseTranslationJob, useResumeTranslationJob, useStopTranslationJob } from "./hooks/translate.mjs";
25
26
  import { useCreateUser, useDeleteUser, useGetUserById, useGetUsers, useUpdateUser, useUploadUserAvatar } from "./hooks/user.mjs";
26
- import { useUser } from "./useUser/index.mjs";
27
27
 
28
28
  export { useAcceptAffiliateInvitation, useAddDictionary, useAddEnvironment, useAddNewAccessKey, useAddOrganization, useAddOrganizationMember, useAddPasskey, useAddProject, useAddTag, useAiAPI, useAskDocQuestion, useAskResetPassword, useAssetAPI, useAuditAPI, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditScan, useAuditTag, useAuth, useAutocomplete, useBitbucketAPI, useBitbucketAuth, useBitbucketCheckConfig, useBitbucketGetConfigFile, useBitbucketRepos, useCancelSubscription, useChangePassword, useChat, useContactReviewer, useCreateMission, useCreatePortalSession, useCreatePromoCode, useCreateUser, useCustomQuery, useDeleteAccessKey, useDeleteAsset, useDeleteDictionary, useDeleteEnvironment, useDeleteOrganization, useDeleteOrganizationById, useDeletePasskey, useDeleteProject, useDeleteProjectById, useDeletePromoCode, useDeleteReviewerProfile, useDeleteSSOProvider, useDeleteShowcaseProject, useDeleteTag, useDeleteUser, useDictionaryAPI, useDisableTwoFactor, useEditorAPI, useEnableTwoFactor, useEnvironmentAPI, useEstimateMission, useFillAllTranslations, useGetAIStats, useGetAdminReviewers, useGetAffiliate, useGetAffiliateAccountSession, useGetAffiliateById, useGetAffiliateInvitation, useGetAffiliateInvitations, useGetAffiliateOnboardingLink, useGetAffiliatePromoCode, useGetAffiliateStats, useGetAffiliates, useGetAssetById, useGetAssets, useGetCIConfig, useGetChatHistory, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useGetDiscussions, useGetDiscussionsData, useGetEditorDictionaries, useGetInvoices, useGetMissionById, useGetMyMissions, useGetMyReviewerProfile, useGetNewsletterStatus, useGetOrganizations, useGetOtherShowcaseProjects, useGetPaymentMethod, useGetPricing, useGetProjectInsights, useGetProjects, useGetPromoCodeById, useGetPromoCodes, useGetRecursiveAuditStatus, useGetReviewerById, useGetReviewerMarketplace, useGetReviewerPriceDistribution, useGetReviewerReviews, useGetShowcaseProjectById, useGetShowcaseProjects, useGetSubscription, useGetTags, useGetUserByAccount, useGetUserById, useGetUsers, useGetVerifyEmailStatus, useGithubAPI, useGithubAuth, useGithubCheckConfig, useGithubGetAuthUrl, useGithubGetConfigFile, useGithubRepos, useGithubToken, useGitlabAPI, useGitlabAuth, useGitlabCheckConfig, useGitlabGetConfigFile, useGitlabProjects, useGrantAffiliateAccess, useInfiniteGetDictionaries, useIntlayerAuth, useIntlayerOAuth, useIntlayerOAuthOptions, useLinkSocial, useListAccounts, useListPasskeys, useListSSOProviders, useLogin, useLogout, useMigrateEnvironment, useNewsletterAPI, useOAuth2, useOAuthAPI, useOrganizationAPI, usePauseTranslationJob, useProjectAPI, usePushCIConfig, usePushDictionaries, usePushProjectConfiguration, useRefreshAccessKey, useRegister, useRegisterAsReviewer, useRegisterSSO, useResetPassword, useResetToProductionEnvironment, useResumeTranslationJob, useReviewerAPI, useSearchAPI, useSearchDoc, useSelectEnvironment, useSelectOrganization, useSelectProject, useSendAffiliateInvitation, useSendReviewerMessage, useSession, useShowcaseProjectAPI, useSignInMagicLink, useSignInPasskey, useSignInSSO, useStartRecursiveAudit, useStopTranslationJob, useStripeAPI, useSubmitReview, useSubmitShowcaseProject, useSubscribeToNewsletter, useTagAPI, useToggleShowcaseDownvote, useToggleShowcaseUpvote, useTranslateAPI, useTranslateJSONDeclaration, useTriggerBuild, useTriggerWebhook, useUnlinkAccount, useUnselectOrganization, useUnselectProject, useUnsubscribeFromNewsletter, useUpdateAffiliateStatus, useUpdateAsset, useUpdateDictionary, useUpdateEnvironment, useUpdateMemberAccess, useUpdateMissionStatus, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateOrganizationMembersById, useUpdateProject, useUpdateProjectMembers, useUpdatePromoCode, useUpdateReviewerProfile, useUpdateShowcaseProject, useUpdateTag, useUpdateUser, useUploadAsset, useUploadReviewerCoverPicture, useUploadReviewerMainPicture, useUploadUserAvatar, useUser, useUserAPI, useValidateReviewerProfile, useVerifyBackupCode, useVerifyEmail, useVerifyTotp, useWriteDictionary };
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import { useUser } from "../../api/useUser/index.mjs";
4
3
  import { Button } from "../Button/Button.mjs";
4
+ import { useUser } from "../../api/useUser/index.mjs";
5
5
  import { AutoCompleteTextarea } from "../TextArea/AutocompleteTextArea.mjs";
6
6
  import { useEffect, useState } from "react";
7
7
  import { Check, X } from "lucide-react";
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
- import { useGetDictionaries } from "../../api/hooks/dictionary.mjs";
4
3
  import { Container } from "../Container/index.mjs";
4
+ import { useGetDictionaries } from "../../api/hooks/dictionary.mjs";
5
5
  import { LocaleSwitcherContent } from "../LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs";
6
6
  import { Pagination } from "../Pagination/Pagination.mjs";
7
7
  import { TextEditorContainer } from "./ContentEditorView/TextEditor.mjs";
@@ -10,13 +10,15 @@ import { KeyPathBreadcrumb } from "./KeyPathBreadcrumb.mjs";
10
10
  import { NavigationViewNode } from "./NavigationView/NavigationViewNode.mjs";
11
11
  import { useCallback, useDeferredValue, useEffect, useMemo, useState, useTransition } from "react";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
13
- import { useEditedContent, useEditorLocale, useFocusUnmergedDictionary } from "@intlayer/editor-react";
14
13
  import { useIntlayer } from "react-intlayer";
14
+ import { useEditedContent, useEditorLocale, useFocusUnmergedDictionary } from "@intlayer/editor-react";
15
15
  import { getContentNodeByKeyPath } from "@intlayer/core/dictionaryManipulator";
16
16
 
17
17
  //#region src/components/DictionaryFieldEditor/ContentEditor.tsx
18
+ /** Render a variant (named string or structured object) for display. */
19
+ const formatVariant = (variant) => variant !== null && typeof variant === "object" ? JSON.stringify(variant) : variant ?? "";
18
20
  const ContentEditor = ({ dictionary, isDarkMode }) => {
19
- const { itemPagination, variantSwitcher, metaSwitcher } = useIntlayer("content-editor");
21
+ const { itemPagination, variantSwitcher } = useIntlayer("content-editor");
20
22
  const { editedContent } = useEditedContent();
21
23
  const { focusedContent, setFocusedContentKeyPath: _setFocusedContentKeyPath } = useFocusUnmergedDictionary();
22
24
  const [, startTransition] = useTransition();
@@ -25,7 +27,7 @@ const ContentEditor = ({ dictionary, isDarkMode }) => {
25
27
  useEffect(() => {
26
28
  setActiveDictionary(dictionary);
27
29
  }, [dictionary.localId]);
28
- const hasQualifier = dictionary.item !== void 0 || dictionary.variant !== void 0 || dictionary.meta !== void 0;
30
+ const hasQualifier = dictionary.item !== void 0 || dictionary.variant !== void 0;
29
31
  const { data: siblingsData } = useGetDictionaries({ keys: [dictionary.key] }, { enabled: hasQualifier && !!dictionary.key });
30
32
  const allSiblings = useMemo(() => siblingsData?.data ?? [], [siblingsData]);
31
33
  const itemDicts = useMemo(() => {
@@ -36,10 +38,6 @@ const ContentEditor = ({ dictionary, isDarkMode }) => {
36
38
  if (dictionary.variant === void 0) return [];
37
39
  return allSiblings.filter((d) => d.variant !== void 0);
38
40
  }, [dictionary, allSiblings]);
39
- const metaDicts = useMemo(() => {
40
- if (dictionary.meta === void 0) return [];
41
- return allSiblings.filter((d) => d.meta !== void 0);
42
- }, [dictionary, allSiblings]);
43
41
  const switchSibling = useCallback((sibling) => {
44
42
  setActiveDictionary(sibling);
45
43
  setFocusedContentKeyPath([]);
@@ -59,71 +57,45 @@ const ContentEditor = ({ dictionary, isDarkMode }) => {
59
57
  }, []);
60
58
  const currentItemIndex = itemDicts.findIndex((dictionary) => dictionary.localId === activeDictionary.localId);
61
59
  const currentVariant = activeDictionary.variant;
62
- const currentMetaId = activeDictionary.meta?.id;
63
60
  return /* @__PURE__ */ jsxs("div", { children: [
64
61
  hasQualifier && /* @__PURE__ */ jsxs("div", {
65
62
  className: "mb-4 flex flex-wrap items-center gap-4",
66
- children: [
67
- itemDicts.length > 0 && /* @__PURE__ */ jsxs("div", {
68
- className: "flex items-center gap-2",
69
- children: [/* @__PURE__ */ jsx("span", {
63
+ children: [itemDicts.length > 0 && /* @__PURE__ */ jsxs("div", {
64
+ className: "flex items-center gap-2",
65
+ children: [/* @__PURE__ */ jsx("span", {
66
+ className: "font-medium text-muted text-xs",
67
+ children: itemPagination.label
68
+ }), /* @__PURE__ */ jsx(Pagination, {
69
+ currentPage: currentItemIndex >= 0 ? currentItemIndex + 1 : 1,
70
+ totalPages: itemDicts.length,
71
+ onPageChange: (page) => {
72
+ const target = itemDicts[page - 1];
73
+ if (target) switchSibling(target);
74
+ },
75
+ size: "sm"
76
+ })]
77
+ }), variantDicts.length > 0 && /* @__PURE__ */ jsxs("div", {
78
+ className: "flex flex-wrap items-center gap-2",
79
+ children: [
80
+ /* @__PURE__ */ jsxs("span", {
70
81
  className: "font-medium text-muted text-xs",
71
- children: itemPagination.label
72
- }), /* @__PURE__ */ jsx(Pagination, {
73
- currentPage: currentItemIndex >= 0 ? currentItemIndex + 1 : 1,
74
- totalPages: itemDicts.length,
75
- onPageChange: (page) => {
76
- const target = itemDicts[page - 1];
77
- if (target) switchSibling(target);
78
- },
79
- size: "sm"
80
- })]
81
- }),
82
- variantDicts.length > 0 && /* @__PURE__ */ jsxs("div", {
83
- className: "flex flex-wrap items-center gap-2",
84
- children: [
85
- /* @__PURE__ */ jsxs("span", {
86
- className: "font-medium text-muted text-xs",
87
- children: [variantSwitcher.label, ":"]
88
- }),
89
- variantDicts.map((sibling) => {
90
- const isActive = sibling.localId === activeDictionary.localId;
91
- return /* @__PURE__ */ jsx("button", {
92
- type: "button",
93
- onClick: () => !isActive && switchSibling(sibling),
94
- className: `rounded-lg px-3 py-1 text-xs transition-colors ${isActive ? "bg-text font-semibold text-text-opposite" : "cursor-pointer border border-border hover:bg-text/10"}`,
95
- children: sibling.variant
96
- }, sibling.localId);
97
- }),
98
- currentVariant !== void 0 && !variantDicts.some((d) => d.localId === dictionary.localId) && /* @__PURE__ */ jsx("span", {
99
- className: "rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs",
100
- children: currentVariant
101
- })
102
- ]
103
- }),
104
- metaDicts.length > 0 && /* @__PURE__ */ jsxs("div", {
105
- className: "flex flex-wrap items-center gap-2",
106
- children: [
107
- /* @__PURE__ */ jsxs("span", {
108
- className: "font-medium text-muted text-xs",
109
- children: [metaSwitcher.label, ":"]
110
- }),
111
- metaDicts.map((sibling) => {
112
- const isActive = sibling.localId === activeDictionary.localId;
113
- return /* @__PURE__ */ jsx("button", {
114
- type: "button",
115
- onClick: () => !isActive && switchSibling(sibling),
116
- className: `rounded-lg px-3 py-1 text-xs transition-colors ${isActive ? "bg-text font-semibold text-text-opposite" : "cursor-pointer border border-border hover:bg-text/10"}`,
117
- children: sibling.meta?.id
118
- }, sibling.localId);
119
- }),
120
- currentMetaId !== void 0 && !metaDicts.some((d) => d.localId === dictionary.localId) && /* @__PURE__ */ jsx("span", {
121
- className: "rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs",
122
- children: currentMetaId
123
- })
124
- ]
125
- })
126
- ]
82
+ children: [variantSwitcher.label, ":"]
83
+ }),
84
+ variantDicts.map((sibling) => {
85
+ const isActive = sibling.localId === activeDictionary.localId;
86
+ return /* @__PURE__ */ jsx("button", {
87
+ type: "button",
88
+ onClick: () => !isActive && switchSibling(sibling),
89
+ className: `rounded-lg px-3 py-1 text-xs transition-colors ${isActive ? "bg-text font-semibold text-text-opposite" : "cursor-pointer border border-border hover:bg-text/10"}`,
90
+ children: formatVariant(sibling.variant)
91
+ }, sibling.localId);
92
+ }),
93
+ currentVariant !== void 0 && !variantDicts.some((d) => d.localId === dictionary.localId) && /* @__PURE__ */ jsx("span", {
94
+ className: "rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs",
95
+ children: formatVariant(currentVariant)
96
+ })
97
+ ]
98
+ })]
127
99
  }),
128
100
  /* @__PURE__ */ jsxs("div", {
129
101
  className: "mb-6 flex items-center justify-between gap-2",
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useGetDictionaries } from '@api/index';\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport {\n useEditedContent,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport {\n type FC,\n useCallback,\n useDeferredValue,\n useEffect,\n useMemo,\n useState,\n useTransition,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContent } from '../LocaleSwitcherContentDropDown';\nimport { Pagination } from '../Pagination';\nimport { TextEditorContainer } from './ContentEditorView/TextEditor';\nimport { getIsEditableSection } from './getIsEditableSection';\nimport { KeyPathBreadcrumb } from './KeyPathBreadcrumb';\nimport { NavigationViewNode } from './NavigationView/NavigationViewNode';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const ContentEditor: FC<NodeEditorProps> = ({\n dictionary,\n isDarkMode,\n}) => {\n const { itemPagination, variantSwitcher, metaSwitcher } =\n useIntlayer('content-editor');\n const { editedContent } = useEditedContent();\n const {\n focusedContent,\n setFocusedContentKeyPath: _setFocusedContentKeyPath,\n } = useFocusUnmergedDictionary();\n const [, startTransition] = useTransition();\n const setFocusedContentKeyPath: typeof _setFocusedContentKeyPath = (\n keyPath\n ) => startTransition(() => _setFocusedContentKeyPath(keyPath));\n\n const [activeDictionary, setActiveDictionary] =\n useState<Dictionary>(dictionary);\n\n useEffect(() => {\n setActiveDictionary(dictionary);\n }, [dictionary.localId]);\n\n const hasQualifier =\n dictionary.item !== undefined ||\n dictionary.variant !== undefined ||\n dictionary.meta !== undefined;\n\n const { data: siblingsData } = useGetDictionaries(\n { keys: [dictionary.key] },\n { enabled: hasQualifier && !!dictionary.key }\n );\n\n const allSiblings = useMemo<Dictionary[]>(\n () => (siblingsData?.data ?? []) as unknown as Dictionary[],\n [siblingsData]\n );\n\n const itemDicts = useMemo<Dictionary[]>(() => {\n if (dictionary.item === undefined) return [];\n return allSiblings\n .filter((d) => d.item !== undefined)\n .sort((a, b) => (a.item ?? 0) - (b.item ?? 0));\n }, [dictionary, allSiblings]);\n\n const variantDicts = useMemo<Dictionary[]>(() => {\n if (dictionary.variant === undefined) return [];\n return allSiblings.filter((d) => d.variant !== undefined);\n }, [dictionary, allSiblings]);\n\n const metaDicts = useMemo<Dictionary[]>(() => {\n if (dictionary.meta === undefined) return [];\n return allSiblings.filter((d) => d.meta !== undefined);\n }, [dictionary, allSiblings]);\n\n const switchSibling = useCallback(\n (sibling: Dictionary) => {\n setActiveDictionary(sibling);\n setFocusedContentKeyPath([]);\n },\n [setFocusedContentKeyPath]\n );\n\n const { content, key, localId } = activeDictionary;\n const focusedKeyPath = focusedContent?.keyPath;\n const section =\n typeof editedContent?.[localId as LocalDictionaryId]?.content ===\n 'undefined'\n ? content\n : editedContent?.[localId as LocalDictionaryId]?.content;\n\n const currentLocale = useEditorLocale();\n const focusedSection = getContentNodeByKeyPath(\n section,\n focusedKeyPath ?? [],\n currentLocale\n );\n\n const deferredKeyPath = useDeferredValue(focusedKeyPath);\n const deferredSection = useDeferredValue(focusedSection);\n const isStale = deferredSection !== focusedSection;\n\n const isEditableBaseSection = getIsEditableSection(section);\n const isEditableFocusedSection = getIsEditableSection(deferredSection);\n\n useEffect(() => {\n if (typeof focusedSection === 'undefined') {\n setFocusedContentKeyPath(focusedContent?.keyPath?.slice(0, -1) ?? []);\n }\n }, []);\n\n const currentItemIndex = itemDicts.findIndex(\n (dictionary) => dictionary.localId === activeDictionary.localId\n );\n const currentVariant = activeDictionary.variant;\n const currentMetaId = activeDictionary.meta?.id;\n\n return (\n <div>\n {/* Qualifier navigation controls */}\n {hasQualifier && (\n <div className=\"mb-4 flex flex-wrap items-center gap-4\">\n {itemDicts.length > 0 && (\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-muted text-xs\">\n {itemPagination.label}\n </span>\n <Pagination\n currentPage={currentItemIndex >= 0 ? currentItemIndex + 1 : 1}\n totalPages={itemDicts.length}\n onPageChange={(page) => {\n const target = itemDicts[page - 1];\n if (target) switchSibling(target);\n }}\n size=\"sm\"\n />\n </div>\n )}\n\n {variantDicts.length > 0 && (\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"font-medium text-muted text-xs\">\n {variantSwitcher.label}:\n </span>\n {variantDicts.map((sibling) => {\n const isActive = sibling.localId === activeDictionary.localId;\n return (\n <button\n key={sibling.localId}\n type=\"button\"\n onClick={() => !isActive && switchSibling(sibling)}\n className={`rounded-lg px-3 py-1 text-xs transition-colors ${\n isActive\n ? 'bg-text font-semibold text-text-opposite'\n : 'cursor-pointer border border-border hover:bg-text/10'\n }`}\n >\n {sibling.variant}\n </button>\n );\n })}\n {currentVariant !== undefined &&\n !variantDicts.some((d) => d.localId === dictionary.localId) && (\n <span className=\"rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs\">\n {currentVariant}\n </span>\n )}\n </div>\n )}\n\n {metaDicts.length > 0 && (\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"font-medium text-muted text-xs\">\n {metaSwitcher.label}:\n </span>\n {metaDicts.map((sibling) => {\n const isActive = sibling.localId === activeDictionary.localId;\n return (\n <button\n key={sibling.localId}\n type=\"button\"\n onClick={() => !isActive && switchSibling(sibling)}\n className={`rounded-lg px-3 py-1 text-xs transition-colors ${\n isActive\n ? 'bg-text font-semibold text-text-opposite'\n : 'cursor-pointer border border-border hover:bg-text/10'\n }`}\n >\n {sibling.meta?.id}\n </button>\n );\n })}\n {currentMetaId !== undefined &&\n !metaDicts.some((d) => d.localId === dictionary.localId) && (\n <span className=\"rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs\">\n {currentMetaId}\n </span>\n )}\n </div>\n )}\n </div>\n )}\n\n <div className=\"mb-6 flex items-center justify-between gap-2\">\n <KeyPathBreadcrumb\n dictionaryKey={key}\n keyPath={focusedKeyPath ?? []}\n onClickKeyPath={setFocusedContentKeyPath}\n />\n <div className=\"flex items-center gap-2\">\n <LocaleSwitcherContent />\n </div>\n </div>\n <div className=\"flex flex-1 gap-2 overflow-visible max-md:flex-col\">\n {typeof section === 'object' &&\n section &&\n !isEditableBaseSection &&\n Object.keys(section).length > 0 && (\n <Container\n border\n background=\"none\"\n className=\"top-10 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]\"\n roundedSize=\"2xl\"\n transparency=\"xs\"\n >\n <NavigationViewNode\n keyPath={[]}\n section={section}\n dictionary={activeDictionary}\n />\n </Container>\n )}\n {(isEditableFocusedSection || (deferredKeyPath ?? []).length > 0) && (\n <div\n className={\n isStale\n ? 'pointer-events-none flex-1 opacity-50 transition-opacity'\n : 'flex-1 transition-opacity'\n }\n >\n <TextEditorContainer\n keyPath={deferredKeyPath ?? []}\n section={deferredSection}\n dictionary={activeDictionary}\n isDarkMode={isDarkMode}\n />\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,MAAa,iBAAsC,EACjD,YACA,iBACI;CACJ,MAAM,EAAE,gBAAgB,iBAAiB,iBACvC,YAAY,iBAAiB;CAC/B,MAAM,EAAE,kBAAkB,kBAAkB;CAC5C,MAAM,EACJ,gBACA,0BAA0B,8BACxB,4BAA4B;CAChC,MAAM,GAAG,mBAAmB,eAAe;CAC3C,MAAM,4BACJ,YACG,sBAAsB,0BAA0B,QAAQ,CAAC;CAE9D,MAAM,CAAC,kBAAkB,uBACvB,SAAqB,WAAW;AAElC,iBAAgB;AACd,sBAAoB,WAAW;IAC9B,CAAC,WAAW,QAAQ,CAAC;CAExB,MAAM,eACJ,WAAW,SAAS,UACpB,WAAW,YAAY,UACvB,WAAW,SAAS;CAEtB,MAAM,EAAE,MAAM,iBAAiB,mBAC7B,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE,EAC1B,EAAE,SAAS,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAC9C;CAED,MAAM,cAAc,cACX,cAAc,QAAQ,EAAE,EAC/B,CAAC,aAAa,CACf;CAED,MAAM,YAAY,cAA4B;AAC5C,MAAI,WAAW,SAAS,OAAW,QAAO,EAAE;AAC5C,SAAO,YACJ,QAAQ,MAAM,EAAE,SAAS,OAAU,CACnC,MAAM,GAAG,OAAO,EAAE,QAAQ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AE;IAC7B,gBAAgB;IAChB,GACF,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,uBAAD,EAAyB;IACrB,EACF;;EACN,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,OAAO,YAAY,YAClB,WACA,CAAC,yBACD,OAAO,KAAK,QAAQ,CAAC,SAAS,KAC5B,oBAAC,WAAD;IACE;IACA,YAAW;IACX,WAAU;IACV,aAAY;IACZ,cAAa;cAEb,oBAAC,oBAAD;KACE,SAAS,EAAE;KACF;KACT,YAAY;KACZ;IACQ,IAEd,6BAA6B,mBAAmB,EAAE,EAAE,SAAS,MAC7D,oBAAC,OAAD;IACE,WACE,UACI,6DACA;cAGN,oBAAC,qBAAD;KACE,SAAS,mBAAmB,EAAE;KAC9B,SAAS;KACT,YAAY;KACA;KACZ;IACE,EAEJ;;EACF"}
1
+ {"version":3,"file":"ContentEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useGetDictionaries } from '@api/index';\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport {\n useEditedContent,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport {\n type FC,\n useCallback,\n useDeferredValue,\n useEffect,\n useMemo,\n useState,\n useTransition,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContent } from '../LocaleSwitcherContentDropDown';\nimport { Pagination } from '../Pagination';\nimport { TextEditorContainer } from './ContentEditorView/TextEditor';\nimport { getIsEditableSection } from './getIsEditableSection';\nimport { KeyPathBreadcrumb } from './KeyPathBreadcrumb';\nimport { NavigationViewNode } from './NavigationView/NavigationViewNode';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\n/** Render a variant (named string or structured object) for display. */\nconst formatVariant = (\n variant: string | Record<string, string | number> | undefined\n): string =>\n variant !== null && typeof variant === 'object'\n ? JSON.stringify(variant)\n : (variant ?? '');\n\nexport const ContentEditor: FC<NodeEditorProps> = ({\n dictionary,\n isDarkMode,\n}) => {\n const { itemPagination, variantSwitcher } = useIntlayer('content-editor');\n const { editedContent } = useEditedContent();\n const {\n focusedContent,\n setFocusedContentKeyPath: _setFocusedContentKeyPath,\n } = useFocusUnmergedDictionary();\n const [, startTransition] = useTransition();\n const setFocusedContentKeyPath: typeof _setFocusedContentKeyPath = (\n keyPath\n ) => startTransition(() => _setFocusedContentKeyPath(keyPath));\n\n const [activeDictionary, setActiveDictionary] =\n useState<Dictionary>(dictionary);\n\n useEffect(() => {\n setActiveDictionary(dictionary);\n }, [dictionary.localId]);\n\n const hasQualifier =\n dictionary.item !== undefined || dictionary.variant !== undefined;\n\n const { data: siblingsData } = useGetDictionaries(\n { keys: [dictionary.key] },\n { enabled: hasQualifier && !!dictionary.key }\n );\n\n const allSiblings = useMemo<Dictionary[]>(\n () => (siblingsData?.data ?? []) as unknown as Dictionary[],\n [siblingsData]\n );\n\n const itemDicts = useMemo<Dictionary[]>(() => {\n if (dictionary.item === undefined) return [];\n return allSiblings\n .filter((d) => d.item !== undefined)\n .sort((a, b) => (a.item ?? 0) - (b.item ?? 0));\n }, [dictionary, allSiblings]);\n\n const variantDicts = useMemo<Dictionary[]>(() => {\n if (dictionary.variant === undefined) return [];\n return allSiblings.filter((d) => d.variant !== undefined);\n }, [dictionary, allSiblings]);\n\n const switchSibling = useCallback(\n (sibling: Dictionary) => {\n setActiveDictionary(sibling);\n setFocusedContentKeyPath([]);\n },\n [setFocusedContentKeyPath]\n );\n\n const { content, key, localId } = activeDictionary;\n const focusedKeyPath = focusedContent?.keyPath;\n const section =\n typeof editedContent?.[localId as LocalDictionaryId]?.content ===\n 'undefined'\n ? content\n : editedContent?.[localId as LocalDictionaryId]?.content;\n\n const currentLocale = useEditorLocale();\n const focusedSection = getContentNodeByKeyPath(\n section,\n focusedKeyPath ?? [],\n currentLocale\n );\n\n const deferredKeyPath = useDeferredValue(focusedKeyPath);\n const deferredSection = useDeferredValue(focusedSection);\n const isStale = deferredSection !== focusedSection;\n\n const isEditableBaseSection = getIsEditableSection(section);\n const isEditableFocusedSection = getIsEditableSection(deferredSection);\n\n useEffect(() => {\n if (typeof focusedSection === 'undefined') {\n setFocusedContentKeyPath(focusedContent?.keyPath?.slice(0, -1) ?? []);\n }\n }, []);\n\n const currentItemIndex = itemDicts.findIndex(\n (dictionary) => dictionary.localId === activeDictionary.localId\n );\n const currentVariant = activeDictionary.variant;\n\n return (\n <div>\n {/* Qualifier navigation controls */}\n {hasQualifier && (\n <div className=\"mb-4 flex flex-wrap items-center gap-4\">\n {itemDicts.length > 0 && (\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-muted text-xs\">\n {itemPagination.label}\n </span>\n <Pagination\n currentPage={currentItemIndex >= 0 ? currentItemIndex + 1 : 1}\n totalPages={itemDicts.length}\n onPageChange={(page) => {\n const target = itemDicts[page - 1];\n if (target) switchSibling(target);\n }}\n size=\"sm\"\n />\n </div>\n )}\n\n {variantDicts.length > 0 && (\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"font-medium text-muted text-xs\">\n {variantSwitcher.label}:\n </span>\n {variantDicts.map((sibling) => {\n const isActive = sibling.localId === activeDictionary.localId;\n return (\n <button\n key={sibling.localId}\n type=\"button\"\n onClick={() => !isActive && switchSibling(sibling)}\n className={`rounded-lg px-3 py-1 text-xs transition-colors ${\n isActive\n ? 'bg-text font-semibold text-text-opposite'\n : 'cursor-pointer border border-border hover:bg-text/10'\n }`}\n >\n {formatVariant(sibling.variant)}\n </button>\n );\n })}\n {currentVariant !== undefined &&\n !variantDicts.some((d) => d.localId === dictionary.localId) && (\n <span className=\"rounded-lg bg-text px-3 py-1 font-semibold text-text-opposite text-xs\">\n {formatVariant(currentVariant)}\n </span>\n )}\n </div>\n )}\n </div>\n )}\n\n <div className=\"mb-6 flex items-center justify-between gap-2\">\n <KeyPathBreadcrumb\n dictionaryKey={key}\n keyPath={focusedKeyPath ?? []}\n onClickKeyPath={setFocusedContentKeyPath}\n />\n <div className=\"flex items-center gap-2\">\n <LocaleSwitcherContent />\n </div>\n </div>\n <div className=\"flex flex-1 gap-2 overflow-visible max-md:flex-col\">\n {typeof section === 'object' &&\n section &&\n !isEditableBaseSection &&\n Object.keys(section).length > 0 && (\n <Container\n border\n background=\"none\"\n className=\"top-10 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]\"\n roundedSize=\"2xl\"\n transparency=\"xs\"\n >\n <NavigationViewNode\n keyPath={[]}\n section={section}\n dictionary={activeDictionary}\n />\n </Container>\n )}\n {(isEditableFocusedSection || (deferredKeyPath ?? []).length > 0) && (\n <div\n className={\n isStale\n ? 'pointer-events-none flex-1 opacity-50 transition-opacity'\n : 'flex-1 transition-opacity'\n }\n >\n <TextEditorContainer\n keyPath={deferredKeyPath ?? []}\n section={deferredSection}\n dictionary={activeDictionary}\n isDarkMode={isDarkMode}\n />\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAM,iBACJ,YAEA,YAAY,QAAQ,OAAO,YAAY,WACnC,KAAK,UAAU,QAAQ,GACtB,WAAW;AAElB,MAAa,iBAAsC,EACjD,YACA,iBACI;CACJ,MAAM,EAAE,gBAAgB,oBAAoB,YAAY,iBAAiB;CACzE,MAAM,EAAE,kBAAkB,kBAAkB;CAC5C,MAAM,EACJ,gBACA,0BAA0B,8BACxB,4BAA4B;CAChC,MAAM,GAAG,mBAAmB,eAAe;CAC3C,MAAM,4BACJ,YACG,sBAAsB,0BAA0B,QAAQ,CAAC;CAE9D,MAAM,CAAC,kBAAkB,uBACvB,SAAqB,WAAW;AAElC,iBAAgB;AACd,sBAAoB,WAAW;IAC9B,CAAC,WAAW,QAAQ,CAAC;CAExB,MAAM,eACJ,WAAW,SAAS,UAAa,WAAW,YAAY;CAE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ACZ,cAAa;cAEb,oBAAC,oBAAD;KACE,SAAS,EAAE;KACF;KACT,YAAY;KACZ;IACQ,IAEd,6BAA6B,mBAAmB,EAAE,EAAE,SAAS,MAC7D,oBAAC,OAAD;IACE,WACE,UACI,6DACA;cAGN,oBAAC,qBAAD;KACE,SAAS,mBAAmB,EAAE;KAC9B,SAAS;KACT,YAAY;KACA;KACZ;IACE,EAEJ;;EACF"}
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { useAuditContentDeclarationField } from "../../../api/hooks/ai.mjs";
4
3
  import { Loader } from "../../Loader/index.mjs";
5
4
  import { Button } from "../../Button/Button.mjs";
6
5
  import { Accordion } from "../../Accordion/Accordion.mjs";
@@ -8,6 +7,7 @@ import { Container } from "../../Container/index.mjs";
8
7
  import { ContentEditorInput as ContentEditorInput$1 } from "../../ContentEditor/ContentEditorInput.mjs";
9
8
  import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
10
9
  import { SwitchSelector } from "../../SwitchSelector/SwitchSelector.mjs";
10
+ import { useAuditContentDeclarationField } from "../../../api/hooks/ai.mjs";
11
11
  import { useLocaleSwitcherContent } from "../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
12
12
  import { renameKey } from "./object.mjs";
13
13
  import { Label } from "../../Label/index.mjs";
@@ -16,9 +16,9 @@ import { SafeHtmlRenderer } from "./SafeHtmlRenderer.mjs";
16
16
  import { Fragment, Suspense, lazy, memo, useState } from "react";
17
17
  import { Plus, Trash, WandSparkles } from "lucide-react";
18
18
  import { jsx, jsxs } from "react/jsx-runtime";
19
- import { useConfiguration, useEditedContent } from "@intlayer/editor-react";
20
19
  import { useIntlayer, useLocale } from "react-intlayer";
21
20
  import { getLocaleName } from "@intlayer/core/localization";
21
+ import { useConfiguration, useEditedContent } from "@intlayer/editor-react";
22
22
  import { getEmptyNode, getNodeType } from "@intlayer/core/dictionaryManipulator";
23
23
  import * as NodeTypes from "@intlayer/types/nodeType";
24
24
  import { camelCaseToSentence } from "@intlayer/config/client";
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
+ import { Button } from "../../Button/Button.mjs";
3
4
  import { useSession } from "../../../api/useAuth/useSession.mjs";
4
5
  import { useAddDictionary } from "../../../api/hooks/dictionary.mjs";
5
6
  import { useGetProjects } from "../../../api/hooks/project.mjs";
6
- import { Button } from "../../Button/Button.mjs";
7
7
  import { MultiSelect } from "../../Select/Multiselect.mjs";
8
8
  import { Select } from "../../Select/Select.mjs";
9
9
  import { InputElement } from "../../Form/elements/InputElement.mjs";
@@ -22,7 +22,7 @@ import { AnimatePresence, motion } from "framer-motion";
22
22
  * Inner component rendered inside Form's FormProvider context so useWatch works.
23
23
  */
24
24
  const DictionaryCreationFormFields = ({ isSubmitting, isPending, projectsData }) => {
25
- const { keyInput, createDictionaryButton, projectInput, qualifierTypeSelect, itemInput, variantInput, metaIdInput } = useIntlayer("dictionary-form");
25
+ const { keyInput, createDictionaryButton, projectInput, qualifierTypeSelect, itemInput, variantInput } = useIntlayer("dictionary-form");
26
26
  const qualifierType = useWatch({ name: "qualifierType" }) ?? "none";
27
27
  return /* @__PURE__ */ jsxs(Fragment, { children: [
28
28
  /* @__PURE__ */ jsx(InputElement, {
@@ -53,76 +53,51 @@ const DictionaryCreationFormFields = ({ isSubmitting, isPending, projectsData })
53
53
  }),
54
54
  /* @__PURE__ */ jsxs(AnimatePresence, {
55
55
  mode: "wait",
56
- children: [
57
- qualifierType === "item" && /* @__PURE__ */ jsx(motion.div, {
58
- initial: {
59
- opacity: 0,
60
- height: 0
61
- },
62
- animate: {
63
- opacity: 1,
64
- height: "auto"
65
- },
66
- exit: {
67
- opacity: 0,
68
- height: 0
69
- },
70
- transition: { duration: .2 },
71
- className: "overflow-hidden",
72
- children: /* @__PURE__ */ jsx(InputElement, {
73
- name: "item",
74
- type: "number",
75
- label: itemInput.label.value,
76
- placeholder: itemInput.placeholder.value,
77
- description: itemInput.description.value,
78
- min: 1
79
- })
80
- }, "item-input"),
81
- qualifierType === "variant" && /* @__PURE__ */ jsx(motion.div, {
82
- initial: {
83
- opacity: 0,
84
- height: 0
85
- },
86
- animate: {
87
- opacity: 1,
88
- height: "auto"
89
- },
90
- exit: {
91
- opacity: 0,
92
- height: 0
93
- },
94
- transition: { duration: .2 },
95
- className: "overflow-hidden",
96
- children: /* @__PURE__ */ jsx(InputElement, {
97
- name: "variant",
98
- label: variantInput.label.value,
99
- placeholder: variantInput.placeholder.value,
100
- description: variantInput.description.value
101
- })
102
- }, "variant-input"),
103
- qualifierType === "meta" && /* @__PURE__ */ jsx(motion.div, {
104
- initial: {
105
- opacity: 0,
106
- height: 0
107
- },
108
- animate: {
109
- opacity: 1,
110
- height: "auto"
111
- },
112
- exit: {
113
- opacity: 0,
114
- height: 0
115
- },
116
- transition: { duration: .2 },
117
- className: "overflow-hidden",
118
- children: /* @__PURE__ */ jsx(InputElement, {
119
- name: "metaId",
120
- label: metaIdInput.label.value,
121
- placeholder: metaIdInput.placeholder.value,
122
- description: metaIdInput.description.value
123
- })
124
- }, "meta-input")
125
- ]
56
+ children: [qualifierType === "item" && /* @__PURE__ */ jsx(motion.div, {
57
+ initial: {
58
+ opacity: 0,
59
+ height: 0
60
+ },
61
+ animate: {
62
+ opacity: 1,
63
+ height: "auto"
64
+ },
65
+ exit: {
66
+ opacity: 0,
67
+ height: 0
68
+ },
69
+ transition: { duration: .2 },
70
+ className: "overflow-hidden",
71
+ children: /* @__PURE__ */ jsx(InputElement, {
72
+ name: "item",
73
+ type: "number",
74
+ label: itemInput.label.value,
75
+ placeholder: itemInput.placeholder.value,
76
+ description: itemInput.description.value,
77
+ min: 1
78
+ })
79
+ }, "item-input"), qualifierType === "variant" && /* @__PURE__ */ jsx(motion.div, {
80
+ initial: {
81
+ opacity: 0,
82
+ height: 0
83
+ },
84
+ animate: {
85
+ opacity: 1,
86
+ height: "auto"
87
+ },
88
+ exit: {
89
+ opacity: 0,
90
+ height: 0
91
+ },
92
+ transition: { duration: .2 },
93
+ className: "overflow-hidden",
94
+ children: /* @__PURE__ */ jsx(InputElement, {
95
+ name: "variant",
96
+ label: variantInput.label.value,
97
+ placeholder: variantInput.placeholder.value,
98
+ description: variantInput.description.value
99
+ })
100
+ }, "variant-input")]
126
101
  }),
127
102
  /* @__PURE__ */ jsx(Button, {
128
103
  className: "mt-12 ml-auto",
@@ -149,7 +124,6 @@ const DictionaryCreationForm = ({ onDictionaryCreated }) => {
149
124
  const qualifiers = {};
150
125
  if (data.qualifierType === "item" && data.item !== void 0) qualifiers.item = data.item;
151
126
  else if (data.qualifierType === "variant" && data.variant) qualifiers.variant = data.variant;
152
- else if (data.qualifierType === "meta" && data.metaId) qualifiers.meta = { id: data.metaId };
153
127
  addDictionary({ dictionary: {
154
128
  key: data.key,
155
129
  projectIds: data.projectIds,
@@ -1 +1 @@
1
- {"version":3,"file":"DictionaryCreationForm.mjs","names":["FormInput","FormMultiSelect","FormSelect","FormButton","useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { useAddDictionary, useGetProjects } from '@api/index';\nimport { useSession } from '@api/useAuth';\nimport {\n Form,\n FormButton,\n FormInput,\n FormMultiSelect,\n FormSelect,\n useForm,\n} from '@components/Form';\nimport { MultiSelect, Select } from '@components/Select';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport type { FC } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport {\n type DictionaryFormData,\n QUALIFIER_TYPES,\n type QualifierType,\n useDictionarySchema,\n} from './useDictionaryFormSchema';\n\ntype DictionaryCreationFormProps = {\n onDictionaryCreated?: () => void;\n};\n\n/**\n * Inner component rendered inside Form's FormProvider context so useWatch works.\n */\nconst DictionaryCreationFormFields: FC<{\n isSubmitting: boolean;\n isPending: boolean;\n projectsData: ReturnType<typeof useGetProjects>['data'];\n}> = ({ isSubmitting, isPending, projectsData }) => {\n const {\n keyInput,\n createDictionaryButton,\n projectInput,\n qualifierTypeSelect,\n itemInput,\n variantInput,\n metaIdInput,\n } = useIntlayer('dictionary-form');\n\n const qualifierType = (useWatch({ name: 'qualifierType' }) ??\n 'none') as QualifierType;\n\n return (\n <>\n <FormInput\n name=\"key\"\n label={keyInput.label.value}\n placeholder={keyInput.placeholder.value}\n isRequired\n />\n\n <FormMultiSelect name=\"projectIds\" label={projectInput.label.value}>\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projectsData?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <MultiSelect.List>\n {projectsData?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </MultiSelect.Content>\n </FormMultiSelect>\n\n <FormSelect\n name=\"qualifierType\"\n label={qualifierTypeSelect.label.value}\n description={qualifierTypeSelect.description.value}\n >\n <Select.Trigger>\n <Select.Value />\n </Select.Trigger>\n <Select.Content>\n {QUALIFIER_TYPES.map((type) => (\n <Select.Item key={type} value={type}>\n {\n (\n qualifierTypeSelect as Record<\n string,\n { value: string } | string\n >\n )[type]\n }\n </Select.Item>\n ))}\n </Select.Content>\n </FormSelect>\n\n <AnimatePresence mode=\"wait\">\n {qualifierType === 'item' && (\n <motion.div\n key=\"item-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"item\"\n type=\"number\"\n label={itemInput.label.value}\n placeholder={itemInput.placeholder.value}\n description={itemInput.description.value}\n min={1}\n />\n </motion.div>\n )}\n\n {qualifierType === 'variant' && (\n <motion.div\n key=\"variant-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"variant\"\n label={variantInput.label.value}\n placeholder={variantInput.placeholder.value}\n description={variantInput.description.value}\n />\n </motion.div>\n )}\n\n {qualifierType === 'meta' && (\n <motion.div\n key=\"meta-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"metaId\"\n label={metaIdInput.label.value}\n placeholder={metaIdInput.placeholder.value}\n description={metaIdInput.description.value}\n />\n </motion.div>\n )}\n </AnimatePresence>\n\n <FormButton\n className=\"mt-12 ml-auto\"\n type=\"submit\"\n color=\"text\"\n isLoading={isSubmitting || isPending}\n label={createDictionaryButton.ariaLabel.value}\n isFullWidth\n >\n {createDictionaryButton.text}\n </FormButton>\n </>\n );\n};\n\nexport const DictionaryCreationForm: FC<DictionaryCreationFormProps> = ({\n onDictionaryCreated,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { mutate: addDictionary, isPending } = useAddDictionary();\n const { data: projectsData } = useGetProjects();\n const DictionarySchema = useDictionarySchema(String(project?.id));\n const { form, isSubmitting } = useForm(DictionarySchema, {\n defaultValues: {\n projectIds: [project?.id],\n qualifierType: 'none',\n },\n });\n\n const onSubmitSuccess = (data: DictionaryFormData) => {\n const qualifiers: Record<string, unknown> = {};\n if (data.qualifierType === 'item' && data.item !== undefined) {\n qualifiers.item = data.item;\n } else if (data.qualifierType === 'variant' && data.variant) {\n qualifiers.variant = data.variant;\n } else if (data.qualifierType === 'meta' && data.metaId) {\n qualifiers.meta = { id: data.metaId };\n }\n\n addDictionary(\n {\n dictionary: {\n key: data.key,\n projectIds: data.projectIds,\n ...qualifiers,\n },\n },\n {\n onSuccess: () => {\n onDictionaryCreated?.();\n },\n }\n );\n };\n\n return (\n <Form\n schema={DictionarySchema}\n onSubmitSuccess={onSubmitSuccess}\n className=\"m-auto w-full max-w-100\"\n {...form}\n >\n <DictionaryCreationFormFields\n isSubmitting={isSubmitting}\n isPending={isPending}\n projectsData={projectsData}\n />\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,gCAIA,EAAE,cAAc,WAAW,mBAAmB;CAClD,MAAM,EACJ,UACA,wBACA,cACA,qBACA,WACA,cACA,gBACE,YAAY,kBAAkB;CAElC,MAAM,gBAAiB,SAAS,EAAE,MAAM,iBAAiB,CAAC,IACxD;AAEF,QACE;EACE,oBAACA,cAAD;GACE,MAAK;GACL,OAAO,SAAS,MAAM;GACtB,aAAa,SAAS,YAAY;GAClC;GACA;EAEF,qBAACC,oBAAD;GAAiB,MAAK;GAAa,OAAO,aAAa,MAAM;aAA7D,CACE,oBAAC,YAAY,SAAb;IACE,gBAAgB,UACd,cAAc,MAAM,MAAM,YAAY,OAAO,QAAQ,GAAG,KAAK,MAAM,EAC/D,QAAQ;cAGd,oBAAC,YAAY,OAAb,EAAmB,aAAa,aAAa,YAAY,OAAS;IAC9C,GACtB,oBAAC,YAAY,SAAb,YACE,oBAAC,YAAY,MAAb,YACG,cAAc,MAAM,KAAK,YACxB,oBAAC,YAAY,MAAb;IAEE,OAAO,OAAO,QAAQ,GAAG;cAExB,QAAQ;IACQ,EAJZ,OAAO,QAAQ,GAAG,CAIN,CACnB,EACe,GACC,EACN;;EAElB,qBAACC,eAAD;GACE,MAAK;GACL,OAAO,oBAAoB,MAAM;GACjC,aAAa,oBAAoB,YAAY;aAH/C,CAKE,oBAAC,OAAO,SAAR,YACE,oBAAC,OAAO,OAAR,EAAgB,GACD,GACjB,oBAAC,OAAO,SAAR,YACG,gBAAgB,KAAK,SACpB,oBAAC,OAAO,MAAR;IAAwB,OAAO;cAGzB,oBAIA;IAEQ,EATI,KASJ,CACd,EACa,EACN;;EAEb,qBAAC,iBAAD;GAAiB,MAAK;aAAtB;I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Y,YAAY;CAChC,MAAM,EAAE,YAAY,WAAW,EAAE;CACjC,MAAM,EAAE,QAAQ,eAAe,cAAc,kBAAkB;CAC/D,MAAM,EAAE,MAAM,iBAAiB,gBAAgB;CAC/C,MAAM,mBAAmB,oBAAoB,OAAO,SAAS,GAAG,CAAC;CACjE,MAAM,EAAE,MAAM,iBAAiBC,UAAQ,kBAAkB,EACvD,eAAe;EACb,YAAY,CAAC,SAAS,GAAG;EACzB,eAAe;EAChB,EACF,CAAC;CAEF,MAAM,mBAAmB,SAA6B;EACpD,MAAM,aAAsC,EAAE;AAC9C,MAAI,KAAK,kBAAkB,UAAU,KAAK,SAAS,OACjD,YAAW,OAAO,KAAK;WACd,KAAK,kBAAkB,aAAa,KAAK,QAClD,YAAW,UAAU,KAAK;WACjB,KAAK,kBAAkB,UAAU,KAAK,OAC/C,YAAW,OAAO,EAAE,IAAI,KAAK,QAAQ;AAGvC,gBACE,EACE,YAAY;GACV,KAAK,KAAK;GACV,YAAY,KAAK;GACjB,GAAG;GACJ,EACF,EACD,EACE,iBAAiB;AACf,0BAAuB;KAE1B,CACF;;AAGH,QACE,oBAAC,MAAD;EACE,QAAQ;EACS;EACjB,WAAU;EACV,GAAI;YAEJ,oBAAC,8BAAD;GACgB;GACH;GACG;GACd;EACG"}
1
+ {"version":3,"file":"DictionaryCreationForm.mjs","names":["FormInput","FormMultiSelect","FormSelect","FormButton","useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { useAddDictionary, useGetProjects } from '@api/index';\nimport { useSession } from '@api/useAuth';\nimport {\n Form,\n FormButton,\n FormInput,\n FormMultiSelect,\n FormSelect,\n useForm,\n} from '@components/Form';\nimport { MultiSelect, Select } from '@components/Select';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport type { FC } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport {\n type DictionaryFormData,\n QUALIFIER_TYPES,\n type QualifierType,\n useDictionarySchema,\n} from './useDictionaryFormSchema';\n\ntype DictionaryCreationFormProps = {\n onDictionaryCreated?: () => void;\n};\n\n/**\n * Inner component rendered inside Form's FormProvider context so useWatch works.\n */\nconst DictionaryCreationFormFields: FC<{\n isSubmitting: boolean;\n isPending: boolean;\n projectsData: ReturnType<typeof useGetProjects>['data'];\n}> = ({ isSubmitting, isPending, projectsData }) => {\n const {\n keyInput,\n createDictionaryButton,\n projectInput,\n qualifierTypeSelect,\n itemInput,\n variantInput,\n } = useIntlayer('dictionary-form');\n\n const qualifierType = (useWatch({ name: 'qualifierType' }) ??\n 'none') as QualifierType;\n\n return (\n <>\n <FormInput\n name=\"key\"\n label={keyInput.label.value}\n placeholder={keyInput.placeholder.value}\n isRequired\n />\n\n <FormMultiSelect name=\"projectIds\" label={projectInput.label.value}>\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projectsData?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <MultiSelect.List>\n {projectsData?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </MultiSelect.Content>\n </FormMultiSelect>\n\n <FormSelect\n name=\"qualifierType\"\n label={qualifierTypeSelect.label.value}\n description={qualifierTypeSelect.description.value}\n >\n <Select.Trigger>\n <Select.Value />\n </Select.Trigger>\n <Select.Content>\n {QUALIFIER_TYPES.map((type) => (\n <Select.Item key={type} value={type}>\n {\n (\n qualifierTypeSelect as Record<\n string,\n { value: string } | string\n >\n )[type]\n }\n </Select.Item>\n ))}\n </Select.Content>\n </FormSelect>\n\n <AnimatePresence mode=\"wait\">\n {qualifierType === 'item' && (\n <motion.div\n key=\"item-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"item\"\n type=\"number\"\n label={itemInput.label.value}\n placeholder={itemInput.placeholder.value}\n description={itemInput.description.value}\n min={1}\n />\n </motion.div>\n )}\n\n {qualifierType === 'variant' && (\n <motion.div\n key=\"variant-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"variant\"\n label={variantInput.label.value}\n placeholder={variantInput.placeholder.value}\n description={variantInput.description.value}\n />\n </motion.div>\n )}\n </AnimatePresence>\n\n <FormButton\n className=\"mt-12 ml-auto\"\n type=\"submit\"\n color=\"text\"\n isLoading={isSubmitting || isPending}\n label={createDictionaryButton.ariaLabel.value}\n isFullWidth\n >\n {createDictionaryButton.text}\n </FormButton>\n </>\n );\n};\n\nexport const DictionaryCreationForm: FC<DictionaryCreationFormProps> = ({\n onDictionaryCreated,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { mutate: addDictionary, isPending } = useAddDictionary();\n const { data: projectsData } = useGetProjects();\n const DictionarySchema = useDictionarySchema(String(project?.id));\n const { form, isSubmitting } = useForm(DictionarySchema, {\n defaultValues: {\n projectIds: [project?.id],\n qualifierType: 'none',\n },\n });\n\n const onSubmitSuccess = (data: DictionaryFormData) => {\n const qualifiers: Record<string, unknown> = {};\n if (data.qualifierType === 'item' && data.item !== undefined) {\n qualifiers.item = data.item;\n } else if (data.qualifierType === 'variant' && data.variant) {\n qualifiers.variant = data.variant;\n }\n\n addDictionary(\n {\n dictionary: {\n key: data.key,\n projectIds: data.projectIds,\n ...qualifiers,\n },\n },\n {\n onSuccess: () => {\n onDictionaryCreated?.();\n },\n }\n );\n };\n\n return (\n <Form\n schema={DictionarySchema}\n onSubmitSuccess={onSubmitSuccess}\n className=\"m-auto w-full max-w-100\"\n {...form}\n >\n <DictionaryCreationFormFields\n isSubmitting={isSubmitting}\n isPending={isPending}\n projectsData={projectsData}\n />\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,gCAIA,EAAE,cAAc,WAAW,mBAAmB;CAClD,MAAM,EACJ,UACA,wBACA,cACA,qBACA,WACA,iBACE,YAAY,kBAAkB;CAElC,MAAM,gBAAiB,SAAS,EAAE,MAAM,iBAAiB,CAAC,IACxD;AAEF,QACE;EACE,oBAACA,cAAD;GACE,MAAK;GACL,OAAO,SAAS,MAAM;GACtB,aAAa,SAAS,YAAY;GAClC;GACA;EAEF,qBAACC,oBAAD;GAAiB,MAAK;GAAa,OAAO,aAAa,MAAM;aAA7D,CACE,oBAAC,YAAY,SAAb;IACE,gBAAgB,UACd,cAAc,MAAM,MAAM,YAAY,OAAO,QAAQ,GAAG,KAAK,MAAM,EAC/D,QAAQ;cAGd,oBAAC,YAAY,OAAb,EAAmB,aAAa,aAAa,YAAY,OAAS;IAC9C,GACtB,oBAAC,YAAY,SAAb,YACE,oBAAC,YAAY,MAAb,YACG,cAAc,MAAM,KAAK,YACxB,oBAAC,YAAY,MAAb;IAEE,OAAO,OAAO,QAAQ,GAAG;cAExB,QAAQ;IACQ,EAJZ,OAAO,QAAQ,GAAG,CAIN,CACnB,EACe,GACC,EACN;;EAElB,qBAACC,eAAD;GACE,MAAK;GACL,OAAO,oBAAoB,MAAM;GACjC,aAAa,oBAAoB,YAAY;aAH/C,CAKE,oBAAC,OAAO,SAAR,YACE,oBAAC,OAAO,OAAR,EAAgB,GACD,GACjB,oBAAC,OAAO,SAAR,YACG,gBAAgB,KAAK,SACpB,oBAAC,OAAO,MAAR;IAAwB,OAAO;cAGzB,oBAIA;IAEQ,EATI,KASJ,CACd,EACa,EACN;;EAEb,qBAAC,iBAAD;GAAiB,MAAK;aAAtB,CACG,kBAAkB,UACjB,oBAAC,OAAO,KAAR;IAEE,SAAS;KAAE,SAAS;KAAG,QAAQ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AAW,OAAO,KAAK;WACd,KAAK,kBAAkB,aAAa,KAAK,QAClD,YAAW,UAAU,KAAK;AAG5B,gBACE,EACE,YAAY;GACV,KAAK,KAAK;GACV,YAAY,KAAK;GACjB,GAAG;GACJ,EACF,EACD,EACE,iBAAiB;AACf,0BAAuB;KAE1B,CACF;;AAGH,QACE,oBAAC,MAAD;EACE,QAAQ;EACS;EACjB,WAAU;EACV,GAAI;YAEJ,oBAAC,8BAAD;GACgB;GACH;GACG;GACd;EACG"}
@@ -334,68 +334,6 @@ const dictionaryFormContent = {
334
334
  uk: "Іменована альтернативна форма вмісту для A/B-тестування, сезонних банерів або прапорів функцій."
335
335
  })
336
336
  },
337
- metaIdInput: {
338
- label: t({
339
- en: "Meta ID",
340
- "en-GB": "Meta ID",
341
- fr: "ID méta",
342
- es: "ID meta",
343
- de: "Meta-ID",
344
- ja: "メタID",
345
- ko: "메타 ID",
346
- zh: "元ID",
347
- it: "ID meta",
348
- pt: "ID meta",
349
- hi: "मेटा ID",
350
- ar: "معرّف البيانات الوصفية",
351
- ru: "Мета-ID",
352
- tr: "Meta kimliği",
353
- pl: "ID meta",
354
- id: "ID meta",
355
- vi: "ID meta",
356
- uk: "Мета-ID"
357
- }),
358
- placeholder: t({
359
- en: "e.g. prod_abc",
360
- "en-GB": "e.g. prod_abc",
361
- fr: "par ex. prod_abc",
362
- es: "por ej. prod_abc",
363
- de: "z. B. prod_abc",
364
- ja: "例: prod_abc",
365
- ko: "예: prod_abc",
366
- zh: "例如: prod_abc",
367
- it: "es. prod_abc",
368
- pt: "ex. prod_abc",
369
- hi: "उदा. prod_abc",
370
- ar: "مثال: prod_abc",
371
- ru: "напр. prod_abc",
372
- tr: "ör. prod_abc",
373
- pl: "np. prod_abc",
374
- id: "mis. prod_abc",
375
- vi: "ví dụ: prod_abc",
376
- uk: "напр. prod_abc"
377
- }),
378
- description: t({
379
- en: "The discriminator ID used to resolve this record at runtime.",
380
- "en-GB": "The discriminator ID used to resolve this record at runtime.",
381
- fr: "L'ID discriminant utilisé pour résoudre cet enregistrement au moment de l'exécution.",
382
- es: "El ID discriminador utilizado para resolver este registro en tiempo de ejecución.",
383
- de: "Die Diskriminator-ID, die verwendet wird, um diesen Datensatz zur Laufzeit aufzulösen.",
384
- ja: "実行時にこのレコードを解決するために使用される識別子ID。",
385
- ko: "런타임에 이 레코드를 해결하는 데 사용되는 식별자 ID.",
386
- zh: "在运行时用于解析此记录的鉴别符ID。",
387
- it: "L'ID discriminante utilizzato per risolvere questo record in fase di esecuzione.",
388
- pt: "O ID discriminador usado para resolver este registro em tempo de execução.",
389
- hi: "रनटाइम पर इस रिकॉर्ड को हल करने के लिए उपयोग किया जाने वाला विवेचक ID।",
390
- ar: "معرف المميز المستخدم لحل هذا السجل في وقت التشغيل.",
391
- ru: "Идентификатор-дискриминатор, используемый для разрешения этой записи во время выполнения.",
392
- tr: "Bu kaydı çalışma zamanında çözümlemek için kullanılan ayırt edici kimlik.",
393
- pl: "Identyfikator dyskryminatora używany do rozwiązania tego rekordu w czasie wykonywania.",
394
- id: "ID pembeda yang digunakan untuk menyelesaikan rekaman ini saat runtime.",
395
- vi: "ID phân biệt được sử dụng để giải quyết bản ghi này lúc chạy.",
396
- uk: "Ідентифікатор-дискримінатор, що використовується для розв'язання цього запису під час виконання."
397
- })
398
- },
399
337
  createDictionaryButton: {
400
338
  text: t({
401
339
  en: "Create dictionary",