@intlayer/design-system 4.1.11 → 4.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +8 -8
- package/dist/components/Auth/ChangePasswordForm/changePasswordForm.content.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/changePasswordForm.content.d.ts.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/changePasswordForm.content.mjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/useChangePasswordSchema.content.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/useChangePasswordSchema.content.d.ts.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/useChangePasswordSchema.content.mjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.d.ts.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/resetPasswordContent.content.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/resetPasswordContent.content.d.ts.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/resetPasswordContent.content.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/useResetPasswordSchema.content.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/useResetPasswordSchema.content.d.ts.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/useResetPasswordSchema.content.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/signIn.content.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/signIn.content.d.ts.map +1 -1
- package/dist/components/Auth/SignInForm/signIn.content.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/useSignInSchema.content.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/useSignInSchema.content.d.ts.map +1 -1
- package/dist/components/Auth/SignInForm/useSignInSchema.content.mjs.map +1 -1
- package/dist/components/Auth/SignUpForm/useSignUpSchema.content.cjs.map +1 -1
- package/dist/components/Auth/SignUpForm/useSignUpSchema.content.d.ts.map +1 -1
- package/dist/components/Auth/SignUpForm/useSignUpSchema.content.mjs.map +1 -1
- package/dist/components/Auth/VerifyEmailForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/VerifyEmailForm/index.content.d.ts.map +1 -1
- package/dist/components/Auth/VerifyEmailForm/index.content.mjs.map +1 -1
- package/dist/components/Breadcrumb/breadcrumb.content.cjs.map +1 -1
- package/dist/components/Breadcrumb/breadcrumb.content.d.ts.map +1 -1
- package/dist/components/Breadcrumb/breadcrumb.content.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +2 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +2 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +3 -3
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/dictionariesSelector.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/dictionariesSelector.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/dictionariesSelector.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +3 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +3 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +1 -2
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts +2 -2
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +1 -2
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +5 -9
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts +2 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +5 -9
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +1 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts +2 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +1 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/dictionaryFieldEditor.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/dictionaryFieldEditor.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/dictionaryFieldEditor.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/editorView.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/editorView.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/editorView.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +14 -3
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts +2 -2
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +14 -3
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs.map +1 -1
- package/dist/components/IDE/ContentDeclarationFormatSelector.cjs +1 -1
- package/dist/components/IDE/ContentDeclarationFormatSelector.cjs.map +1 -1
- package/dist/components/IDE/ContentDeclarationFormatSelector.mjs +1 -1
- package/dist/components/IDE/ContentDeclarationFormatSelector.mjs.map +1 -1
- package/dist/components/IDE/CopyButton.content.cjs.map +1 -1
- package/dist/components/IDE/CopyButton.content.d.ts.map +1 -1
- package/dist/components/IDE/CopyButton.content.mjs.map +1 -1
- package/dist/components/Loader/index.content.cjs.map +1 -1
- package/dist/components/Loader/index.content.d.ts.map +1 -1
- package/dist/components/Loader/index.content.mjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.mjs.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.cjs.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.mjs.map +1 -1
- package/dist/index-B-adg6xa.js.map +1 -1
- package/dist/index-DAsui9u9.cjs.map +1 -1
- package/dist/{index-ikcnTPvJ.js → index-Di_3dNqI.js} +4 -4
- package/dist/index-Di_3dNqI.js.map +1 -0
- package/dist/{index-NyRxk54x.cjs → index-ZARcTrR0.cjs} +4 -4
- package/dist/index-ZARcTrR0.cjs.map +1 -0
- package/package.json +17 -17
- package/dist/index-NyRxk54x.cjs.map +0 -1
- package/dist/index-ikcnTPvJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { getSectionType } from '@intlayer/editor';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionary.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["useEditedContent","useAuditContentDeclarationField","jsx","ContentEditorTextAreaBase","Button","WandSparkles","element","createElement","useLocale","useLocaleSwitcherContent","NodeType","jsxs","getLocaleName","useDictionary","navigationViewContent","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAw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;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAGE,MAAA,aAAaQ,cAAS,MAAM;AAE5B,WAAAR,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,2BAAA,kBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,mGAAS,UAAqB,wBAAA,CAAA;AAChC;;;"}
|
|
1
|
+
{"version":3,"file":"TextEditor.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n getLocaleName,\n Dictionary,\n getSectionType,\n} from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionary.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as ContentNode[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as ContentNode[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["useEditedContent","useAuditContentDeclarationField","jsx","ContentEditorTextAreaBase","Button","WandSparkles","element","createElement","useLocale","useLocaleSwitcherContent","NodeType","jsxs","getLocaleName","useDictionary","navigationViewContent","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,iBAAiB,IAAIA,6BAAiB;AAC9C,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/CC,uBAAAA,gCAAgC;AAGhC,SAAAC,2BAAA,kBAAA;AAAA,IAACC,+CAAA;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,2BAAA,kBAAA;AAAA,QAACE,yBAAA;AAAA,QAAA;AAAA,UACC,MAAMC,YAAA;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B,aAAa,KAAK,UAAU,UAAU;AAAA,cACtC;AAAA,cACA;AAAA,YAAA,CACD,EAAE,KAAK,CAAC,aAAa;AAChB,kBAAA,CAAC,SAAS,KAAM;AAEhB,kBAAA;AACI,sBAAA,gBAAgB,SAAS,KAAK;AAEnB,iCAAA,WAAW,KAAK,eAAe,OAAO;AAAA,uBAChD,OAAO;AACd,wBAAQ,MAAM,KAAK;AAAA,cAAA;AAAA,YACrB,CACD;AAAA,UAAA;AAAA,QACH;AAAA,MACF;AAAA,MAED,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;AAEA,MAAM,qBAAqB,CAAC,YAA0B;AAChD,MAAA,OAAO,YAAY,UAAU;AA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;AAEnC,aAAAR,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaQ,cAAS,OAAO;AAE7B,aAAAR,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAGE,MAAA,aAAaQ,cAAS,MAAM;AAE5B,WAAAR,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,2BAAA,kBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,mGAAS,UAAqB,wBAAA,CAAA;AAChC;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config';
|
|
2
|
-
import { KeyPath,
|
|
2
|
+
import { KeyPath, ContentNode, Dictionary } from '@intlayer/core';
|
|
3
3
|
import { FC } from 'react';
|
|
4
4
|
export declare const traceKeys: string[];
|
|
5
5
|
export type TextEditorProps = {
|
|
6
6
|
dictionary: Dictionary;
|
|
7
7
|
keyPath: KeyPath[];
|
|
8
|
-
section:
|
|
8
|
+
section: ContentNode;
|
|
9
9
|
locales: Locales[];
|
|
10
10
|
};
|
|
11
11
|
export declare const TextEditor: FC<TextEditorProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,UAAU,EAEX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAIL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAef,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAgGlE,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAuOF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2E1C,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
|
|
3
|
-
import { NodeType, getLocaleName } from "@intlayer/core";
|
|
4
|
-
import { getSectionType } from "@intlayer/editor";
|
|
3
|
+
import { getSectionType, NodeType, getLocaleName } from "@intlayer/core";
|
|
5
4
|
import { useEditedContent } from "@intlayer/editor-react";
|
|
6
5
|
import { WandSparkles, X, Plus } from "lucide-react";
|
|
7
6
|
import { createElement } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { getSectionType } from '@intlayer/editor';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionary.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["jsx","ContentEditorTextAreaBase","element","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,iBAAiB,IAAI,iBAAiB;AAC9C,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/C,gCAAgC;AAGhC,SAAAA,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAM;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B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,IAAA;AAIA,QAAA,aAAa,SAAS,aAAa;AAEnC,aAAAA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,OAAO;AAE7B,aAAAA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAGE,MAAA,aAAa,SAAS,MAAM;AAE5B,WAAAA,kCAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
|
|
1
|
+
{"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n getLocaleName,\n Dictionary,\n getSectionType,\n} from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionary.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as ContentNode[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as ContentNode[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["jsx","ContentEditorTextAreaBase","element","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,iBAAiB,IAAI,iBAAiB;AAC9C,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/C,gCAAgC;AAGhC,SAAAA,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAM;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B,aAAa,KAAK,UAAU,UAAU;AAAA,cACtC;AAAA,cACA;AAAA,YAAA,CACD,EAAE,KAAK,CAAC,aAAa;AAChB,kBAAA,CAAC,SAAS,KAAM;AAEhB,kBAAA;AACI,sBAAA,gBAAgB,SAAS,KAAK;AAEnB,iCAAA,WAAW,KAAK,eAAe,OAAO;AAAA,uBAChD,OAAO;AACd,wBAAQ,MAAM,KAAK;AAAA,cAAA;AAAA,YACrB,CACD;AAAA,UAAA;AAAA,QACH;AAAA,MACF;AAAA,MAED,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;AA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E5B,WAAAA,kCAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("../../../jsx-runtime-CgFM7lM3.cjs");
|
|
4
4
|
const client = require("@intlayer/config/client");
|
|
5
5
|
const core = require("@intlayer/core");
|
|
6
|
-
const editor = require("@intlayer/editor");
|
|
7
6
|
const editorReact = require("@intlayer/editor-react");
|
|
8
7
|
const lucideReact = require("lucide-react");
|
|
9
8
|
const require$$0 = require("react");
|
|
@@ -20,7 +19,7 @@ const NavigationViewNode = ({
|
|
|
20
19
|
dictionaryKey
|
|
21
20
|
}) => {
|
|
22
21
|
const { locales } = client.getConfiguration().internationalization;
|
|
23
|
-
const section =
|
|
22
|
+
const section = core.getContentNodeByKeyPath(sectionProp, keyPath);
|
|
24
23
|
const { addEditedContent } = editorReact.useEditedContentActions();
|
|
25
24
|
const { setFocusedContentKeyPath, focusedContent } = editorReact.useFocusDictionary();
|
|
26
25
|
const {
|
|
@@ -31,7 +30,7 @@ const NavigationViewNode = ({
|
|
|
31
30
|
goToEnumeration,
|
|
32
31
|
goToTranslation
|
|
33
32
|
} = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
|
|
34
|
-
const nodeType =
|
|
33
|
+
const nodeType = core.getSectionType(section);
|
|
35
34
|
const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
|
|
36
35
|
const getIsSelected = require$$0.useCallback(
|
|
37
36
|
(keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && core.isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []),
|
|
@@ -49,7 +48,7 @@ const NavigationViewNode = ({
|
|
|
49
48
|
...keyPath,
|
|
50
49
|
{ type: core.NodeType.Translation, key: translationKey }
|
|
51
50
|
];
|
|
52
|
-
const subSection =
|
|
51
|
+
const subSection = core.getContentNodeByKeyPath(
|
|
53
52
|
sectionProp,
|
|
54
53
|
childKeyPath
|
|
55
54
|
);
|
|
@@ -98,7 +97,7 @@ const NavigationViewNode = ({
|
|
|
98
97
|
...keyPath,
|
|
99
98
|
{ type: core.NodeType.Enumeration, key }
|
|
100
99
|
];
|
|
101
|
-
const subSection =
|
|
100
|
+
const subSection = core.getContentNodeByKeyPath(
|
|
102
101
|
sectionProp,
|
|
103
102
|
childKeyPath
|
|
104
103
|
);
|
|
@@ -213,10 +212,7 @@ const NavigationViewNode = ({
|
|
|
213
212
|
...keyPath,
|
|
214
213
|
{ type: core.NodeType.Object, key }
|
|
215
214
|
];
|
|
216
|
-
const subSection =
|
|
217
|
-
sectionProp,
|
|
218
|
-
childKeyPath
|
|
219
|
-
);
|
|
215
|
+
const subSection = core.getContentNodeByKeyPath(sectionProp, childKeyPath);
|
|
220
216
|
const isEditableSubSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(subSection);
|
|
221
217
|
if (isEditableSubSection) {
|
|
222
218
|
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { getDictionaryValueByKeyPath, getSectionType } from '@intlayer/editor';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getDictionaryValueByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;;AAuBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,OAAAA,4BAA4B,aAAa,OAAO;AAC1D,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAIC,+BAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA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,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getSectionType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as ContentNode[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","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AAAA,MAEDA,2BAAA,kBAAA;AAAA,QAACG,yBAAA;AAAA,QAAA;AAAA,UACC,OAAO,YAAY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAMD,KAAAA,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAMK,YAAA;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACID,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { KeyPath,
|
|
1
|
+
import { KeyPath, ContentNode } from '@intlayer/core';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
export declare const traceKeys: string[];
|
|
4
4
|
export type NodeWrapperProps = {
|
|
5
5
|
dictionaryKey: string;
|
|
6
6
|
keyPath: KeyPath[];
|
|
7
|
-
section:
|
|
7
|
+
section: ContentNode;
|
|
8
8
|
};
|
|
9
9
|
export declare const NavigationViewNode: FC<NodeWrapperProps>;
|
|
10
10
|
//# sourceMappingURL=NavigationViewNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,WAAW,EAIjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAe,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAS7C,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CA4SnD,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config/client";
|
|
3
|
-
import { isSameKeyPath, NodeType } from "@intlayer/core";
|
|
4
|
-
import { getDictionaryValueByKeyPath, getSectionType } from "@intlayer/editor";
|
|
3
|
+
import { getContentNodeByKeyPath, getSectionType, isSameKeyPath, NodeType } from "@intlayer/core";
|
|
5
4
|
import { useEditedContentActions, useFocusDictionary } from "@intlayer/editor-react";
|
|
6
5
|
import { ChevronRight, Plus } from "lucide-react";
|
|
7
6
|
import { useCallback } from "react";
|
|
@@ -18,7 +17,7 @@ const NavigationViewNode = ({
|
|
|
18
17
|
dictionaryKey
|
|
19
18
|
}) => {
|
|
20
19
|
const { locales } = getConfiguration().internationalization;
|
|
21
|
-
const section =
|
|
20
|
+
const section = getContentNodeByKeyPath(sectionProp, keyPath);
|
|
22
21
|
const { addEditedContent } = useEditedContentActions();
|
|
23
22
|
const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();
|
|
24
23
|
const {
|
|
@@ -47,7 +46,7 @@ const NavigationViewNode = ({
|
|
|
47
46
|
...keyPath,
|
|
48
47
|
{ type: NodeType.Translation, key: translationKey }
|
|
49
48
|
];
|
|
50
|
-
const subSection =
|
|
49
|
+
const subSection = getContentNodeByKeyPath(
|
|
51
50
|
sectionProp,
|
|
52
51
|
childKeyPath
|
|
53
52
|
);
|
|
@@ -96,7 +95,7 @@ const NavigationViewNode = ({
|
|
|
96
95
|
...keyPath,
|
|
97
96
|
{ type: NodeType.Enumeration, key }
|
|
98
97
|
];
|
|
99
|
-
const subSection =
|
|
98
|
+
const subSection = getContentNodeByKeyPath(
|
|
100
99
|
sectionProp,
|
|
101
100
|
childKeyPath
|
|
102
101
|
);
|
|
@@ -211,10 +210,7 @@ const NavigationViewNode = ({
|
|
|
211
210
|
...keyPath,
|
|
212
211
|
{ type: NodeType.Object, key }
|
|
213
212
|
];
|
|
214
|
-
const subSection =
|
|
215
|
-
sectionProp,
|
|
216
|
-
childKeyPath
|
|
217
|
-
);
|
|
213
|
+
const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);
|
|
218
214
|
const isEditableSubSection = getIsEditableSection(subSection);
|
|
219
215
|
if (isEditableSubSection) {
|
|
220
216
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { getDictionaryValueByKeyPath, getSectionType } from '@intlayer/editor';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;AAuBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,4BAA4B,aAAa,OAAO;AAC1D,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,eAAe,OAAO;AACjC,QAAA,oBAAoB,qBAAqB,OAAO;AACtD,QAAM,gBAAgB;AAAA,IACpB,CAACA,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEI,MAAA,kBAA0B,QAAAC,kCAAA,IAAAC,k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,EACF,CAAA;AAAA,UAAA;AAAA,UAdK;AAAA,QAeP;AAAA,MAAA,CAEH;AAAA,MAEDA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO,YAAY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getSectionType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as ContentNode[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,eAAe,OAAO;AACjC,QAAA,oBAAoB,qBAAqB,OAAO;AACtD,QAAM,gBAAgB;AAAA,IACpB,CAACA,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEI,MAAA,kBAA0B,QAAAC,kCAAA,IAAAC,kBAAA,UAAA,EAAE,UAAC,KAAA;AAEjC,MAAI,CAAC,QAAgB,QAAAD,kCAAA,IAAAC,kBAAA,UAAA,EAAE,UAAC,KAAA;AAEpB,MAAA,OAA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AY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationViewNode.content.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.ts"],"sourcesContent":["import { t, type
|
|
1
|
+
{"version":3,"file":"navigationViewNode.content.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.ts"],"sourcesContent":["import { t, type Dictionary } from 'intlayer';\n\nexport const navigationViewContent = {\n key: 'navigation-view',\n content: {\n tsxNotEditable: t({\n en: 'React node not editable',\n 'en-GB': 'React node not editable',\n fr: 'Node React non éditable',\n es: 'Nodo React no editable',\n de: 'React-Knoten nicht bearbeitbar',\n ja: '編集できないReactノード',\n ko: '편집할 수 없는 React 노드',\n zh: '不可编辑的 React 节点',\n it: 'Node React non modificabile',\n pt: 'Nó React não editável',\n hi: 'सम्पादित न करने योग्य React नोड',\n ar: 'عقدة React غير قابلة للتحرير',\n ru: 'React-узел не редактируемый',\n }),\n goToField: {\n label: t({\n en: 'Go to field',\n 'en-GB': 'Go to field',\n fr: 'Aller au champ',\n es: 'Ir al campo',\n de: 'Zum Feld gehen',\n ja: 'フィールドに移動',\n ko: '필드로 이동',\n zh: '转到字段',\n it: 'Vai al campo',\n pt: 'Ir para o campo',\n hi: 'फ़ील्ड पर जाएं',\n ar: 'اذهب إلى الحقل',\n ru: 'Перейти к полю',\n }),\n },\n addNewField: {\n label: t({\n en: 'Click to add field',\n 'en-GB': 'Click to add field',\n fr: 'Cliquez pour ajouter un champ',\n es: 'Haga clic para agregar un campo',\n de: 'Klicken Sie, um ein Feld hinzuzufügen',\n ja: 'フィールドを追加するにはクリック',\n ko: '필드를 추가하려면 클릭하세요',\n zh: '点击添加字段',\n it: 'Clicca per aggiungere un campo',\n pt: 'Clique para adicionar um campo',\n hi: 'फ़ील्ड जोड़ने के लिए क्लिक करें',\n ar: 'انقر لإضافة حقل',\n ru: 'Нажмите, чтобы добавить поле',\n }),\n text: t({\n en: 'Add new field',\n 'en-GB': 'Add new field',\n fr: 'Ajouter un nouveau champ',\n es: 'Agregar nuevo campo',\n de: 'Neues Feld hinzufügen',\n ja: '新しいフィールドを追加',\n ko: '새 필드 추가',\n zh: '添加新字段',\n it: 'Aggiungi nuovo campo',\n pt: 'Adicionar novo campo',\n hi: 'नया फ़ील्ड जोड़ें',\n ar: 'أضف حقلًا جديدًا',\n ru: 'Добавить новое поле',\n }),\n },\n goToElement: {\n label: t({\n en: 'Go to element',\n 'en-GB': 'Go to element',\n fr: \"Aller à l'élément\",\n es: 'Ir al elemento',\n de: 'Zum Element gehen',\n ja: '要素に移動',\n ko: '요소로 이동',\n zh: '转到元素',\n it: 'Vai all’elemento',\n pt: 'Ir para o elemento',\n hi: 'तत्व पर जाएं',\n ar: 'اذهب إلى العنصر',\n ru: 'Перейти к элементу',\n }),\n },\n addNewElement: {\n label: t({\n en: 'Click to add element',\n 'en-GB': 'Click to add element',\n fr: 'Cliquez pour ajouter un élément',\n es: 'Haga clic para agregar un elemento',\n de: 'Klicken Sie, um ein Element hinzuzufügen',\n ja: '要素を追加するにはクリック',\n ko: '요소를 추가하려면 클릭하세요',\n zh: '点击添加元素',\n it: 'Clicca per aggiungere un elemento',\n pt: 'Clique para adicionar um elemento',\n hi: 'तत्व जोड़ने के लिए क्लिक करें',\n ar: 'انقر لإضافة عنصر',\n ru: 'Нажмите, чтобы добавить элемент',\n }),\n text: t({\n en: 'Add new element',\n 'en-GB': 'Add new element',\n fr: 'Ajouter un nouvel élément',\n es: 'Agregar nuevo elemento',\n de: 'Neues Element hinzufügen',\n ja: '新しい要素を追加',\n ko: '새 요소 추가',\n zh: '添加新元素',\n it: 'Aggiungi nuovo elemento',\n pt: 'Adicionar novo elemento',\n hi: 'नया तत्व जोड़ें',\n ar: 'أضف عنصرًا جديدًا',\n ru: 'Добавить новый элемент',\n }),\n },\n goToTranslation: {\n label: t({\n en: 'Go to translation',\n 'en-GB': 'Go to translation',\n fr: 'Aller à la traduction',\n es: 'Ir a la traducción',\n de: 'Zur Übersetzung gehen',\n ja: '翻訳に移動',\n ko: '번역으로 이동',\n zh: '转到翻译',\n it: 'Vai alla traduzione',\n pt: 'Ir para a tradução',\n hi: 'अनुवाद पर जाएं',\n ar: 'اذهب إلى الترجمة',\n ru: 'Перейти к переводу',\n }),\n },\n goToEnumeration: {\n label: t({\n en: 'Go to enumeration',\n 'en-GB': 'Go to enumeration',\n fr: \"Aller à l'énumération\",\n es: 'Ir a la enumeración',\n de: 'Zur Aufzählung gehen',\n ja: '列挙に移動',\n ko: '열거로 이동',\n zh: '转到枚举',\n it: 'Vai all ENUMERAZIONE',\n pt: 'Ir para a enumeração',\n hi: 'सूची में जाएं',\n ar: 'اذهب إلى التعداد',\n ru: 'Перейти к перечислению',\n }),\n },\n addNewEnumeration: {\n label: t({\n en: 'Click to add enumeration',\n 'en-GB': 'Click to add enumeration',\n fr: 'Cliquez pour ajouter une énumération',\n es: 'Haga clic para agregar una enumeración',\n de: 'Klicken Sie, um eine Aufzählung hinzuzufügen',\n ja: '列挙を追加するにはクリック',\n ko: '열거를 추가하려면 클릭하세요',\n zh: '点击添加枚举',\n it: 'Clicca per aggiungere un enumerazione',\n pt: 'Clique para adicionar uma enumeração',\n hi: 'सूची जोड़ने के लिए क्लिक करें',\n ar: 'انقر لإضافة تعداد',\n ru: 'Нажмите, чтобы добавить перечисление',\n }),\n text: t({\n en: 'Add new enumeration',\n 'en-GB': 'Add new enumeration',\n fr: 'Ajouter une nouvelle énumération',\n es: 'Agregar nueva enumeración',\n de: 'Neue Aufzählung hinzufügen',\n ja: '新しい列挙を追加',\n ko: '새 목록 추가',\n zh: '添加新枚举',\n it: 'Aggiungi nuova enumerazione',\n pt: 'Adicionar nova enumeração',\n hi: 'नया सूची जोड़ें',\n ar: 'أضف تعدادًا جديدًا',\n ru: 'Добавить новое перечисление',\n }),\n },\n },\n} satisfies Dictionary;\n"],"names":["t"],"mappings":";;;AAEO,MAAM,wBAAwB;AAAA,EACnC,KAAK;AAAA,EACL,SAAS;AAAA,IACP,gBAAgBA,SAAAA,EAAE;AAAA,MAChB,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,IACD,WAAW;AAAA,MACT,OAAOA,SAAAA,EAAE;AAAA,QACP,IAAI;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACL,CAAA;AAAA,IACH;AAAA,IACA,aAAa;AAAA,MACX,OAAOA,SAAAA,EAAE;AAAA,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,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACL,CAAA;AAAA,IAAA;AAAA,EACH;AAEJ;;"}
|
package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationViewNode.content.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"navigationViewNode.content.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuLZ,CAAC"}
|