@intlayer/design-system 8.2.2 → 8.2.3
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/esm/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/esm/components/Avatar/index.mjs.map +1 -1
- package/dist/esm/components/Badge/index.mjs.map +1 -1
- package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/esm/components/Browser/Browser.mjs.map +1 -1
- package/dist/esm/components/Button/Button.mjs.map +1 -1
- package/dist/esm/components/Carousel/index.mjs.map +1 -1
- package/dist/esm/components/ClickOutsideDiv/index.mjs.map +1 -1
- package/dist/esm/components/CollapsibleTable/CollapsibleTable.mjs.map +1 -1
- package/dist/esm/components/Command/index.mjs.map +1 -1
- package/dist/esm/components/Container/index.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorInput.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/esm/components/ContentSelector/ContentSelector.mjs.map +1 -1
- package/dist/esm/components/CopyButton/index.mjs.map +1 -1
- package/dist/esm/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/ItemLayout.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs.map +1 -1
- package/dist/esm/components/DropDown/index.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
- package/dist/esm/components/Flags/Flag.mjs.map +1 -1
- package/dist/esm/components/Footer/index.mjs.map +1 -1
- package/dist/esm/components/Form/FormBase.mjs.map +1 -1
- package/dist/esm/components/Form/FormControl.mjs.map +1 -1
- package/dist/esm/components/Form/FormDescription.mjs.map +1 -1
- package/dist/esm/components/Form/FormField.mjs.map +1 -1
- package/dist/esm/components/Form/FormItem.mjs.map +1 -1
- package/dist/esm/components/Form/FormLabel.mjs.map +1 -1
- package/dist/esm/components/Form/FormMessage.mjs.map +1 -1
- package/dist/esm/components/Form/elements/AutoSizeTextAreaElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/CheckboxElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/EditableFieldInputElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/EditableFieldTextAreaElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElementWrapper.mjs.map +1 -1
- package/dist/esm/components/Form/elements/InputElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/InputPasswordElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/MultiselectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SearchInputElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SelectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/TextAreaElement.mjs.map +1 -1
- package/dist/esm/components/Form/layout/FormItemLayout.mjs.map +1 -1
- package/dist/esm/components/Form/layout/FormLabelLayout.mjs.map +1 -1
- package/dist/esm/components/Form/layout/RequiredStar.mjs.map +1 -1
- package/dist/esm/components/HTMLRender/HTMLRender.mjs.map +1 -1
- package/dist/esm/components/Headers/index.mjs.map +1 -1
- package/dist/esm/components/HeightResizer/index.mjs.map +1 -1
- package/dist/esm/components/HideShow/index.mjs.map +1 -1
- package/dist/esm/components/IDE/Code.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockClient.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockServer.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockShiki.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeConditionalRenderer.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeContext.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeFormatSelector.mjs.map +1 -1
- package/dist/esm/components/IDE/ContentDeclarationFormatSelector.mjs.map +1 -1
- package/dist/esm/components/IDE/CopyCode.mjs.map +1 -1
- package/dist/esm/components/IDE/FileList.mjs.map +1 -1
- package/dist/esm/components/IDE/FileTree.mjs.map +1 -1
- package/dist/esm/components/IDE/IDE.mjs.map +1 -1
- package/dist/esm/components/IDE/MarkDownRender.mjs.map +1 -1
- package/dist/esm/components/IDE/MonacoCode.mjs.map +1 -1
- package/dist/esm/components/IDE/PackageManagerSelector.mjs.map +1 -1
- package/dist/esm/components/InformationTag/index.mjs.map +1 -1
- package/dist/esm/components/Input/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Input/Input.mjs.map +1 -1
- package/dist/esm/components/Input/InputPassword.mjs.map +1 -1
- package/dist/esm/components/Input/OTPInput.mjs.map +1 -1
- package/dist/esm/components/Input/SearchInput.mjs.map +1 -1
- package/dist/esm/components/KeyboardScreenAdapter/index.mjs.map +1 -1
- package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs.map +1 -1
- package/dist/esm/components/Label/index.mjs.map +1 -1
- package/dist/esm/components/LanguageBackground/index.mjs.map +1 -1
- package/dist/esm/components/Link/Link.mjs.map +1 -1
- package/dist/esm/components/Loader/index.mjs.map +1 -1
- package/dist/esm/components/Loader/spinner.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
- package/dist/esm/components/Logo/Logo.mjs.map +1 -1
- package/dist/esm/components/Logo/LogoTextOnly.mjs.map +1 -1
- package/dist/esm/components/Logo/LogoWithText.mjs.map +1 -1
- package/dist/esm/components/Logo/LogoWithTextBelow.mjs.map +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/esm/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/esm/components/MaxWidthSmoother/index.mjs.map +1 -1
- package/dist/esm/components/Modal/Modal.mjs.map +1 -1
- package/dist/esm/components/Navbar/Burger.mjs.map +1 -1
- package/dist/esm/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/esm/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/esm/components/Navbar/index.mjs.map +1 -1
- package/dist/esm/components/Pagination/NumberItemsSelector.mjs.map +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/esm/components/Pagination/ShowingResultsNumberItems.mjs.map +1 -1
- package/dist/esm/components/Pattern/DotPattern.mjs.map +1 -1
- package/dist/esm/components/Pattern/GridPattern.mjs.map +1 -1
- package/dist/esm/components/Pattern/SpotLight.mjs.map +1 -1
- package/dist/esm/components/Popover/dynamic.mjs.map +1 -1
- package/dist/esm/components/Popover/static.mjs +1 -1
- package/dist/esm/components/Popover/static.mjs.map +1 -1
- package/dist/esm/components/PressableSpan/PressableSpan.mjs.map +1 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/esm/components/Select/Multiselect.mjs.map +1 -1
- package/dist/esm/components/Select/Select.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/DiscordLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/FacebookLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/InstagramLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/LinkedInLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/ProductHuntLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/TiktokLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/XLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/YoutubeLogo.mjs.map +1 -1
- package/dist/esm/components/SocialNetworks/index.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/index.mjs.map +1 -1
- package/dist/esm/components/Tab/Tab.mjs.map +1 -1
- package/dist/esm/components/Tab/TabContext.mjs.map +1 -1
- package/dist/esm/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/esm/components/Table/Table.mjs.map +1 -1
- package/dist/esm/components/Tag/index.mjs.map +1 -1
- package/dist/esm/components/Terminal/Terminal.mjs.map +1 -1
- package/dist/esm/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/types.mjs.map +1 -1
- package/dist/esm/components/Toaster/Toast.mjs.map +1 -1
- package/dist/esm/components/Toaster/Toaster.mjs.map +1 -1
- package/dist/esm/components/Toaster/useToast.mjs.map +1 -1
- package/dist/esm/components/WithResizer/index.mjs.map +1 -1
- package/dist/esm/hooks/index.mjs +1 -1
- package/dist/esm/hooks/reactQuery.mjs +1 -1
- package/dist/esm/hooks/reactQuery.mjs.map +1 -1
- package/dist/esm/providers/ReactQueryProvider.mjs.map +1 -1
- package/dist/esm/utils/image.mjs.map +1 -1
- package/dist/types/components/Badge/index.d.ts +2 -2
- package/dist/types/components/Button/Button.d.ts +3 -3
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +1 -1
- package/dist/types/components/Command/index.d.ts +1 -1
- package/dist/types/components/Container/index.d.ts +8 -8
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +1 -1
- package/dist/types/components/Input/Checkbox.d.ts +3 -3
- package/dist/types/components/Input/Input.d.ts +1 -1
- package/dist/types/components/Link/Link.d.ts +4 -4
- package/dist/types/components/Pagination/Pagination.d.ts +2 -2
- package/dist/types/components/Popover/static.d.ts.map +1 -1
- package/dist/types/components/SwitchSelector/index.d.ts +1 -1
- package/dist/types/components/Tab/Tab.d.ts +2 -2
- package/dist/types/components/TabSelector/TabSelector.d.ts +1 -1
- package/dist/types/components/Tag/index.d.ts +3 -3
- package/dist/types/hooks/index.d.ts +2 -2
- package/dist/types/hooks/reactQuery.d.ts +12 -1
- package/dist/types/hooks/reactQuery.d.ts.map +1 -1
- package/package.json +27 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase","MarkdownRenderer"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '@components/ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '@components/ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '@components/Input';\nimport { Label } from '@components/Label';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '@components/MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '@components/SwitchSelector';\nimport { useAuditContentDeclarationField } from '@hooks/reactQuery';\nimport {\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n GenderContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport {\n type ContentNode,\n type Dictionary,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { renameKey } from '@utils/object';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\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 const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-translation-${translationKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"flex w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ] as KeyPath[];\n const uniqueKey = `${JSON.stringify(keyPath)}-enumeration-${enumKey}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full\">\n <td className=\"flex w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n Icon={Trash}\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </td>\n </tr>\n <tr className=\"w-full p-2\">\n <td className=\"flex w-full\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n\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 console.log('newValue', newValue);\n\n addEditedContent(\n dictionary.localId!,\n newValue,\n keyPath\n );\n }}\n />\n </td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-condition-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-gender-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-array-${index}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2\">\n <td className=\"flex w-full\">\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index, // Fixed: Use index instead of length\n },\n ];\n addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </div>\n </td>\n </tr>\n\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length, // Keeps length for adding new items\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 p-2 text-xs\">\n <td className=\"flex w-full\">{String(key)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nenum HtmlViewMode {\n Edit,\n Preview,\n}\n\nconst HtmlTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n}) => {\n const [mode, setMode] = useState(HtmlViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: HtmlViewMode.Edit,\n },\n {\n content: 'Preview',\n value: HtmlViewMode.Preview,\n },\n ] as SwitchSelectorChoices<HtmlViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeType.HTML\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === HtmlViewMode.Preview\n ? (content) => (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML content is user-controlled and rendered in editor context\n <div dangerouslySetInnerHTML={{ __html: content }} />\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <span>(React Node)</span>\n <span className=\"flex text-neutral text-xs\">{tsxNotEditable}</span>\n </div>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"],"mappings":"m6CA4DA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAU3D,GAAyD,CAC7D,UACA,aACA,GAAG,KACC,CACJ,GAAM,CAAE,gBAAe,oBAAqB,GAAkB,CACxD,EAAgB,GAAkB,CAClC,CAAE,OAAQ,EAA8B,UAAW,GACvD,GAAiC,CAEnC,OACE,EAACA,EAAAA,CACC,QAAS,EAAa,QACtB,gBAAkB,GAChB,EAAiB,EAAW,QAAU,EAAU,EAAQ,CAE1D,kBACE,EAAC,EAAA,CACC,KAAM,EACN,MAAM,QACN,QAAS,EAAc,UACvB,KAAM,EAAW,QACjB,MAAO,EAAY,KACnB,UAAU,iCACV,UAAW,EACX,YAAe,CACb,EACE,CACE,YAAa,KAAK,UAAU,CAC1B,GAAG,EACH,GAAI,IAAgB,EAAW,UAAa,EAAE,CAC/C,CAAC,CACF,UACA,QAAS,EAAc,qBAAqB,SAAW,EAAE,CACzD,UAAW,CACT,OAAQ,EAAc,IAAI,OAC1B,MAAO,EAAc,IAAI,MACzB,YAAa,EAAc,IAAI,YAChC,CACF,CACD,CACE,UAAY,GAAa,CAClB,MAAU,KAEf,GAAI,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UAAU,sBACb,EAAC,EAAA,CACa,aACH,UACT,KAAK,SACL,aAAW,sBAEV,GACkB,EACjB,CAIN,IAAa,EAAS,KAEtB,EAAC,MAAA,CAAI,UAAU,sBACZ,OAAO,GAAkB,WACxB,EAAc,EAAkB,CAEhC,EAAC,EAAA,CACC,QAAS,EAAa,QACtB,aAAW,aACF,UACG,sBAEX,GACqB,EAEtB,CAIN,IAAa,EAAS,QAEtB,EAAC,MAAA,CAAI,UAAU,sBACb,EAAC,EAAA,CACa,aACH,UACT,MAAO,GACP,EACE,CAKR,EAAC,MAAA,CAAI,UAAU,uBAAa,+BAEzB,KAAK,UAAU,EAAS,KAAM,EAAE,CAChC,KAAK,UAAU,EAAS,KAAM,EAAE,CAAC,cACtB,IACR,EAIG,EAA4C,GACvD,EAAC,EAAA,CACC,OAAA,GACA,WAAW,OACX,UAAU,wEACV,YAAY,cAEZ,EAAC,EAAA,CAAW,GAAI,EAAA,CAAS,EACf"}
|
|
1
|
+
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase","MarkdownRenderer"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '@components/ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '@components/ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '@components/Input';\nimport { Label } from '@components/Label';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '@components/MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '@components/SwitchSelector';\nimport { useAuditContentDeclarationField } from '@hooks/reactQuery';\nimport {\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n GenderContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport {\n type ContentNode,\n type Dictionary,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { renameKey } from '@utils/object';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\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 const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-translation-${translationKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"flex w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ] as KeyPath[];\n const uniqueKey = `${JSON.stringify(keyPath)}-enumeration-${enumKey}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full\">\n <td className=\"flex w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n Icon={Trash}\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </td>\n </tr>\n <tr className=\"w-full p-2\">\n <td className=\"flex w-full\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n\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 console.log('newValue', newValue);\n\n addEditedContent(\n dictionary.localId!,\n newValue,\n keyPath\n );\n }}\n />\n </td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-condition-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-gender-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-array-${index}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2\">\n <td className=\"flex w-full\">\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index, // Fixed: Use index instead of length\n },\n ];\n addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </div>\n </td>\n </tr>\n\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length, // Keeps length for adding new items\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 p-2 text-xs\">\n <td className=\"flex w-full\">{String(key)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nenum HtmlViewMode {\n Edit,\n Preview,\n}\n\nconst HtmlTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n}) => {\n const [mode, setMode] = useState(HtmlViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: HtmlViewMode.Edit,\n },\n {\n content: 'Preview',\n value: HtmlViewMode.Preview,\n },\n ] as SwitchSelectorChoices<HtmlViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeType.HTML\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === HtmlViewMode.Preview\n ? (content) => (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML content is user-controlled and rendered in editor context\n <div dangerouslySetInnerHTML={{ __html: content }} />\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <span>(React Node)</span>\n <span className=\"flex text-neutral text-xs\">{tsxNotEditable}</span>\n </div>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"],"mappings":"m6CA4DA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAU3D,GAAyD,CAC7D,UACA,aACA,GAAG,KACC,CACJ,GAAM,CAAE,gBAAe,oBAAqB,GAAkB,CACxD,EAAgB,GAAkB,CAClC,CAAE,OAAQ,EAA8B,UAAW,GACvD,GAAiC,CAEnC,OACE,EAACA,EAAD,CACE,QAAS,EAAa,QACtB,gBAAkB,GAChB,EAAiB,EAAW,QAAU,EAAU,EAAQ,CAE1D,kBACE,EAAC,EAAD,CACE,KAAM,EACN,MAAM,QACN,QAAS,EAAc,UACvB,KAAM,EAAW,QACjB,MAAO,EAAY,KACnB,UAAU,iCACV,UAAW,EACX,YAAe,CACb,EACE,CACE,YAAa,KAAK,UAAU,CAC1B,GAAG,EACH,GAAI,IAAgB,EAAW,UAAa,EAAE,CAC/C,CAAC,CACF,UACA,QAAS,EAAc,qBAAqB,SAAW,EAAE,CACzD,UAAW,CACT,OAAQ,EAAc,IAAI,OAC1B,MAAO,EAAc,IAAI,MACzB,YAAa,EAAc,IAAI,YAChC,CACF,CACD,CACE,UAAY,GAAa,CAClB,MAAU,KAEf,GAAI,CACF,IAAM,EAAgB,EAAS,KAAK,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AS,UAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,SAEtB,EAAC,EAAD,CACc,aACH,UACA,UACG,aACZ,CAAA,CAIF,IAAa,EAAS,KAEtB,EAAC,EAAD,CACc,aACH,UACA,UACT,CAAA,CAIF,IAAa,EAAS,KAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,MAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,OAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,OAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,KAAK,SACL,aAAW,sBAEV,EACkB,CAAA,CACjB,CAAA,CAIN,IAAa,EAAS,KAEtB,EAAC,MAAD,CAAK,UAAU,sBACZ,OAAO,GAAkB,WACxB,EAAc,EAAkB,CAEhC,EAAC,EAAD,CACE,QAAS,EAAa,QACtB,aAAW,aACF,UACG,sBAEX,EACqB,CAAA,CAEtB,CAAA,CAIN,IAAa,EAAS,QAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,MAAO,EACP,CAAA,CACE,CAAA,CAKR,EAAC,MAAD,CAAK,UAAU,sBAAf,CAA4B,+BAEzB,KAAK,UAAU,EAAS,KAAM,EAAE,CAChC,KAAK,UAAU,EAAS,KAAM,EAAE,CAAC,cACtB,EACR,IAIG,EAA4C,GACvD,EAAC,EAAD,CACE,OAAA,GACA,WAAW,OACX,UAAU,wEACV,YAAY,cAEZ,EAAC,EAAD,CAAY,GAAI,EAAS,CAAA,CACf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryCreationForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { MultiSelect } from '@components/Select';\nimport { useAddDictionary, useGetProjects } from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport {\n type DictionaryFormData,\n useDictionarySchema,\n} from './useDictionaryFormSchema';\n\ntype DictionaryCreationFormProps = {\n onDictionaryCreated?: () => void;\n};\n\nexport const DictionaryCreationForm: FC<DictionaryCreationFormProps> = ({\n onDictionaryCreated,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { mutate: addDictionary, isPending } = useAddDictionary();\n const { data: projectsData } = useGetProjects();\n const DictionarySchema = useDictionarySchema(String(project?.id));\n const { form, isSubmitting } = useForm(DictionarySchema);\n const { keyInput, createDictionaryButton, projectInput } =\n useIntlayer('dictionary-form');\n\n const onSubmitSuccess = (data: DictionaryFormData) => {\n addDictionary(\n { dictionary: data },\n {\n onSuccess: () => {\n onDictionaryCreated?.();\n },\n }\n );\n };\n\n return (\n <Form\n schema={DictionarySchema}\n onSubmitSuccess={onSubmitSuccess}\n className=\"m-auto w-full max-w-[400px]\"\n {...form}\n >\n <Form.Input\n name=\"key\"\n label={keyInput.label.value}\n placeholder={keyInput.placeholder.value}\n isRequired\n />\n\n <Form.MultiSelect name=\"projectIds\" label={projectInput.label.value}>\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projectsData?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <MultiSelect.List>\n {projectsData?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.Button\n className=\"mt-12 ml-auto\"\n type=\"submit\"\n color={ButtonColor.TEXT}\n isLoading={isSubmitting || isPending}\n label={createDictionaryButton.ariaLabel.value}\n isFullWidth\n >\n {createDictionaryButton.text}\n </Form.Button>\n </Form>\n );\n};\n"],"mappings":"shBAkBA,MAAa,GAA2D,CACtE,yBACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,OAAQ,EAAe,aAAc,GAAkB,CACzD,CAAE,KAAM,GAAiB,GAAgB,CACzC,EAAmB,EAAoB,OAAO,GAAS,GAAG,CAAC,CAC3D,CAAE,OAAM,gBAAiB,EAAQ,EAAiB,CAClD,CAAE,WAAU,yBAAwB,gBACxC,EAAY,kBAAkB,CAahC,OACE,EAAC,
|
|
1
|
+
{"version":3,"file":"DictionaryCreationForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { MultiSelect } from '@components/Select';\nimport { useAddDictionary, useGetProjects } from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport {\n type DictionaryFormData,\n useDictionarySchema,\n} from './useDictionaryFormSchema';\n\ntype DictionaryCreationFormProps = {\n onDictionaryCreated?: () => void;\n};\n\nexport const DictionaryCreationForm: FC<DictionaryCreationFormProps> = ({\n onDictionaryCreated,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { mutate: addDictionary, isPending } = useAddDictionary();\n const { data: projectsData } = useGetProjects();\n const DictionarySchema = useDictionarySchema(String(project?.id));\n const { form, isSubmitting } = useForm(DictionarySchema);\n const { keyInput, createDictionaryButton, projectInput } =\n useIntlayer('dictionary-form');\n\n const onSubmitSuccess = (data: DictionaryFormData) => {\n addDictionary(\n { dictionary: data },\n {\n onSuccess: () => {\n onDictionaryCreated?.();\n },\n }\n );\n };\n\n return (\n <Form\n schema={DictionarySchema}\n onSubmitSuccess={onSubmitSuccess}\n className=\"m-auto w-full max-w-[400px]\"\n {...form}\n >\n <Form.Input\n name=\"key\"\n label={keyInput.label.value}\n placeholder={keyInput.placeholder.value}\n isRequired\n />\n\n <Form.MultiSelect name=\"projectIds\" label={projectInput.label.value}>\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projectsData?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <MultiSelect.List>\n {projectsData?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.Button\n className=\"mt-12 ml-auto\"\n type=\"submit\"\n color={ButtonColor.TEXT}\n isLoading={isSubmitting || isPending}\n label={createDictionaryButton.ariaLabel.value}\n isFullWidth\n >\n {createDictionaryButton.text}\n </Form.Button>\n </Form>\n );\n};\n"],"mappings":"shBAkBA,MAAa,GAA2D,CACtE,yBACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,OAAQ,EAAe,aAAc,GAAkB,CACzD,CAAE,KAAM,GAAiB,GAAgB,CACzC,EAAmB,EAAoB,OAAO,GAAS,GAAG,CAAC,CAC3D,CAAE,OAAM,gBAAiB,EAAQ,EAAiB,CAClD,CAAE,WAAU,yBAAwB,gBACxC,EAAY,kBAAkB,CAahC,OACE,EAAC,EAAD,CACE,OAAQ,EACS,gBAdI,GAA6B,CACpD,EACE,CAAE,WAAY,EAAM,CACpB,CACE,cAAiB,CACf,KAAuB,EAE1B,CACF,EAOC,UAAU,8BACV,GAAI,WAJN,CAME,EAAC,EAAK,MAAN,CACE,KAAK,MACL,MAAO,EAAS,MAAM,MACtB,YAAa,EAAS,YAAY,MAClC,WAAA,GACA,CAAA,CAEF,EAAC,EAAK,YAAN,CAAkB,KAAK,aAAa,MAAO,EAAa,MAAM,eAA9D,CACE,EAAC,EAAY,QAAb,CACE,cAAgB,GACd,GAAc,MAAM,KAAM,GAAY,OAAO,EAAQ,GAAG,GAAK,EAAM,EAC/D,MAAQ,WAGd,EAAC,EAAY,MAAb,CAAmB,YAAa,EAAa,YAAY,MAAS,CAAA,CAC9C,CAAA,CACtB,EAAC,EAAY,QAAb,CAAA,SACE,EAAC,EAAY,KAAb,CAAA,SACG,GAAc,MAAM,IAAK,GACxB,EAAC,EAAY,KAAb,CAEE,MAAO,OAAO,EAAQ,GAAG,UAExB,EAAQ,KACQ,CAJZ,OAAO,EAAQ,GAAG,CAIN,CACnB,CACe,CAAA,CACC,CAAA,CACL,GAEnB,EAAC,EAAK,OAAN,CACE,UAAU,gBACV,KAAK,SACL,MAAO,EAAY,KACnB,UAAW,GAAgB,EAC3B,MAAO,EAAuB,UAAU,MACxC,YAAA,YAEC,EAAuB,KACZ,CAAA,CACT"}
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = response.data.fileContent;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n filePath: newFilePath,\n }));\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n }));\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n filePath: value,\n }));\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n importMode: value as any,\n }));\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":"y+BA2BA,MAAa,GAAqD,CAChE,aACA,UACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,KAAM,EAAc,UAAW,GACrC,GAAgB,CACZ,CAAE,KAAM,GAAa,GAAY,CAEjC,EAAY,GAAc,MAAQ,EAAE,CACpC,EAAW,GAAU,MAAQ,EAAE,CAE/B,EAA0B,EAC9B,OAAO,GAAS,GAAG,CACpB,CACK,CAAE,OAAM,gBAAiBA,EAAQ,EAAyB,CAC9D,cAAe,CACb,GAAG,EACH,SAAU,EAAW,UAAY,SAClC,CACF,CAAC,CACI,CAAE,gBAAe,uBAAwB,GAAkB,CAC3D,CACJ,aACA,WACA,mBACA,eACA,aACA,iBACA,mBACA,gBACA,eACE,EAAY,qBAAqB,CAC/B,CAAE,OAAQ,EAAyB,UAAW,GAClD,GAAoC,CAChC,EACJ,I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AAC,EAAM,CAAC,MAAM,CACjC,EAAK,SAAS,OAAQ,EAAY,CAAE,YAAa,GAAM,CAAC,CACxD,EAAqB,IAAU,CAC7B,GAAG,EACH,GAAI,GAAQ,EAAE,CACd,KAAM,EACP,EAAE,YAGL,EAAC,EAAY,QAAA,CACX,cAAgB,GACd,GAAS,KAAM,GAAa,OAAO,EAAI,IAAI,GAAK,EAAM,EAAE,MACxD,WAGF,EAAC,EAAY,MAAA,CAAM,YAAa,EAAW,YAAY,MAAA,CAAS,EAC5C,CACtB,EAAC,EAAY,QAAA,CAAA,SACX,EAAC,EAAA,CAAO,UAAW,WACjB,EAAC,EAAY,KAAA,CAAA,SACV,GAAS,IAAK,GACb,EAAC,EAAY,KAAA,CAEX,MAAO,OAAO,EAAI,IAAI,UAErB,EAAI,MAAQ,EAAI,KAHZ,OAAO,EAAI,IAAI,CAIH,CACnB,CAAA,CACe,EACZ,CAAA,CACW,CAAA,EACL,CAAA,EACf,CAEN,EAAC,MAAA,CAAI,UAAU,yEACb,EAAC,EAAK,OAAA,CACJ,KAAK,SACL,KAAM,EAAW,QACjB,MAAO,EAAY,MAAM,MACzB,KAAM,EACN,QAAS,EAAc,QACvB,MAAO,EAAY,KACnB,UAAU,gBACV,QAAS,EACT,SAAU,GAAgB,EAC1B,UAAW,GACX,EACE,GACD"}
|
|
1
|
+
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = response.data.fileContent;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n filePath: newFilePath,\n }));\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n }));\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n filePath: value,\n }));\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n importMode: value as any,\n }));\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":"y+BA2BA,MAAa,GAAqD,CAChE,aACA,UACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,KAAM,EAAc,UAAW,GACrC,GAAgB,CACZ,CAAE,KAAM,GAAa,GAAY,CAEjC,EAAY,GAAc,MAAQ,EAAE,CACpC,EAAW,GAAU,MAAQ,EAAE,CAE/B,EAA0B,EAC9B,OAAO,GAAS,GAAG,CACpB,CACK,CAAE,OAAM,gBAAiBA,EAAQ,EAAyB,CAC9D,cAAe,CACb,GAAG,EACH,SAAU,EAAW,UAAY,SAClC,CACF,CAAC,CACI,CAAE,gBAAe,uBAAwB,GAAkB,CAC3D,CACJ,aACA,WACA,mBACA,eACA,aAC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,EAAQ,GAAG,UAExB,EAAQ,KACQ,CAJZ,OAAO,EAAQ,GAAG,CAIN,CACnB,CACe,CAAA,CACZ,CAAA,CACW,CAAA,CACL,GAEnB,EAAC,EAAK,YAAN,CACE,KAAK,OACL,MAAO,EAAW,MAAM,MACxB,YAAa,EAAW,YACxB,cAAgB,GAAU,CACxB,IAAM,EAAa,CAAC,EAAM,CAAC,MAAM,CACjC,EAAK,SAAS,OAAQ,EAAY,CAAE,YAAa,GAAM,CAAC,CACxD,EAAqB,IAAU,CAC7B,GAAG,EACH,GAAI,GAAQ,EAAE,CACd,KAAM,EACP,EAAE,WAXP,CAcE,EAAC,EAAY,QAAb,CACE,cAAgB,GACd,GAAS,KAAM,GAAa,OAAO,EAAI,IAAI,GAAK,EAAM,EAAE,MACxD,WAGF,EAAC,EAAY,MAAb,CAAmB,YAAa,EAAW,YAAY,MAAS,CAAA,CAC5C,CAAA,CACtB,EAAC,EAAY,QAAb,CAAA,SACE,EAAC,EAAD,CAAQ,UAAW,WACjB,EAAC,EAAY,KAAb,CAAA,SACG,GAAS,IAAK,GACb,EAAC,EAAY,KAAb,CAEE,MAAO,OAAO,EAAI,IAAI,UAErB,EAAI,MAAQ,EAAI,IACA,CAJZ,OAAO,EAAI,IAAI,CAIH,CACnB,CACe,CAAA,CACZ,CAAA,CACW,CAAA,CACL,GACf,GAEN,EAAC,MAAD,CAAK,UAAU,yEACb,EAAC,EAAK,OAAN,CACE,KAAK,SACL,KAAM,EAAW,QACjB,MAAO,EAAY,MAAM,MACzB,KAAM,EACN,QAAS,EAAc,QACvB,MAAO,EAAY,KACnB,UAAU,gBACV,QAAS,EACT,SAAU,GAAgB,EAC1B,UAAW,EACX,CAAA,CACE,CAAA,CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.localId!]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"sticky bottom-16 z-20 flex shrink-0 flex-wrap items-center justify-end gap-10 border-card border-t p-4 md:bottom-0\">\n <CopyToClipboard\n text={dictionary.id!}\n className=\"text-nowrap text-neutral text-sm\"\n size={9}\n >\n {dictionary.id}\n </CopyToClipboard>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n onSave={onSave}\n />\n </div>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"mappings":"83BA+BA,MAAa,GAAyD,CACpE,aACA,wBACA,aACA,OACA,WACA,SACA,mBAAmB,MACf,CACJ,IAAM,EAAS,GAAkB,CAC3B,CAAE,0BAA2B,EAAY,0BAA0B,CACnE,CAAE,qBAAsB,GAA4B,CACpD,CAAE,yBAA0B,GAA8B,CAehE,OAbA,MAAgB,CAEd,EAAmB,IAAU,CAC3B,GAAI,GAAQ,EAAE,CACd,cAAe,EAAW,IAC1B,kBAAmB,EAAW,QAC/B,EAAE,CACH,EAAuB,IAAU,CAC/B,GAAG,GACF,EAAW,SAAW,EACxB,EAAE,EACF,EAAE,CAAC,CAGJ,EAAC,
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.localId!]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"sticky bottom-16 z-20 flex shrink-0 flex-wrap items-center justify-end gap-10 border-card border-t p-4 md:bottom-0\">\n <CopyToClipboard\n text={dictionary.id!}\n className=\"text-nowrap text-neutral text-sm\"\n size={9}\n >\n {dictionary.id}\n </CopyToClipboard>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n onSave={onSave}\n />\n </div>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"mappings":"83BA+BA,MAAa,GAAyD,CACpE,aACA,wBACA,aACA,OACA,WACA,SACA,mBAAmB,MACf,CACJ,IAAM,EAAS,GAAkB,CAC3B,CAAE,0BAA2B,EAAY,0BAA0B,CACnE,CAAE,qBAAsB,GAA4B,CACpD,CAAE,yBAA0B,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|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumKeyInput.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useMemo, useState } from 'react';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\n\nconst extractInitialState = (\n value: string | number\n): { comparator: string | undefined; numberValue: string | undefined } => {\n let comparator: string | undefined;\n let numberValue: string | undefined;\n\n if (typeof value === 'number' || !Number.isNaN(Number(value))) {\n // If value is a number or numeric string, set comparator to '=' and numberValue accordingly\n comparator = '=';\n numberValue = value.toString();\n } else if (typeof value === 'string') {\n // Define possible comparators\n const comparators = ['<=', '>=', '<', '>', '='];\n // Find the comparator that matches the start of the string\n const matchedComparator = comparators.find((comp) =>\n value.startsWith(comp)\n );\n if (matchedComparator) {\n comparator = matchedComparator;\n numberValue = value.slice(matchedComparator.length);\n }\n }\n\n return { comparator, numberValue };\n};\n\ntype EnumKeyInputProps = {\n value: string | number;\n onChange: (value: string) => void;\n};\n\n/**\n * Example of values:\n * - `<1`\n * - `>-44.3`\n * - `=999`\n * - `<=1`\n * - `>=1`\n * - 88\n * - `-1`\n *\n */\nexport const EnumKeyInput: FC<EnumKeyInputProps> = ({ value, onChange }) => {\n const { comparator: initialComparator, numberValue: initialNumberValue } =\n useMemo(() => extractInitialState(value), [value]);\n const [comparator, setComparator] = useState<string | null>(\n initialComparator ?? null\n );\n const [numberValue, setNumberValue] = useState<string | null>(\n initialNumberValue ?? null\n );\n\n useEffect(() => {\n if (\n comparator &&\n numberValue &&\n (comparator !== initialComparator || numberValue !== initialNumberValue)\n ) {\n const newValue = `${comparator}${numberValue}`;\n\n onChange(newValue);\n }\n }, [\n comparator,\n initialComparator,\n initialNumberValue,\n numberValue,\n onChange,\n ]);\n\n return (\n <div className=\"flex gap-1\">\n <Select onValueChange={setComparator} defaultValue={initialComparator}>\n <Select.Trigger className=\"w-20\">\n <Select.Value placeholder=\"Select a comparator\" />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"<\">{`<`}</Select.Item>\n <Select.Item value=\"<=\">{`<=`}</Select.Item>\n <Select.Item value=\"=\">{`=`}</Select.Item>\n <Select.Item value=\">=\">{`>=`}</Select.Item>\n <Select.Item value=\">\">{`>`}</Select.Item>\n </Select.Content>\n </Select>\n <Input\n type=\"number\"\n aria-label=\"Quantity\"\n defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"min-w-4\"\n />\n </div>\n );\n};\n"],"mappings":"qNAMA,MAAM,EACJ,GACwE,CACxE,IAAI,EACA,EAEJ,GAAI,OAAO,GAAU,UAAY,CAAC,OAAO,MAAM,OAAO,EAAM,CAAC,CAE3D,EAAa,IACb,EAAc,EAAM,UAAU,SACrB,OAAO,GAAU,SAAU,CAIpC,IAAM,EAFc,CAAC,KAAM,KAAM,IAAK,IAAK,IAAI,CAET,KAAM,GAC1C,EAAM,WAAW,EAAK,CACvB,CACG,IACF,EAAa,EACb,EAAc,EAAM,MAAM,EAAkB,OAAO,EAIvD,MAAO,CAAE,aAAY,cAAa,EAmBvB,GAAuC,CAAE,QAAO,cAAe,CAC1E,GAAM,CAAE,WAAY,EAAmB,YAAa,GAClD,MAAc,EAAoB,EAAM,CAAE,CAAC,EAAM,CAAC,CAC9C,CAAC,EAAY,GAAiB,EAClC,GAAqB,KACtB,CACK,CAAC,EAAa,GAAkB,EACpC,GAAsB,KACvB,CAoBD,OAlBA,MAAgB,CAEZ,GACA,IACC,IAAe,GAAqB,IAAgB,IAIrD,EAFiB,GAAG,IAAa,IAEf,EAEnB,CACD,EACA,EACA,EACA,EACA,EACD,CAAC,CAGA,EAAC,
|
|
1
|
+
{"version":3,"file":"EnumKeyInput.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useMemo, useState } from 'react';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\n\nconst extractInitialState = (\n value: string | number\n): { comparator: string | undefined; numberValue: string | undefined } => {\n let comparator: string | undefined;\n let numberValue: string | undefined;\n\n if (typeof value === 'number' || !Number.isNaN(Number(value))) {\n // If value is a number or numeric string, set comparator to '=' and numberValue accordingly\n comparator = '=';\n numberValue = value.toString();\n } else if (typeof value === 'string') {\n // Define possible comparators\n const comparators = ['<=', '>=', '<', '>', '='];\n // Find the comparator that matches the start of the string\n const matchedComparator = comparators.find((comp) =>\n value.startsWith(comp)\n );\n if (matchedComparator) {\n comparator = matchedComparator;\n numberValue = value.slice(matchedComparator.length);\n }\n }\n\n return { comparator, numberValue };\n};\n\ntype EnumKeyInputProps = {\n value: string | number;\n onChange: (value: string) => void;\n};\n\n/**\n * Example of values:\n * - `<1`\n * - `>-44.3`\n * - `=999`\n * - `<=1`\n * - `>=1`\n * - 88\n * - `-1`\n *\n */\nexport const EnumKeyInput: FC<EnumKeyInputProps> = ({ value, onChange }) => {\n const { comparator: initialComparator, numberValue: initialNumberValue } =\n useMemo(() => extractInitialState(value), [value]);\n const [comparator, setComparator] = useState<string | null>(\n initialComparator ?? null\n );\n const [numberValue, setNumberValue] = useState<string | null>(\n initialNumberValue ?? null\n );\n\n useEffect(() => {\n if (\n comparator &&\n numberValue &&\n (comparator !== initialComparator || numberValue !== initialNumberValue)\n ) {\n const newValue = `${comparator}${numberValue}`;\n\n onChange(newValue);\n }\n }, [\n comparator,\n initialComparator,\n initialNumberValue,\n numberValue,\n onChange,\n ]);\n\n return (\n <div className=\"flex gap-1\">\n <Select onValueChange={setComparator} defaultValue={initialComparator}>\n <Select.Trigger className=\"w-20\">\n <Select.Value placeholder=\"Select a comparator\" />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"<\">{`<`}</Select.Item>\n <Select.Item value=\"<=\">{`<=`}</Select.Item>\n <Select.Item value=\"=\">{`=`}</Select.Item>\n <Select.Item value=\">=\">{`>=`}</Select.Item>\n <Select.Item value=\">\">{`>`}</Select.Item>\n </Select.Content>\n </Select>\n <Input\n type=\"number\"\n aria-label=\"Quantity\"\n defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"min-w-4\"\n />\n </div>\n );\n};\n"],"mappings":"qNAMA,MAAM,EACJ,GACwE,CACxE,IAAI,EACA,EAEJ,GAAI,OAAO,GAAU,UAAY,CAAC,OAAO,MAAM,OAAO,EAAM,CAAC,CAE3D,EAAa,IACb,EAAc,EAAM,UAAU,SACrB,OAAO,GAAU,SAAU,CAIpC,IAAM,EAFc,CAAC,KAAM,KAAM,IAAK,IAAK,IAAI,CAET,KAAM,GAC1C,EAAM,WAAW,EAAK,CACvB,CACG,IACF,EAAa,EACb,EAAc,EAAM,MAAM,EAAkB,OAAO,EAIvD,MAAO,CAAE,aAAY,cAAa,EAmBvB,GAAuC,CAAE,QAAO,cAAe,CAC1E,GAAM,CAAE,WAAY,EAAmB,YAAa,GAClD,MAAc,EAAoB,EAAM,CAAE,CAAC,EAAM,CAAC,CAC9C,CAAC,EAAY,GAAiB,EAClC,GAAqB,KACtB,CACK,CAAC,EAAa,GAAkB,EACpC,GAAsB,KACvB,CAoBD,OAlBA,MAAgB,CAEZ,GACA,IACC,IAAe,GAAqB,IAAgB,IAIrD,EAFiB,GAAG,IAAa,IAEf,EAEnB,CACD,EACA,EACA,EACA,EACA,EACD,CAAC,CAGA,EAAC,MAAD,CAAK,UAAU,sBAAf,CACE,EAAC,EAAD,CAAQ,cAAe,EAAe,aAAc,WAApD,CACE,EAAC,EAAO,QAAR,CAAgB,UAAU,gBACxB,EAAC,EAAO,MAAR,CAAc,YAAY,sBAAwB,CAAA,CACnC,CAAA,CACjB,EAAC,EAAO,QAAR,CAAA,SAAA,CACE,EAAC,EAAO,KAAR,CAAa,MAAM,aAAK,IAAkB,CAAA,CAC1C,EAAC,EAAO,KAAR,CAAa,MAAM,cAAM,KAAmB,CAAA,CAC5C,EAAC,EAAO,KAAR,CAAa,MAAM,aAAK,IAAkB,CAAA,CAC1C,EAAC,EAAO,KAAR,CAAa,MAAM,cAAM,KAAmB,CAAA,CAC5C,EAAC,EAAO,KAAR,CAAa,MAAM,aAAK,IAAkB,CAAA,CAC3B,CAAA,CAAA,CACV,GACT,EAAC,EAAD,CACE,KAAK,SACL,aAAW,WACX,aAAc,GAAe,IAAA,GAC7B,SAAW,GAAM,EAAe,EAAE,OAAO,MAAM,CAC/C,UAAU,UACV,CAAA,CACE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":"qJAUA,MAAa,GAAmC,CAAE,aAAY,gBAAiB,CAC7E,GAAM,CAAE,mBAAkB,iBAAkB,GAAkB,CAExD,EAAe,GAAgC,CACnD,GAAI,CAEF,OADA,KAAK,MAAM,EAAW,CACf,QACQ,CACf,MAAO,KAIL,EACJ,IAAgB,EAAW,UAAW,SAAW,GAAY,QAE/D,OACE,EAAC,
|
|
1
|
+
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":"qJAUA,MAAa,GAAmC,CAAE,aAAY,gBAAiB,CAC7E,GAAM,CAAE,mBAAkB,iBAAkB,GAAkB,CAExD,EAAe,GAAgC,CACnD,GAAI,CAEF,OADA,KAAK,MAAM,EAAW,CACf,QACQ,CACf,MAAO,KAIL,EACJ,IAAgB,EAAW,UAAW,SAAW,GAAY,QAE/D,OACE,EAAC,EAAD,CACE,SAAS,OACT,SAAW,GAAY,CACjB,EAAY,GAAW,KAAK,EAC9B,EAAiB,EAAW,QAAU,KAAK,MAAM,GAAW,KAAK,CAAC,EAG1D,sBAEX,KAAK,UAAU,EAAkB,KAAM,EAAE,CAC/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { KeyPath, Locale } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { Breadcrumb, type BreadcrumbLink } from '../Breadcrumb';\nimport type { LinkColor } from '../Link';\n\ntype KeyPathBreadcrumbProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n onClickKeyPath?: (keyPath: KeyPath[]) => void;\n locale?: Locale;\n color?: LinkColor | `${LinkColor}`;\n showDictionaryKey?: boolean;\n};\n\nexport const KeyPathBreadcrumb: FC<KeyPathBreadcrumbProps> = ({\n keyPath,\n dictionaryKey,\n onClickKeyPath,\n locale,\n color,\n showDictionaryKey = true,\n}) => {\n const formattedKeyPath: BreadcrumbLink[] = [\n ...(showDictionaryKey\n ? [\n {\n text: camelCaseToSentence(dictionaryKey),\n onClick: onClickKeyPath ? () => onClickKeyPath([]) : undefined,\n },\n ]\n : []),\n ...keyPath.map((el, index) => ({\n onClick: onClickKeyPath\n ? () =>\n // With keyPath = [{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}, {type: NodeType.Object, key: '1'}]\n // If index is 0 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}])\n // If index is 1 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}])\n onClickKeyPath?.(keyPath.slice(0, index + 1))\n : undefined,\n\n text: el.key?.toString() ?? '',\n })),\n ];\n\n return (\n <Breadcrumb\n links={formattedKeyPath}\n locale={locale}\n elementType=\"location\"\n color={color}\n />\n );\n};\n"],"mappings":"2JAeA,MAAa,GAAiD,CAC5D,UACA,gBACA,iBACA,SACA,QACA,oBAAoB,MAyBlB,EAAC,
|
|
1
|
+
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { KeyPath, Locale } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { Breadcrumb, type BreadcrumbLink } from '../Breadcrumb';\nimport type { LinkColor } from '../Link';\n\ntype KeyPathBreadcrumbProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n onClickKeyPath?: (keyPath: KeyPath[]) => void;\n locale?: Locale;\n color?: LinkColor | `${LinkColor}`;\n showDictionaryKey?: boolean;\n};\n\nexport const KeyPathBreadcrumb: FC<KeyPathBreadcrumbProps> = ({\n keyPath,\n dictionaryKey,\n onClickKeyPath,\n locale,\n color,\n showDictionaryKey = true,\n}) => {\n const formattedKeyPath: BreadcrumbLink[] = [\n ...(showDictionaryKey\n ? [\n {\n text: camelCaseToSentence(dictionaryKey),\n onClick: onClickKeyPath ? () => onClickKeyPath([]) : undefined,\n },\n ]\n : []),\n ...keyPath.map((el, index) => ({\n onClick: onClickKeyPath\n ? () =>\n // With keyPath = [{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}, {type: NodeType.Object, key: '1'}]\n // If index is 0 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}])\n // If index is 1 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}])\n onClickKeyPath?.(keyPath.slice(0, index + 1))\n : undefined,\n\n text: el.key?.toString() ?? '',\n })),\n ];\n\n return (\n <Breadcrumb\n links={formattedKeyPath}\n locale={locale}\n elementType=\"location\"\n color={color}\n />\n );\n};\n"],"mappings":"2JAeA,MAAa,GAAiD,CAC5D,UACA,gBACA,iBACA,SACA,QACA,oBAAoB,MAyBlB,EAAC,EAAD,CACE,MAxBuC,CACzC,GAAI,EACA,CACE,CACE,KAAM,EAAoB,EAAc,CACxC,QAAS,MAAuB,EAAe,EAAE,CAAC,CAAG,IAAA,GACtD,CACF,CACD,EAAE,CACN,GAAG,EAAQ,KAAK,EAAI,KAAW,CAC7B,QAAS,MAKH,IAAiB,EAAQ,MAAM,EAAG,EAAQ,EAAE,CAAC,CAC/C,IAAA,GAEJ,KAAM,EAAG,KAAK,UAAU,EAAI,GAC7B,EAAE,CACJ,CAKW,SACR,YAAY,WACL,QACP,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport configuration from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport {\n type KeyPath,\n type LocalDictionaryId,\n NodeType,\n} from '@intlayer/types';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = configuration.internationalization;\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\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\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\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 unknown 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 key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\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 dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.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.value} ${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 dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\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"],"mappings":"szBA+BA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAQpD,GAA4C,CACvD,QAAS,EACT,UACA,gBACI,CACJ,GAAM,CAAE,WAAY,EAAc,qBAE5B,EAAU,EAAwB,EAAa,EAD/B,GAAiB,CACqC,CACtE,CAAE,oBAAqB,GAAyB,CAChD,CAAE,2BAA0B,kBAChC,GAA4B,CACxB,CAAE,gBAAe,aAAc,EAAY,kBAAkB,CAC7D,EAAW,EAAY,EAAQ,CAC/B,EAAiB,IACpB,GAAgB,SAAS,QAAU,GAAK,GACzC,EAAc,EAAS,GAAgB,SAAW,EAAE,CAAC,CACjD,EAAuB,EAAqB,EAAQ,CA+N1D,OA7NK,EAED,EAEA,EAAC,EAAA,CACC,MAAO,EAAU,MAAM,MACvB,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAQ,CAChD,UAAW,WAEV,EAAoB,EAAQ,EAAQ,OAAS,GAAG,IAAc,EACxD,CAIT,OAAO,GAAY,SACjB,IAAa,EAAS,UACjB,EAAA,EAAA,CAAA,SAAE,aAAA,CAAa,CAGpB,IAAa,EAAS,YAEtB,EAAC,MAAA,CAAI,UAAU,+CACZ,EAAQ,IAAK,GAOV,EAAC,EAAA,CAEC,QA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,EACf,EACJ,EACE,EACG,EAAa,OAAS,GAE1B,EAAI,GACP,EACE,EAAW,QACX,EACA,EACA,GACD,CACD,EAAyB,EAAW,EAEtC,KAAM,WAEL,EAAc,MACR,CAAA,EACL,CAIN,OAAO,EAAQ,UAAa,SAO5B,EAAC,EAAA,CACC,QAP4B,CAC9B,GAAG,EACH,CAAE,KAAM,EAAQ,SAAU,CAC3B,CAKG,QAAS,EACG,cACZ,CAMJ,EAAC,MAAA,CAAI,UAAU,iEAFI,OAAO,KAAK,EAAQ,CAGvB,IAAK,GAAQ,CACzB,IAAM,EAA0B,CAC9B,GAAG,EACH,CAAE,KAAM,EAAS,OAAQ,MAAK,CAC/B,CAsBD,OAnB6B,EADV,EAAwB,EAAa,EAAa,CACR,CAIzD,EAAC,EAAA,CACC,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IAEnC,SAAU,EAAc,EAAa,CACrC,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAa,CACrD,UAAW,WAEV,EAAoB,EAAI,EARpB,EASE,CAKX,EAAC,EAAA,CAEC,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IACnC,SAAU,EAAc,EAAa,CACrC,YAAe,EAAyB,EAAa,CACrD,OAAQ,EAAoB,EAAI,UAEhC,EAAC,MAAA,CAAI,UAAU,uCACb,EAAC,MAAA,CAAI,UAAU,wBACb,EAAC,EAAA,CACC,QAAS,EACT,QAAS,EACG,cACZ,EACE,EACF,EAdD,EAeK,EAEd,EACE,CAKR,EAAA,EAAA,CAAA,SAAA,CAAE,2BAEC,EAAS,KAET,KAAK,UAAU,EAAQ,CAAC,KAExB,KAAK,UAAU,EAAQ,GACvB,CArOgB,EAAA,EAAA,EAAA,CAAK"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport configuration from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport {\n type KeyPath,\n type LocalDictionaryId,\n NodeType,\n} from '@intlayer/types';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = configuration.internationalization;\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\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\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\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 unknown 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 key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\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 dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.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.value} ${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 dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\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"],"mappings":"szBA+BA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAQpD,GAA4C,CACvD,QAAS,EACT,UACA,gBACI,CACJ,GAAM,CAAE,WAAY,EAAc,qBAE5B,EAAU,EAAwB,EAAa,EAD/B,GAAiB,CACqC,CACtE,CAAE,oBAAqB,GAAyB,CAChD,CAAE,2BAA0B,kBAChC,GAA4B,CACxB,CAAE,gBAAe,aAAc,EAAY,kBAAkB,CAC7D,EAAW,EAAY,EAAQ,CAC/B,EAAiB,IACpB,GAAgB,SAAS,QAAU,GAAK,GACzC,EAAc,EAAS,GAAgB,SAAW,EAAE,CAAC,CACjD,EAAuB,EAAqB,EAAQ,CA+N1D,OA7NK,EAED,EAEA,EAAC,EAAD,CACE,MAAO,EAAU,MAAM,MACvB,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAQ,CAChD,UAAW,WAEV,EAAoB,EAAQ,EAAQ,OAAS,GAAG,IAAc,CACxD,CAAA,CAIT,OAAO,GAAY,SACjB,IAAa,EAAS,UACjB,EAAA,EAAA,CAAA,SAAE,aAAa,CAAA,CAGpB,IAAa,EAAS,YAEtB,EAAC,MAAD,CAAK,UAAU,+CACZ,EAAQ,IAAK,GAOV,EAAC,EAAD,CAEE,QAR4B,CAC9B,GAAG,EACH,CAAE,KAAM,EAAS,YAAa,IAAK,EAAgB,CACpD,CAMG,QAAS,EACG,aACZ,CAJK,EAIL,CAEJ,CACE,CAAA,CAIN,IAAa,EAAS,aAAe,IAAa,EAAS,UAE3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EtC,KAAM,WAEL,EAAc,KACR,CAAA,CACL,GAIN,OAAO,EAAQ,UAAa,SAO5B,EAAC,EAAD,CACE,QAP4B,CAC9B,GAAG,EACH,CAAE,KAAM,EAAQ,SAAU,CAC3B,CAKG,QAAS,EACG,aACZ,CAAA,CAMJ,EAAC,MAAD,CAAK,UAAU,iEAFI,OAAO,KAAK,EAAQ,CAGvB,IAAK,GAAQ,CACzB,IAAM,EAA0B,CAC9B,GAAG,EACH,CAAE,KAAM,EAAS,OAAQ,MAAK,CAC/B,CAsBD,OAnB6B,EADV,EAAwB,EAAa,EAAa,CACR,CAIzD,EAAC,EAAD,CACE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IAEnC,SAAU,EAAc,EAAa,CACrC,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAa,CACrD,UAAW,WAEV,EAAoB,EAAI,CAClB,CATF,EASE,CAKX,EAAC,EAAD,CAEE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IACnC,SAAU,EAAc,EAAa,CACrC,YAAe,EAAyB,EAAa,CACrD,OAAQ,EAAoB,EAAI,UAEhC,EAAC,MAAD,CAAK,UAAU,uCACb,EAAC,MAAD,CAAK,UAAU,wBACb,EAAC,EAAD,CACE,QAAS,EACT,QAAS,EACG,aACZ,CAAA,CACE,CAAA,CACF,CAAA,CACI,CAfL,EAeK,EAEd,CACE,CAAA,CAKR,EAAA,EAAA,CAAA,SAAA,CAAE,2BAEC,EAAS,KAET,KAAK,UAAU,EAAQ,CAAC,KAExB,KAAK,UAAU,EAAQ,CACvB,CAAA,CAAA,CArOgB,EAAA,EAAA,EAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeSelector.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getNodeType } from '@intlayer/core/dictionaryManipulator';\nimport { type ContentNode, NodeType } from '@intlayer/types';\nimport { type FC, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Select } from '../Select';\n\ntype NodeTypeSelectorProps = {\n section: ContentNode;\n onValueChange: (keyType: NodeType) => void;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n section,\n onValueChange: onValueChangeProp,\n}) => {\n const {\n multilingual,\n text,\n number,\n boolean,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n nest,\n gender,\n condition,\n markdown,\n insertion,\n reactNode,\n file,\n } = useIntlayer('node-type-selector');\n const nodeType = getNodeType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n onValueChangeProp(keyType);\n };\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger>\n <Select.Value placeholder={triggerPlaceHolder} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>{multilingual}</Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Number}>{number}</Select.Item>\n <Select.Item value={NodeType.Boolean}>{boolean}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n <Select.Item value={NodeType.Gender}>{gender}</Select.Item>\n <Select.Item value={NodeType.Insertion}>{insertion}</Select.Item>\n <Select.Item value={NodeType.Markdown}>{markdown}</Select.Item>\n <Select.Item value={NodeType.Nested}>{nest}</Select.Item>\n <Select.Item value={NodeType.Condition}>{condition}</Select.Item>\n <Select.Item value={NodeType.ReactNode} disabled>\n {reactNode}\n </Select.Item>\n <Select.Item value={NodeType.File}>{file}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"mappings":"ySAaA,MAAa,GAA+C,CAC1D,UACA,cAAe,KACX,CACJ,GAAM,CACJ,eACA,OACA,SACA,UACA,OACA,QACA,cACA,qBACA,OACA,SACA,YACA,WACA,YACA,YACA,QACE,EAAY,qBAAqB,CAE/B,CAAC,EAAS,GAAc,EADb,EAAY,EAAQ,CACqB,CAO1D,OACE,EAAC,
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getNodeType } from '@intlayer/core/dictionaryManipulator';\nimport { type ContentNode, NodeType } from '@intlayer/types';\nimport { type FC, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Select } from '../Select';\n\ntype NodeTypeSelectorProps = {\n section: ContentNode;\n onValueChange: (keyType: NodeType) => void;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n section,\n onValueChange: onValueChangeProp,\n}) => {\n const {\n multilingual,\n text,\n number,\n boolean,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n nest,\n gender,\n condition,\n markdown,\n insertion,\n reactNode,\n file,\n } = useIntlayer('node-type-selector');\n const nodeType = getNodeType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n onValueChangeProp(keyType);\n };\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger>\n <Select.Value placeholder={triggerPlaceHolder} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>{multilingual}</Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Number}>{number}</Select.Item>\n <Select.Item value={NodeType.Boolean}>{boolean}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n <Select.Item value={NodeType.Gender}>{gender}</Select.Item>\n <Select.Item value={NodeType.Insertion}>{insertion}</Select.Item>\n <Select.Item value={NodeType.Markdown}>{markdown}</Select.Item>\n <Select.Item value={NodeType.Nested}>{nest}</Select.Item>\n <Select.Item value={NodeType.Condition}>{condition}</Select.Item>\n <Select.Item value={NodeType.ReactNode} disabled>\n {reactNode}\n </Select.Item>\n <Select.Item value={NodeType.File}>{file}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"mappings":"ySAaA,MAAa,GAA+C,CAC1D,UACA,cAAe,KACX,CACJ,GAAM,CACJ,eACA,OACA,SACA,UACA,OACA,QACA,cACA,qBACA,OACA,SACA,YACA,WACA,YACA,YACA,QACE,EAAY,qBAAqB,CAE/B,CAAC,EAAS,GAAc,EADb,EAAY,EAAQ,CACqB,CAO1D,OACE,EAAC,EAAD,CAAQ,MAAO,EAAwB,cANlB,GAAsB,CAC3C,EAAW,EAAQ,CACnB,EAAkB,EAAQ,WAI1B,CACE,EAAC,EAAO,QAAR,CAAA,SACE,EAAC,EAAO,MAAR,CAAc,YAAa,EAAsB,CAAA,CAClC,CAAA,CACjB,EAAC,EAAO,QAAR,CAAA,SAAA,CACE,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,qBAAc,EAA2B,CAAA,CACtE,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,cAAO,EAAmB,CAAA,CACvD,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,gBAAS,EAAqB,CAAA,CAC3D,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,iBAAU,EAAsB,CAAA,CAC7D,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,gBAAS,EAAmB,CAAA,CACzD,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,eAAQ,EAAoB,CAAA,CACzD,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,qBAAc,EAA0B,CAAA,CACrE,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,gBAAS,EAAqB,CAAA,CAC3D,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,mBAAY,EAAwB,CAAA,CACjE,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,kBAAW,EAAuB,CAAA,CAC/D,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,gBAAS,EAAmB,CAAA,CACzD,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,mBAAY,EAAwB,CAAA,CACjE,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,UAAW,SAAA,YACrC,EACW,CAAA,CACd,EAAC,EAAO,KAAR,CAAa,MAAO,EAAS,cAAO,EAAmB,CAAA,CACxC,CAAA,CAAA,CACV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonVariant } from '@components/Button';\nimport { Form } from '@components/Form';\nimport { Modal, ModalSize } from '@components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '@hooks/index';\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport { cn } from '@utils/cn';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n onSave?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n onSave,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { mutate: deleteDictionary, isPending: isDeleting } =\n useDeleteDictionary();\n const { mutate: writeDictionary, isPending: isWriting } =\n useWriteDictionary();\n const { mutate: pushDictionaries, isPending: isPushing } =\n usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useIntlayer('save-dictionary-details');\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.localId!];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as unknown as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.localId!]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n writeDictionary(\n {\n dictionary: updatedDictionary,\n },\n {\n onSuccess: () => {\n setLocaleDictionary(editedContent?.[dictionary.localId!]);\n restoreEditedContent(dictionary.localId!);\n setIsFormatAlertModalOpen(false);\n onSave?.();\n },\n }\n );\n };\n\n const handlePushDictionary = () => {\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n pushDictionaries(\n { dictionaries: [updatedDictionary] },\n {\n onSuccess: (res) => {\n if (res) {\n setLocaleDictionary(updatedDictionary);\n restoreEditedContent(dictionary.localId!);\n onSave?.();\n }\n },\n }\n );\n };\n\n const handleDeleteDictionary = () => {\n if (!dictionary.id) return;\n\n deleteDictionary(\n {\n dictionaryId: dictionary.id,\n },\n {\n onSuccess: (res) => {\n if (res) {\n onDelete?.();\n }\n },\n }\n );\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size={ModalSize.MD}\n onClose={() => setIsFormatAlertModalOpen(false)}\n padding=\"md\"\n >\n <form className=\"size-full\">\n <p className=\"py-4 text-neutral text-sm\">{confirmation.message}</p>\n\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n variant={ButtonVariant.OUTLINE}\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color={ButtonColor.ERROR}\n variant={ButtonVariant.OUTLINE}\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.localId!)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color={ButtonColor.TEXT}\n variant={\n isAuthenticated ? ButtonVariant.OUTLINE : ButtonVariant.DEFAULT\n }\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"mappings":"suBAwCA,MAAa,GAAwC,CACnD,aACA,OACA,YACA,WACA,SACA,GAAG,KACC,CACJ,GAAM,CAAC,EAAwB,GAA6B,EAAS,GAAM,CACrE,CAAE,uBAAwB,GAA8B,CACxD,CAAE,OAAQ,EAAkB,UAAW,GAC3C,GAAqB,CACjB,CAAE,OAAQ,EAAiB,UAAW,GAC1C,GAAoB,CAChB,CAAE,OAAQ,EAAkB,UAAW,GAC3C,GAAqB,CACjB,EAAY,GAAa,EAEzB,CAAE,gBAAe,wBAAyB,GAAkB,CAC5D,CACJ,eACA,cACA,aACA,gBACA,iBACA,gBACE,EAAY,0BAA0B,CACpC,CAAE,mBAAoB,GAAS,CAE/B,EAAmB,IAAgB,EAAW,SAE9C,EACJ,GACA,KAAK,UAAU,EAAiB,GAAK,KAAK,UAAU,EAAW,CAE3D,EACI,GAA6C,KAAO,OAExD,EAAmC,SAAY,CAC9C,IAAgB,EAAW,UAOhC,EACE,CACE,WAPsB,CACxB,GAAG,EACH,GAAG,IAAgB,EAAW,SAC/B,CAKE,CACD,CACE,cAAiB,CACf,EAAoB,IAAgB,EAAW,SAAU,CACzD,EAAqB,EAAW,QAAS,CACzC,EAA0B,GAAM,CAChC,KAAU,EAEb,CACF,EAGG,MAA6B,CACjC,IAAM,EAAoB,CACxB,GAAG,EACH,GAAG,IAAgB,EAAW,SAC/B,CAED,EACE,CAAE,aAAc,CAAC,EAAkB,CAAE,CACrC,CACE,UAAY,GAAQ,CACd,IACF,EA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SAAS,QAAQ,EACrB,EAAC,EAAK,OAAA,CACJ,MAAO,EAAe,MAAM,MAC5B,SAAU,CAAC,GAAY,EACvB,KAAM,EACN,MAAO,EAAY,KACnB,QACE,EAAkB,EAAc,QAAU,EAAc,QAE1D,UAAU,gBACV,UAAW,EACX,YAAe,EAA0B,GAAK,UAE7C,EAAe,MACJ,CAEf,EAAK,SAAS,SAAS,EAAI,GAAmB,CAAC,GAC9C,EAAC,EAAK,OAAA,CACJ,MAAO,EAAc,MAAM,MAC3B,SAAU,EACV,KAAM,EACN,MAAO,EAAY,KACnB,UAAU,gBACV,UAAW,EACX,QAAS,WAER,EAAc,MACH,CAEf,EAAK,SAAS,SAAS,EACtB,GACA,GACA,GACE,EAAC,EAAK,OAAA,CACJ,MAAO,EAAW,MAAM,MACxB,SAAU,CAAC,GAAY,EACvB,KAAM,EACN,MAAM,OACN,UAAU,gBACV,UAAW,EACX,QAAS,WAER,EAAW,MACA,GAEb,CAAA,CAAA,CACN"}
|
|
1
|
+
{"version":3,"file":"SaveForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonVariant } from '@components/Button';\nimport { Form } from '@components/Form';\nimport { Modal, ModalSize } from '@components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '@hooks/index';\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport { cn } from '@utils/cn';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n onSave?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n onSave,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { mutate: deleteDictionary, isPending: isDeleting } =\n useDeleteDictionary();\n const { mutate: writeDictionary, isPending: isWriting } =\n useWriteDictionary();\n const { mutate: pushDictionaries, isPending: isPushing } =\n usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useIntlayer('save-dictionary-details');\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.localId!];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as unknown as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.localId!]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n writeDictionary(\n {\n dictionary: updatedDictionary,\n },\n {\n onSuccess: () => {\n setLocaleDictionary(editedContent?.[dictionary.localId!]);\n restoreEditedContent(dictionary.localId!);\n setIsFormatAlertModalOpen(false);\n onSave?.();\n },\n }\n );\n };\n\n const handlePushDictionary = () => {\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n pushDictionaries(\n { dictionaries: [updatedDictionary] },\n {\n onSuccess: (res) => {\n if (res) {\n setLocaleDictionary(updatedDictionary);\n restoreEditedContent(dictionary.localId!);\n onSave?.();\n }\n },\n }\n );\n };\n\n const handleDeleteDictionary = () => {\n if (!dictionary.id) return;\n\n deleteDictionary(\n {\n dictionaryId: dictionary.id,\n },\n {\n onSuccess: (res) => {\n if (res) {\n onDelete?.();\n }\n },\n }\n );\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size={ModalSize.MD}\n onClose={() => setIsFormatAlertModalOpen(false)}\n padding=\"md\"\n >\n <form className=\"size-full\">\n <p className=\"py-4 text-neutral text-sm\">{confirmation.message}</p>\n\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n variant={ButtonVariant.OUTLINE}\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color={ButtonColor.ERROR}\n variant={ButtonVariant.OUTLINE}\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.localId!)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color={ButtonColor.TEXT}\n variant={\n isAuthenticated ? ButtonVariant.OUTLINE : ButtonVariant.DEFAULT\n }\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"mappings":"suBAwCA,MAAa,GAAwC,CACnD,aACA,OACA,YACA,WACA,SACA,GAAG,KACC,CACJ,GAAM,CAAC,EAAwB,GAA6B,EAAS,GAAM,CACrE,CAAE,uBAAwB,GAA8B,CACxD,CAAE,OAAQ,EAAkB,UAAW,GAC3C,GAAqB,CACjB,CAAE,OAAQ,EAAiB,UAAW,GAC1C,GAAoB,CAChB,CAAE,OAAQ,EAAkB,UAAW,GAC3C,GAAqB,CACjB,EAAY,GAAa,EAEzB,CAAE,gBAAe,wBAAyB,GAAkB,CAC5D,CACJ,eACA,cACA,aACA,gBACA,iBACA,gBACE,EAAY,0BAA0B,CACpC,CAAE,mBAAoB,GAAS,CAE/B,EAAmB,IAAgB,EAAW,SAE9C,EACJ,GACA,KAAK,UAAU,EAAiB,GAAK,KAAK,UAAU,EAAW,CAE3D,EACI,GAA6C,KAAO,OAExD,EAAmC,SAAY,CAC9C,IAAgB,EAAW,UAOhC,EACE,CACE,WAPsB,CACxB,GAAG,EACH,GAAG,IAAgB,EAAW,SAC/B,CA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Aa,MAAM,MAC1B,KAAM,EACN,MAAO,EAAY,MACnB,QAAS,EAAc,QACvB,UAAU,gBACV,UAAW,EACX,QAAS,WAER,EAAa,KACF,CAAA,CAEjB,GACC,EAAC,EAAK,OAAN,CACE,MAAO,EAAY,MAAM,MACzB,SAAU,CAAC,EACX,KAAM,EACN,QAAS,EAAc,QACvB,MAAO,EAAY,KACnB,UAAU,gBACV,YAAe,EAAqB,EAAW,QAAS,UAEvD,EAAY,KACD,CAAA,CAEf,EAAK,SAAS,QAAQ,EACrB,EAAC,EAAK,OAAN,CACE,MAAO,EAAe,MAAM,MAC5B,SAAU,CAAC,GAAY,EACvB,KAAM,EACN,MAAO,EAAY,KACnB,QACE,EAAkB,EAAc,QAAU,EAAc,QAE1D,UAAU,gBACV,UAAW,EACX,YAAe,EAA0B,GAAK,UAE7C,EAAe,KACJ,CAAA,CAEf,EAAK,SAAS,SAAS,EAAI,GAAmB,CAAC,GAC9C,EAAC,EAAK,OAAN,CACE,MAAO,EAAc,MAAM,MAC3B,SAAU,EACV,KAAM,EACN,MAAO,EAAY,KACnB,UAAU,gBACV,UAAW,EACX,QAAS,WAER,EAAc,KACH,CAAA,CAEf,EAAK,SAAS,SAAS,EACtB,GACA,GACA,GACE,EAAC,EAAK,OAAN,CACE,MAAO,EAAW,MAAM,MACxB,SAAU,CAAC,GAAY,EACvB,KAAM,EACN,MAAM,OACN,UAAU,gBACV,UAAW,EACX,QAAS,WAER,EAAW,KACA,CAAA,CAEb,GACN,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content, localId } = dictionary;\n\n const { editedContent } = useEditedContent();\n const initialSection =\n typeof editedContent?.[localId!]?.content === 'undefined'\n ? content\n : editedContent?.[localId!]?.content;\n\n return (\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryLocalId={localId!}\n />\n );\n};\n"],"mappings":"4KAWA,MAAa,GAAwC,CAAE,gBAAiB,CACtE,GAAM,CAAE,UAAS,WAAY,EAEvB,CAAE,iBAAkB,GAAkB,CAM5C,OACE,EAAC,
|
|
1
|
+
{"version":3,"file":"StructureEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content, localId } = dictionary;\n\n const { editedContent } = useEditedContent();\n const initialSection =\n typeof editedContent?.[localId!]?.content === 'undefined'\n ? content\n : editedContent?.[localId!]?.content;\n\n return (\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryLocalId={localId!}\n />\n );\n};\n"],"mappings":"4KAWA,MAAa,GAAwC,CAAE,gBAAiB,CACtE,GAAM,CAAE,UAAS,WAAY,EAEvB,CAAE,iBAAkB,GAAkB,CAM5C,OACE,EAAC,EAAD,CACE,QANK,IAAgB,IAAW,UAAY,OAC1C,EACA,IAAgB,IAAW,QAK7B,QAAS,EAAE,CACX,kBAAmB,EACnB,CAAA"}
|