@intlayer/design-system 9.0.0-canary.0 → 9.0.0-canary.2
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/api/hooks/ai.mjs +20 -1
- package/dist/esm/api/hooks/ai.mjs.map +1 -1
- package/dist/esm/api/hooks/asset.mjs +78 -0
- package/dist/esm/api/hooks/asset.mjs.map +1 -0
- package/dist/esm/api/index.mjs +6 -5
- package/dist/esm/api/useIntlayerAPI.mjs +6 -1
- package/dist/esm/api/useIntlayerAPI.mjs.map +1 -1
- package/dist/esm/components/Command/index.mjs +8 -8
- package/dist/esm/components/Command/index.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs +132 -35
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +33 -11
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +146 -35
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs +308 -0
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs +12 -2
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +460 -20
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +506 -0
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +10 -6
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +9 -9
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +2 -2
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/contentEditor.content.mjs +79 -0
- package/dist/esm/components/DictionaryFieldEditor/contentEditor.content.mjs.map +1 -0
- package/dist/esm/components/Form/Form.mjs +3 -43
- package/dist/esm/components/Form/Form.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElement.mjs +2 -3
- package/dist/esm/components/Form/elements/FormElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/MultiselectElement.mjs +2 -3
- package/dist/esm/components/Form/elements/MultiselectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs +3 -4
- package/dist/esm/components/Form/elements/OTPElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SelectElement.mjs +2 -3
- package/dist/esm/components/Form/elements/SelectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs +2 -3
- package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs.map +1 -1
- package/dist/esm/components/Form/index.mjs +21 -2
- package/dist/esm/components/Form/layout/FormItemLayout.mjs +8 -5
- package/dist/esm/components/Form/layout/FormItemLayout.mjs.map +1 -1
- package/dist/esm/components/LanguageBackground/LanguageBackground.mjs +3 -8
- package/dist/esm/components/LanguageBackground/LanguageBackground.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/esm/components/MarkdownEditor/MarkdownEditor.mjs +113 -0
- package/dist/esm/components/MarkdownEditor/MarkdownEditor.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/extensions.mjs +103 -0
- package/dist/esm/components/MarkdownEditor/extensions.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/generative/AICompletionCommands.mjs +51 -0
- package/dist/esm/components/MarkdownEditor/generative/AICompletionCommands.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/generative/AISelector.mjs +100 -0
- package/dist/esm/components/MarkdownEditor/generative/AISelector.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/generative/AISelectorCommands.mjs +81 -0
- package/dist/esm/components/MarkdownEditor/generative/AISelectorCommands.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/generative/GenerativeMenuSwitch.mjs +47 -0
- package/dist/esm/components/MarkdownEditor/generative/GenerativeMenuSwitch.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/generative/useAICompletion.mjs +83 -0
- package/dist/esm/components/MarkdownEditor/generative/useAICompletion.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/imageUpload.mjs +47 -0
- package/dist/esm/components/MarkdownEditor/imageUpload.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/index.mjs +4 -0
- package/dist/esm/components/MarkdownEditor/markdownEditor.content.mjs +1140 -0
- package/dist/esm/components/MarkdownEditor/markdownEditor.content.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-bubble-item.mjs +20 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-bubble-item.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-bubble.mjs +39 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-bubble.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-command-item.mjs +25 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-command-item.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-command.mjs +61 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor-command.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor.mjs +27 -0
- package/dist/esm/components/MarkdownEditor/novel/components/editor.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/components/index.mjs +8 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/ai-highlight.mjs +74 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/ai-highlight.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/custom-keymap.mjs +37 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/custom-keymap.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/image-resizer.mjs +49 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/image-resizer.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/index.mjs +51 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/index.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/slash-command.mjs +79 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/slash-command.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/updated-image.mjs +17 -0
- package/dist/esm/components/MarkdownEditor/novel/extensions/updated-image.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/index.mjs +17 -0
- package/dist/esm/components/MarkdownEditor/novel/plugins/index.mjs +3 -0
- package/dist/esm/components/MarkdownEditor/novel/plugins/upload-images.mjs +92 -0
- package/dist/esm/components/MarkdownEditor/novel/plugins/upload-images.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/utils/atoms.mjs +39 -0
- package/dist/esm/components/MarkdownEditor/novel/utils/atoms.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/novel/utils/index.mjs +38 -0
- package/dist/esm/components/MarkdownEditor/novel/utils/index.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/selectors/ColorSelector.mjs +176 -0
- package/dist/esm/components/MarkdownEditor/selectors/ColorSelector.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/selectors/LinkSelector.mjs +95 -0
- package/dist/esm/components/MarkdownEditor/selectors/LinkSelector.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/selectors/NodeSelector.mjs +139 -0
- package/dist/esm/components/MarkdownEditor/selectors/NodeSelector.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/selectors/TextButtons.mjs +81 -0
- package/dist/esm/components/MarkdownEditor/selectors/TextButtons.mjs.map +1 -0
- package/dist/esm/components/MarkdownEditor/slashCommand.mjs +161 -0
- package/dist/esm/components/MarkdownEditor/slashCommand.mjs.map +1 -0
- package/dist/esm/components/Modal/Modal.mjs +2 -2
- package/dist/esm/components/Navbar/MobileNavbar.mjs +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs +1 -1
- package/dist/esm/components/Pattern/GridDistortionPattern.mjs +275 -0
- package/dist/esm/components/Pattern/GridDistortionPattern.mjs.map +1 -0
- package/dist/esm/components/Pattern/index.mjs +2 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs +3 -3
- package/dist/esm/components/Tab/Tab.mjs +1 -1
- package/dist/esm/components/Table/Table.mjs +1 -1
- package/dist/esm/components/Table/Table.mjs.map +1 -1
- package/dist/esm/components/Tag/index.mjs +0 -9
- package/dist/esm/components/Tag/index.mjs.map +1 -1
- package/dist/esm/components/Toaster/Toast.mjs +1 -1
- package/dist/esm/components/Toaster/Toast.mjs.map +1 -1
- package/dist/esm/components/index.mjs +27 -6
- package/dist/esm/hooks/index.mjs +8 -8
- package/dist/esm/hooks/useIsMounted.mjs +4 -2
- package/dist/esm/hooks/useIsMounted.mjs.map +1 -1
- package/dist/esm/routes.mjs +2 -1
- package/dist/esm/routes.mjs.map +1 -1
- package/dist/types/api/hooks/ai.d.ts +5 -1
- package/dist/types/api/hooks/ai.d.ts.map +1 -1
- package/dist/types/api/hooks/asset.d.ts +27 -0
- package/dist/types/api/hooks/asset.d.ts.map +1 -0
- package/dist/types/api/hooks/audit.d.ts +1 -1
- package/dist/types/api/index.d.ts +4 -3
- package/dist/types/api/useIntlayerAPI.d.ts +15 -3
- package/dist/types/api/useIntlayerAPI.d.ts.map +1 -1
- package/dist/types/components/Badge/index.d.ts +1 -1
- package/dist/types/components/Breadcrumb/index.d.ts +1 -1
- package/dist/types/components/Button/Button.d.ts +3 -3
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +2 -2
- package/dist/types/components/Command/index.d.ts.map +1 -1
- package/dist/types/components/Container/index.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +308 -0
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts +12 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +2 -0
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +506 -0
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +2 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/contentEditor.content.d.ts +80 -0
- package/dist/types/components/DictionaryFieldEditor/contentEditor.content.d.ts.map +1 -0
- package/dist/types/components/Form/Form.d.ts +27 -47
- package/dist/types/components/Form/Form.d.ts.map +1 -1
- package/dist/types/components/Form/elements/FormElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/MultiselectElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/OTPElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/SelectElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/SwitchSelectorElement.d.ts.map +1 -1
- package/dist/types/components/Form/index.d.ts +22 -3
- package/dist/types/components/Form/layout/FormItemLayout.d.ts.map +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/Input/Radio.d.ts +3 -3
- package/dist/types/components/LanguageBackground/LanguageBackground.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +1 -1
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +31 -0
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/extensions.d.ts +11 -0
- package/dist/types/components/MarkdownEditor/extensions.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/generative/AICompletionCommands.d.ts +18 -0
- package/dist/types/components/MarkdownEditor/generative/AICompletionCommands.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/generative/AISelector.d.ts +22 -0
- package/dist/types/components/MarkdownEditor/generative/AISelector.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/generative/AISelectorCommands.d.ts +17 -0
- package/dist/types/components/MarkdownEditor/generative/AISelectorCommands.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/generative/GenerativeMenuSwitch.d.ts +26 -0
- package/dist/types/components/MarkdownEditor/generative/GenerativeMenuSwitch.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/generative/useAICompletion.d.ts +30 -0
- package/dist/types/components/MarkdownEditor/generative/useAICompletion.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/imageUpload.d.ts +29 -0
- package/dist/types/components/MarkdownEditor/imageUpload.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/index.d.ts +3 -0
- package/dist/types/components/MarkdownEditor/markdownEditor.content.d.ts +1135 -0
- package/dist/types/components/MarkdownEditor/markdownEditor.content.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-bubble-item.d.ts +14 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-bubble-item.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-bubble.d.ts +18 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-bubble.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-command-item.d.ts +28 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-command-item.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-command.d.ts +34 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor-command.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor.d.ts +23 -0
- package/dist/types/components/MarkdownEditor/novel/components/editor.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/components/index.d.ts +8 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/ai-highlight.d.ts +36 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/ai-highlight.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/custom-keymap.d.ts +17 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/custom-keymap.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/image-resizer.d.ts +7 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/image-resizer.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/index.d.ts +30 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/index.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/slash-command.d.ts +38 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/slash-command.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/updated-image.d.ts +8 -0
- package/dist/types/components/MarkdownEditor/novel/extensions/updated-image.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/index.d.ts +16 -0
- package/dist/types/components/MarkdownEditor/novel/plugins/index.d.ts +2 -0
- package/dist/types/components/MarkdownEditor/novel/plugins/upload-images.d.ts +22 -0
- package/dist/types/components/MarkdownEditor/novel/plugins/upload-images.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/utils/atoms.d.ts +21 -0
- package/dist/types/components/MarkdownEditor/novel/utils/atoms.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/novel/utils/index.d.ts +10 -0
- package/dist/types/components/MarkdownEditor/novel/utils/index.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/selectors/ColorSelector.d.ts +17 -0
- package/dist/types/components/MarkdownEditor/selectors/ColorSelector.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/selectors/LinkSelector.d.ts +15 -0
- package/dist/types/components/MarkdownEditor/selectors/LinkSelector.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/selectors/NodeSelector.d.ts +22 -0
- package/dist/types/components/MarkdownEditor/selectors/NodeSelector.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/selectors/TextButtons.d.ts +11 -0
- package/dist/types/components/MarkdownEditor/selectors/TextButtons.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/slashCommand.d.ts +29 -0
- package/dist/types/components/MarkdownEditor/slashCommand.d.ts.map +1 -0
- package/dist/types/components/Pattern/GridDistortionPattern.d.ts +15 -0
- package/dist/types/components/Pattern/GridDistortionPattern.d.ts.map +1 -0
- package/dist/types/components/Pattern/index.d.ts +2 -1
- package/dist/types/components/SwitchSelector/SwitchSelector.d.ts +1 -1
- package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts +1 -1
- package/dist/types/components/Tag/index.d.ts +2 -2
- package/dist/types/components/Tag/index.d.ts.map +1 -1
- package/dist/types/components/Toaster/Toast.d.ts +1 -1
- package/dist/types/components/index.d.ts +24 -3
- package/dist/types/routes.d.ts +2 -1
- package/dist/types/routes.d.ts.map +1 -1
- package/package.json +63 -32
- package/src/components/MarkdownEditor/markdown-editor.css +297 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useAuditContentDeclarationField } from "../../../api/hooks/ai.mjs";
|
|
4
3
|
import { Loader } from "../../Loader/index.mjs";
|
|
5
4
|
import { Button } from "../../Button/Button.mjs";
|
|
6
5
|
import { Accordion } from "../../Accordion/Accordion.mjs";
|
|
@@ -8,6 +7,7 @@ import { Container } from "../../Container/index.mjs";
|
|
|
8
7
|
import { ContentEditorInput as ContentEditorInput$1 } from "../../ContentEditor/ContentEditorInput.mjs";
|
|
9
8
|
import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
|
|
10
9
|
import { SwitchSelector } from "../../SwitchSelector/SwitchSelector.mjs";
|
|
10
|
+
import { useAuditContentDeclarationField } from "../../../api/hooks/ai.mjs";
|
|
11
11
|
import { useLocaleSwitcherContent } from "../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
|
|
12
12
|
import { renameKey } from "./object.mjs";
|
|
13
13
|
import { Label } from "../../Label/index.mjs";
|
|
@@ -16,15 +16,16 @@ import { SafeHtmlRenderer } from "./SafeHtmlRenderer.mjs";
|
|
|
16
16
|
import { Fragment, Suspense, lazy, memo, useState } from "react";
|
|
17
17
|
import { Plus, Trash, WandSparkles } from "lucide-react";
|
|
18
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
-
import { useConfiguration, useEditedContent } from "@intlayer/editor-react";
|
|
20
19
|
import { useIntlayer, useLocale } from "react-intlayer";
|
|
21
20
|
import { getLocaleName } from "@intlayer/core/localization";
|
|
21
|
+
import { useConfiguration, useEditedContent } from "@intlayer/editor-react";
|
|
22
22
|
import { getEmptyNode, getNodeType } from "@intlayer/core/dictionaryManipulator";
|
|
23
23
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
24
24
|
import { camelCaseToSentence } from "@intlayer/config/client";
|
|
25
25
|
|
|
26
26
|
//#region src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx
|
|
27
27
|
const LazyMarkdownRenderer = lazy(() => import("../../MarkDownRender/index.mjs").then((m) => ({ default: m.MarkdownRenderer })));
|
|
28
|
+
const LazyMarkdownEditor = lazy(() => import("../../MarkdownEditor/index.mjs").then((m) => ({ default: m.MarkdownEditor })));
|
|
28
29
|
const CollapsibleEditor = memo(function CollapsibleEditor({ label, ...editorProps }) {
|
|
29
30
|
const [hasOpened, setHasOpened] = useState(false);
|
|
30
31
|
return /* @__PURE__ */ jsx(Accordion, {
|
|
@@ -498,13 +499,21 @@ const HtmlTextEditor = ({ section, keyPath, dictionary }) => {
|
|
|
498
499
|
};
|
|
499
500
|
const MarkdownTextEditor = ({ section, keyPath, dictionary, isDarkMode }) => {
|
|
500
501
|
const [mode, setMode] = useState(0);
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
502
|
+
const { addEditedContent } = useEditedContent();
|
|
503
|
+
const toggleContent = [
|
|
504
|
+
{
|
|
505
|
+
content: "Edit",
|
|
506
|
+
value: 0
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
content: "Raw",
|
|
510
|
+
value: 1
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
content: "Preview",
|
|
514
|
+
value: 2
|
|
515
|
+
}
|
|
516
|
+
];
|
|
508
517
|
const childKeyPath = [...keyPath, { type: NodeTypes.MARKDOWN }];
|
|
509
518
|
const content = section[NodeTypes.MARKDOWN] ?? "";
|
|
510
519
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -516,11 +525,24 @@ const MarkdownTextEditor = ({ section, keyPath, dictionary, isDarkMode }) => {
|
|
|
516
525
|
color: "text",
|
|
517
526
|
size: "sm",
|
|
518
527
|
className: "ml-auto"
|
|
519
|
-
}), /* @__PURE__ */ jsx(
|
|
528
|
+
}), mode === 0 && typeof content === "string" ? /* @__PURE__ */ jsx(Container, {
|
|
529
|
+
border: true,
|
|
530
|
+
background: "none",
|
|
531
|
+
roundedSize: "2xl",
|
|
532
|
+
padding: "lg",
|
|
533
|
+
className: "w-full",
|
|
534
|
+
children: /* @__PURE__ */ jsx(Suspense, {
|
|
535
|
+
fallback: /* @__PURE__ */ jsx(Loader, {}),
|
|
536
|
+
children: /* @__PURE__ */ jsx(LazyMarkdownEditor, {
|
|
537
|
+
defaultValue: content,
|
|
538
|
+
onChange: (markdown) => addEditedContent(dictionary.localId, markdown, childKeyPath)
|
|
539
|
+
}, JSON.stringify(childKeyPath))
|
|
540
|
+
})
|
|
541
|
+
}) : /* @__PURE__ */ jsx(TextEditorContainer, {
|
|
520
542
|
section: content,
|
|
521
543
|
keyPath: childKeyPath,
|
|
522
544
|
dictionary,
|
|
523
|
-
renderSection: mode ===
|
|
545
|
+
renderSection: mode === 2 ? (content) => /* @__PURE__ */ jsx(Suspense, {
|
|
524
546
|
fallback: /* @__PURE__ */ jsx(Loader, {}),
|
|
525
547
|
children: /* @__PURE__ */ jsx(LazyMarkdownRenderer, {
|
|
526
548
|
isDarkMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useAuditContentDeclarationField } from '@api/index';\nimport { Accordion } from '@components/Accordion';\nimport { Button } 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 { renameKey } from '@components/DictionaryFieldEditor/ContentEditorView/object';\nimport { Label } from '@components/Label';\nimport { Loader } from '@components/Loader';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n type SwitchSelectorProps,\n} from '@components/SwitchSelector';\nimport { camelCaseToSentence } from '@intlayer/config/client';\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 PluralContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport {\n type FC,\n Fragment,\n lazy,\n memo,\n type ReactNode,\n Suspense,\n useState,\n} from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { SafeHtmlRenderer } from './SafeHtmlRenderer';\n\nconst LazyMarkdownRenderer = lazy(() =>\n import('@components/MarkDownRender').then((m) => ({\n default: m.MarkdownRenderer,\n }))\n);\n\n// Renders children only after the accordion is first opened (mount-once pattern).\n// Prevents deeply nested sub-trees from mounting on initial render.\ntype CollapsibleEditorProps = TextEditorProps & { label: string };\nconst CollapsibleEditor = memo<CollapsibleEditorProps>(\n function CollapsibleEditor({ label, ...editorProps }) {\n const [hasOpened, setHasOpened] = useState(false);\n return (\n <Accordion\n header={label}\n label={label}\n onToggle={(isOpen) => {\n if (isOpen && !hasOpened) setHasOpened(true);\n }}\n >\n {hasOpened ? <TextEditor {...editorProps} /> : null}\n </Accordion>\n );\n }\n);\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=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\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=\"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=\"text\"\n size=\"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 } = useLocaleSwitcherContent();\n\n const content: any = (section as TranslationContent<string>)[\n NodeTypes.TRANSLATION\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {selectedLocales.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: NodeTypes.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>)[\n NodeTypes.ENUMERATION\n ];\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>)[NodeTypes.ENUMERATION]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeTypes.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 )[NodeTypes.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 [NodeTypes.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=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeTypes.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>)[NodeTypes.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: NodeTypes.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>)[NodeTypes.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: NodeTypes.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 PLURAL_CATEGORIES = ['zero', 'one', 'two', 'few', 'many', 'other'];\n\nconst PluralTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as PluralContent<string>)[NodeTypes.PLURAL];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {PLURAL_CATEGORIES.map((pluralKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-plural-${pluralKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{pluralKey}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[pluralKey as keyof typeof content] ??\n getEmptyNode(content.other)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeTypes.PLURAL,\n key: pluralKey,\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: NodeTypes.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: NodeTypes.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=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeTypes.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 const typedSection = section as unknown as Record<string, ContentNode>;\n const firstKey = Object.keys(typedSection)[0] as keyof typeof section;\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(typedSection).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key },\n ];\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n // Collapse any object/array (typed or plain) — only true primitives render inline.\n // getIsEditableSection can't be used here: it inspects getNodeChildren(), which for\n // translation nodes returns the first locale value (a string), causing translation\n // subtrees to be mistakenly treated as leaves and mounted all at once.\n const isLeaf = subSection === null || typeof subSection !== 'object';\n\n if (isLeaf) {\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 return (\n <tr\n key={uniqueKey}\n className=\"block w-full border-neutral/10 border-t py-1\"\n >\n <td className=\"flex w-full\">\n <CollapsibleEditor\n label={camelCaseToSentence(key)}\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\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: NodeTypes.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeTypes.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=\"text\"\n size=\"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 ? (rawContent) => <SafeHtmlRenderer rawContent={rawContent} />\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: NodeTypes.MARKDOWN }];\n\n const content = ((section as MarkdownContent<ContentNode>)[\n NodeTypes.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=\"text\"\n size=\"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 <Suspense fallback={<Loader />}>\n <LazyMarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </LazyMarkdownRenderer>\n </Suspense>\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: NodeTypes.INSERTION }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeTypes.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: NodeTypes.FILE }];\n\n const fileUrl = (section as FileContent)[NodeTypes.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)[NodeTypes.NESTED];\n const childrenKeyPath = [...keyPath, { type: NodeTypes.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=\"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=\"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 = memo<TextEditorProps>(function TextEditor({\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 === NodeTypes.REACT_NODE) {\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 === NodeTypes.NESTED) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.TRANSLATION) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.ENUMERATION) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.CONDITION) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.GENDER) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.PLURAL) {\n return (\n <PluralTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.INSERTION) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.MARKDOWN) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeTypes.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.FILE) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.ARRAY) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.OBJECT) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.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 === NodeTypes.TEXT) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant=\"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 === NodeTypes.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 = memo<TextEditorProps>(\n function TextEditorContainer(props) {\n return (\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=\"2xl\"\n >\n <TextEditor {...props} />\n </Container>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,uBAAuB,WAC3B,OAAO,kCAA8B,MAAM,OAAO,EAChD,SAAS,EAAE,kBACZ,EAAE,CACJ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ACzB,QACE,oBAAC,qBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,SACzB,QACE,oBAAC,oBAAD;EACc;EACH;EACA;EACG;EACZ;AAIN,KAAI,aAAa,UAAU,KACzB,QACE,oBAAC,gBAAD;EACc;EACH;EACA;EACT;AAIN,KAAI,aAAa,UAAU,KACzB,QACE,oBAAC,gBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,MACzB,QACE,oBAAC,iBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,OACzB,QACE,oBAAC,kBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,OACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,oBAAD;GACc;GACH;GACT,MAAK;GACL,cAAW;aAEV;GACkB;EACjB;AAIV,KAAI,aAAa,UAAU,KACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACZ,OAAO,kBAAkB,aACxB,cAAc,QAAkB,GAEhC,oBAAC,uBAAD;GACE,SAAQ;GACR,cAAW;GACF;GACG;aAEX;GACqB;EAEtB;AAIV,KAAI,aAAa,UAAU,QACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,qBAAD;GACc;GACH;GACT,OAAO;GACP;EACE;AAIV,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf;GAA4B;GAEzB,KAAK,UAAU,SAAS,MAAM,EAAE;GAChC,KAAK,UAAU,SAAS,MAAM,EAAE;GAAC;GACtB;GACR;;EAER;AAEF,MAAa,sBAAsB,KACjC,SAAS,oBAAoB,OAAO;AAClC,QACE,oBAAC,WAAD;EACE;EACA,YAAW;EACX,WAAU;EACV,aAAY;YAEZ,oBAAC,YAAD,EAAY,GAAI,OAAS;EACf;EAGjB"}
|
|
1
|
+
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useAuditContentDeclarationField } from '@api/index';\nimport { Accordion } from '@components/Accordion';\nimport { Button } 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 { renameKey } from '@components/DictionaryFieldEditor/ContentEditorView/object';\nimport { Label } from '@components/Label';\nimport { Loader } from '@components/Loader';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n type SwitchSelectorProps,\n} from '@components/SwitchSelector';\nimport { camelCaseToSentence } from '@intlayer/config/client';\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 PluralContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport {\n type FC,\n Fragment,\n lazy,\n memo,\n type ReactNode,\n Suspense,\n useState,\n} from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { SafeHtmlRenderer } from './SafeHtmlRenderer';\n\nconst LazyMarkdownRenderer = lazy(() =>\n import('@components/MarkDownRender').then((m) => ({\n default: m.MarkdownRenderer,\n }))\n);\n\n// Lazy-loaded so the Tiptap/Novel editor bundle is only fetched when a markdown\n// field is actually edited.\nconst LazyMarkdownEditor = lazy(() =>\n import('@components/MarkdownEditor').then((m) => ({\n default: m.MarkdownEditor,\n }))\n);\n\n// Renders children only after the accordion is first opened (mount-once pattern).\n// Prevents deeply nested sub-trees from mounting on initial render.\ntype CollapsibleEditorProps = TextEditorProps & { label: string };\nconst CollapsibleEditor = memo<CollapsibleEditorProps>(\n function CollapsibleEditor({ label, ...editorProps }) {\n const [hasOpened, setHasOpened] = useState(false);\n return (\n <Accordion\n header={label}\n label={label}\n onToggle={(isOpen) => {\n if (isOpen && !hasOpened) setHasOpened(true);\n }}\n >\n {hasOpened ? <TextEditor {...editorProps} /> : null}\n </Accordion>\n );\n }\n);\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=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\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=\"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=\"text\"\n size=\"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 } = useLocaleSwitcherContent();\n\n const content: any = (section as TranslationContent<string>)[\n NodeTypes.TRANSLATION\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {selectedLocales.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: NodeTypes.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>)[\n NodeTypes.ENUMERATION\n ];\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>)[NodeTypes.ENUMERATION]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeTypes.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 )[NodeTypes.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 [NodeTypes.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=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeTypes.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>)[NodeTypes.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: NodeTypes.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>)[NodeTypes.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: NodeTypes.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 PLURAL_CATEGORIES = ['zero', 'one', 'two', 'few', 'many', 'other'];\n\nconst PluralTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as PluralContent<string>)[NodeTypes.PLURAL];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {PLURAL_CATEGORIES.map((pluralKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-plural-${pluralKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{pluralKey}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[pluralKey as keyof typeof content] ??\n getEmptyNode(content.other)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeTypes.PLURAL,\n key: pluralKey,\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: NodeTypes.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: NodeTypes.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=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeTypes.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 const typedSection = section as unknown as Record<string, ContentNode>;\n const firstKey = Object.keys(typedSection)[0] as keyof typeof section;\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(typedSection).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key },\n ];\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n // Collapse any object/array (typed or plain) — only true primitives render inline.\n // getIsEditableSection can't be used here: it inspects getNodeChildren(), which for\n // translation nodes returns the first locale value (a string), causing translation\n // subtrees to be mistakenly treated as leaves and mounted all at once.\n const isLeaf = subSection === null || typeof subSection !== 'object';\n\n if (isLeaf) {\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 return (\n <tr\n key={uniqueKey}\n className=\"block w-full border-neutral/10 border-t py-1\"\n >\n <td className=\"flex w-full\">\n <CollapsibleEditor\n label={camelCaseToSentence(key)}\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nenum MarkdownViewMode {\n Edit,\n Raw,\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: NodeTypes.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeTypes.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=\"text\"\n size=\"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 ? (rawContent) => <SafeHtmlRenderer rawContent={rawContent} />\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 { addEditedContent } = useEditedContent();\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Raw',\n value: MarkdownViewMode.Raw,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeTypes.MARKDOWN }];\n\n const content = ((section as MarkdownContent<ContentNode>)[\n NodeTypes.MARKDOWN\n ] ?? '') as ContentNode;\n\n // The WYSIWYG editor only handles a plain markdown string. When the markdown\n // node wraps another node (e.g. `md(t({ ... }))`), fall back to the recursive\n // editor so the inner translation/nested structure stays editable.\n const isStringLeaf = typeof content === 'string';\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=\"text\"\n size=\"sm\"\n className=\"ml-auto\"\n />\n\n {mode === MarkdownViewMode.Edit && isStringLeaf ? (\n <Container\n border\n background=\"none\"\n roundedSize=\"2xl\"\n padding=\"lg\"\n className=\"w-full\"\n >\n <Suspense fallback={<Loader />}>\n <LazyMarkdownEditor\n key={JSON.stringify(childKeyPath)}\n defaultValue={content}\n onChange={(markdown) =>\n addEditedContent(dictionary.localId!, markdown, childKeyPath)\n }\n />\n </Suspense>\n </Container>\n ) : (\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <Suspense fallback={<Loader />}>\n <LazyMarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </LazyMarkdownRenderer>\n </Suspense>\n )\n : undefined\n }\n />\n )}\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeTypes.INSERTION }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeTypes.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: NodeTypes.FILE }];\n\n const fileUrl = (section as FileContent)[NodeTypes.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)[NodeTypes.NESTED];\n const childrenKeyPath = [...keyPath, { type: NodeTypes.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=\"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=\"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 = memo<TextEditorProps>(function TextEditor({\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 === NodeTypes.REACT_NODE) {\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 === NodeTypes.NESTED) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.TRANSLATION) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.ENUMERATION) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.CONDITION) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.GENDER) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.PLURAL) {\n return (\n <PluralTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.INSERTION) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.MARKDOWN) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeTypes.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.FILE) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.ARRAY) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.OBJECT) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeTypes.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 === NodeTypes.TEXT) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant=\"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 === NodeTypes.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 = memo<TextEditorProps>(\n function TextEditorContainer(props) {\n return (\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=\"2xl\"\n >\n <TextEditor {...props} />\n </Container>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,uBAAuB,WAC3B,OAAO,kCAA8B,MAAM,OAAO,EAChD,SAAS,EAAE,kBACZ,EAAE,CACJ;AAID,MAAM,qBAAqB,WACzB,OAAO,kCAA8B,MAAM,OAAO,EAChD,SAAS,EAAE,gBACZ,EAAE,CACJ;AAKD,MAAM,oBAAoB,KACxB,SAAS,kBAAkB,EAAE,OAAO,GAAG,eAAe;CACpD,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;AACjD,QACE,oBAAC,WAAD;EACE,QAAQ;EACD;EACP,WAAW,WAAW;AACpB,OAAI,UAAU,CAAC,UAAW,cAAa,KAAK;;YAG7C,YAAY,oBAAC,YAAD,EAAY,GAAI,aAAe,IAAG;EACrC;EAGjB;AAED,MAAa,YAAsB;CAAC;CAAY;CAAM;CAAW;AAUjE,MAAM,yBAAyD,EAC7D,SACA,YACA,GAAG,YACC;CACJ,MAAM,EAAE,eAAe,qBAAqB,kBAAkB;CAC9D,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,EAAE,QAAQ,8BAA8B,WAAW,eACvD,iCAAi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ACE,oBAAC,gBAAD;EACc;EACH;EACA;EACT;AAIN,KAAI,aAAa,UAAU,KACzB,QACE,oBAAC,gBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,MACzB,QACE,oBAAC,iBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,OACzB,QACE,oBAAC,kBAAD;EACc;EACG;EACN;EACA;EACT;AAIN,KAAI,aAAa,UAAU,OACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,oBAAD;GACc;GACH;GACT,MAAK;GACL,cAAW;aAEV;GACkB;EACjB;AAIV,KAAI,aAAa,UAAU,KACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACZ,OAAO,kBAAkB,aACxB,cAAc,QAAkB,GAEhC,oBAAC,uBAAD;GACE,SAAQ;GACR,cAAW;GACF;GACG;aAEX;GACqB;EAEtB;AAIV,KAAI,aAAa,UAAU,QACzB,QACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,qBAAD;GACc;GACH;GACT,OAAO;GACP;EACE;AAIV,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf;GAA4B;GAEzB,KAAK,UAAU,SAAS,MAAM,EAAE;GAChC,KAAK,UAAU,SAAS,MAAM,EAAE;GAAC;GACtB;GACR;;EAER;AAEF,MAAa,sBAAsB,KACjC,SAAS,oBAAoB,OAAO;AAClC,QACE,oBAAC,WAAD;EACE;EACA,YAAW;EACX,WAAU;EACV,aAAY;YAEZ,oBAAC,YAAD,EAAY,GAAI,OAAS;EACf;EAGjB"}
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs
CHANGED
|
@@ -1,62 +1,173 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { Button } from "../../Button/Button.mjs";
|
|
3
4
|
import { useSession } from "../../../api/useAuth/useSession.mjs";
|
|
4
5
|
import { useAddDictionary } from "../../../api/hooks/dictionary.mjs";
|
|
5
6
|
import { useGetProjects } from "../../../api/hooks/project.mjs";
|
|
6
7
|
import { MultiSelect } from "../../Select/Multiselect.mjs";
|
|
7
|
-
import {
|
|
8
|
+
import { Select } from "../../Select/Select.mjs";
|
|
9
|
+
import { InputElement } from "../../Form/elements/InputElement.mjs";
|
|
10
|
+
import { MultiSelectElement } from "../../Form/elements/MultiselectElement.mjs";
|
|
11
|
+
import { SelectElement } from "../../Form/elements/SelectElement.mjs";
|
|
12
|
+
import { useForm as useForm$1 } from "../../Form/FormBase.mjs";
|
|
8
13
|
import { Form } from "../../Form/Form.mjs";
|
|
9
|
-
import { useDictionarySchema } from "./useDictionaryFormSchema.mjs";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { QUALIFIER_TYPES, useDictionarySchema } from "./useDictionaryFormSchema.mjs";
|
|
15
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
16
|
import { useIntlayer } from "react-intlayer";
|
|
17
|
+
import { useWatch } from "react-hook-form";
|
|
18
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
12
19
|
|
|
13
20
|
//#region src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx
|
|
21
|
+
/**
|
|
22
|
+
* Inner component rendered inside Form's FormProvider context so useWatch works.
|
|
23
|
+
*/
|
|
24
|
+
const DictionaryCreationFormFields = ({ isSubmitting, isPending, projectsData }) => {
|
|
25
|
+
const { keyInput, createDictionaryButton, projectInput, qualifierTypeSelect, itemInput, variantInput, metaIdInput } = useIntlayer("dictionary-form");
|
|
26
|
+
const qualifierType = useWatch({ name: "qualifierType" }) ?? "none";
|
|
27
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28
|
+
/* @__PURE__ */ jsx(InputElement, {
|
|
29
|
+
name: "key",
|
|
30
|
+
label: keyInput.label.value,
|
|
31
|
+
placeholder: keyInput.placeholder.value,
|
|
32
|
+
isRequired: true
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsxs(MultiSelectElement, {
|
|
35
|
+
name: "projectIds",
|
|
36
|
+
label: projectInput.label.value,
|
|
37
|
+
children: [/* @__PURE__ */ jsx(MultiSelect.Trigger, {
|
|
38
|
+
getBadgeValue: (value) => projectsData?.data?.find((project) => String(project.id) === value)?.name ?? value,
|
|
39
|
+
children: /* @__PURE__ */ jsx(MultiSelect.Input, { placeholder: projectInput.placeholder.value })
|
|
40
|
+
}), /* @__PURE__ */ jsx(MultiSelect.Content, { children: /* @__PURE__ */ jsx(MultiSelect.List, { children: projectsData?.data?.map((project) => /* @__PURE__ */ jsx(MultiSelect.Item, {
|
|
41
|
+
value: String(project.id),
|
|
42
|
+
children: project.name
|
|
43
|
+
}, String(project.id))) }) })]
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ jsxs(SelectElement, {
|
|
46
|
+
name: "qualifierType",
|
|
47
|
+
label: qualifierTypeSelect.label.value,
|
|
48
|
+
description: qualifierTypeSelect.description.value,
|
|
49
|
+
children: [/* @__PURE__ */ jsx(Select.Trigger, { children: /* @__PURE__ */ jsx(Select.Value, {}) }), /* @__PURE__ */ jsx(Select.Content, { children: QUALIFIER_TYPES.map((type) => /* @__PURE__ */ jsx(Select.Item, {
|
|
50
|
+
value: type,
|
|
51
|
+
children: qualifierTypeSelect[type]
|
|
52
|
+
}, type)) })]
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsxs(AnimatePresence, {
|
|
55
|
+
mode: "wait",
|
|
56
|
+
children: [
|
|
57
|
+
qualifierType === "item" && /* @__PURE__ */ jsx(motion.div, {
|
|
58
|
+
initial: {
|
|
59
|
+
opacity: 0,
|
|
60
|
+
height: 0
|
|
61
|
+
},
|
|
62
|
+
animate: {
|
|
63
|
+
opacity: 1,
|
|
64
|
+
height: "auto"
|
|
65
|
+
},
|
|
66
|
+
exit: {
|
|
67
|
+
opacity: 0,
|
|
68
|
+
height: 0
|
|
69
|
+
},
|
|
70
|
+
transition: { duration: .2 },
|
|
71
|
+
className: "overflow-hidden",
|
|
72
|
+
children: /* @__PURE__ */ jsx(InputElement, {
|
|
73
|
+
name: "item",
|
|
74
|
+
type: "number",
|
|
75
|
+
label: itemInput.label.value,
|
|
76
|
+
placeholder: itemInput.placeholder.value,
|
|
77
|
+
description: itemInput.description.value,
|
|
78
|
+
min: 1
|
|
79
|
+
})
|
|
80
|
+
}, "item-input"),
|
|
81
|
+
qualifierType === "variant" && /* @__PURE__ */ jsx(motion.div, {
|
|
82
|
+
initial: {
|
|
83
|
+
opacity: 0,
|
|
84
|
+
height: 0
|
|
85
|
+
},
|
|
86
|
+
animate: {
|
|
87
|
+
opacity: 1,
|
|
88
|
+
height: "auto"
|
|
89
|
+
},
|
|
90
|
+
exit: {
|
|
91
|
+
opacity: 0,
|
|
92
|
+
height: 0
|
|
93
|
+
},
|
|
94
|
+
transition: { duration: .2 },
|
|
95
|
+
className: "overflow-hidden",
|
|
96
|
+
children: /* @__PURE__ */ jsx(InputElement, {
|
|
97
|
+
name: "variant",
|
|
98
|
+
label: variantInput.label.value,
|
|
99
|
+
placeholder: variantInput.placeholder.value,
|
|
100
|
+
description: variantInput.description.value
|
|
101
|
+
})
|
|
102
|
+
}, "variant-input"),
|
|
103
|
+
qualifierType === "meta" && /* @__PURE__ */ jsx(motion.div, {
|
|
104
|
+
initial: {
|
|
105
|
+
opacity: 0,
|
|
106
|
+
height: 0
|
|
107
|
+
},
|
|
108
|
+
animate: {
|
|
109
|
+
opacity: 1,
|
|
110
|
+
height: "auto"
|
|
111
|
+
},
|
|
112
|
+
exit: {
|
|
113
|
+
opacity: 0,
|
|
114
|
+
height: 0
|
|
115
|
+
},
|
|
116
|
+
transition: { duration: .2 },
|
|
117
|
+
className: "overflow-hidden",
|
|
118
|
+
children: /* @__PURE__ */ jsx(InputElement, {
|
|
119
|
+
name: "metaId",
|
|
120
|
+
label: metaIdInput.label.value,
|
|
121
|
+
placeholder: metaIdInput.placeholder.value,
|
|
122
|
+
description: metaIdInput.description.value
|
|
123
|
+
})
|
|
124
|
+
}, "meta-input")
|
|
125
|
+
]
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ jsx(Button, {
|
|
128
|
+
className: "mt-12 ml-auto",
|
|
129
|
+
type: "submit",
|
|
130
|
+
color: "text",
|
|
131
|
+
isLoading: isSubmitting || isPending,
|
|
132
|
+
label: createDictionaryButton.ariaLabel.value,
|
|
133
|
+
isFullWidth: true,
|
|
134
|
+
children: createDictionaryButton.text
|
|
135
|
+
})
|
|
136
|
+
] });
|
|
137
|
+
};
|
|
14
138
|
const DictionaryCreationForm = ({ onDictionaryCreated }) => {
|
|
15
139
|
const { session } = useSession();
|
|
16
140
|
const { project } = session ?? {};
|
|
17
141
|
const { mutate: addDictionary, isPending } = useAddDictionary();
|
|
18
142
|
const { data: projectsData } = useGetProjects();
|
|
19
143
|
const DictionarySchema = useDictionarySchema(String(project?.id));
|
|
20
|
-
const { form, isSubmitting } = useForm(DictionarySchema, { defaultValues: {
|
|
21
|
-
|
|
144
|
+
const { form, isSubmitting } = useForm$1(DictionarySchema, { defaultValues: {
|
|
145
|
+
projectIds: [project?.id],
|
|
146
|
+
qualifierType: "none"
|
|
147
|
+
} });
|
|
22
148
|
const onSubmitSuccess = (data) => {
|
|
23
|
-
|
|
149
|
+
const qualifiers = {};
|
|
150
|
+
if (data.qualifierType === "item" && data.item !== void 0) qualifiers.item = data.item;
|
|
151
|
+
else if (data.qualifierType === "variant" && data.variant) qualifiers.variant = data.variant;
|
|
152
|
+
else if (data.qualifierType === "meta" && data.metaId) qualifiers.meta = { id: data.metaId };
|
|
153
|
+
addDictionary({ dictionary: {
|
|
154
|
+
key: data.key,
|
|
155
|
+
projectIds: data.projectIds,
|
|
156
|
+
...qualifiers
|
|
157
|
+
} }, { onSuccess: () => {
|
|
24
158
|
onDictionaryCreated?.();
|
|
25
159
|
} });
|
|
26
160
|
};
|
|
27
|
-
return /* @__PURE__ */
|
|
161
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
28
162
|
schema: DictionarySchema,
|
|
29
163
|
onSubmitSuccess,
|
|
30
164
|
className: "m-auto w-full max-w-100",
|
|
31
165
|
...form,
|
|
32
|
-
children:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isRequired: true
|
|
38
|
-
}),
|
|
39
|
-
/* @__PURE__ */ jsxs(Form.MultiSelect, {
|
|
40
|
-
name: "projectIds",
|
|
41
|
-
label: projectInput.label.value,
|
|
42
|
-
children: [/* @__PURE__ */ jsx(MultiSelect.Trigger, {
|
|
43
|
-
getBadgeValue: (value) => projectsData?.data?.find((project) => String(project.id) === value)?.name ?? value,
|
|
44
|
-
children: /* @__PURE__ */ jsx(MultiSelect.Input, { placeholder: projectInput.placeholder.value })
|
|
45
|
-
}), /* @__PURE__ */ jsx(MultiSelect.Content, { children: /* @__PURE__ */ jsx(MultiSelect.List, { children: projectsData?.data?.map((project) => /* @__PURE__ */ jsx(MultiSelect.Item, {
|
|
46
|
-
value: String(project.id),
|
|
47
|
-
children: project.name
|
|
48
|
-
}, String(project.id))) }) })]
|
|
49
|
-
}),
|
|
50
|
-
/* @__PURE__ */ jsx(Form.Button, {
|
|
51
|
-
className: "mt-12 ml-auto",
|
|
52
|
-
type: "submit",
|
|
53
|
-
color: "text",
|
|
54
|
-
isLoading: isSubmitting || isPending,
|
|
55
|
-
label: createDictionaryButton.ariaLabel.value,
|
|
56
|
-
isFullWidth: true,
|
|
57
|
-
children: createDictionaryButton.text
|
|
58
|
-
})
|
|
59
|
-
]
|
|
166
|
+
children: /* @__PURE__ */ jsx(DictionaryCreationFormFields, {
|
|
167
|
+
isSubmitting,
|
|
168
|
+
isPending,
|
|
169
|
+
projectsData
|
|
170
|
+
})
|
|
60
171
|
});
|
|
61
172
|
};
|
|
62
173
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryCreationForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { useAddDictionary, useGetProjects } from '@api/index';\nimport { useSession } from '@api/useAuth';\nimport {
|
|
1
|
+
{"version":3,"file":"DictionaryCreationForm.mjs","names":["FormInput","FormMultiSelect","FormSelect","FormButton","useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.tsx"],"sourcesContent":["'use client';\n\nimport { useAddDictionary, useGetProjects } from '@api/index';\nimport { useSession } from '@api/useAuth';\nimport {\n Form,\n FormButton,\n FormInput,\n FormMultiSelect,\n FormSelect,\n useForm,\n} from '@components/Form';\nimport { MultiSelect, Select } from '@components/Select';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport type { FC } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport {\n type DictionaryFormData,\n QUALIFIER_TYPES,\n type QualifierType,\n useDictionarySchema,\n} from './useDictionaryFormSchema';\n\ntype DictionaryCreationFormProps = {\n onDictionaryCreated?: () => void;\n};\n\n/**\n * Inner component rendered inside Form's FormProvider context so useWatch works.\n */\nconst DictionaryCreationFormFields: FC<{\n isSubmitting: boolean;\n isPending: boolean;\n projectsData: ReturnType<typeof useGetProjects>['data'];\n}> = ({ isSubmitting, isPending, projectsData }) => {\n const {\n keyInput,\n createDictionaryButton,\n projectInput,\n qualifierTypeSelect,\n itemInput,\n variantInput,\n metaIdInput,\n } = useIntlayer('dictionary-form');\n\n const qualifierType = (useWatch({ name: 'qualifierType' }) ??\n 'none') as QualifierType;\n\n return (\n <>\n <FormInput\n name=\"key\"\n label={keyInput.label.value}\n placeholder={keyInput.placeholder.value}\n isRequired\n />\n\n <FormMultiSelect name=\"projectIds\" label={projectInput.label.value}>\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projectsData?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <MultiSelect.List>\n {projectsData?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </MultiSelect.Content>\n </FormMultiSelect>\n\n <FormSelect\n name=\"qualifierType\"\n label={qualifierTypeSelect.label.value}\n description={qualifierTypeSelect.description.value}\n >\n <Select.Trigger>\n <Select.Value />\n </Select.Trigger>\n <Select.Content>\n {QUALIFIER_TYPES.map((type) => (\n <Select.Item key={type} value={type}>\n {\n (\n qualifierTypeSelect as Record<\n string,\n { value: string } | string\n >\n )[type]\n }\n </Select.Item>\n ))}\n </Select.Content>\n </FormSelect>\n\n <AnimatePresence mode=\"wait\">\n {qualifierType === 'item' && (\n <motion.div\n key=\"item-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"item\"\n type=\"number\"\n label={itemInput.label.value}\n placeholder={itemInput.placeholder.value}\n description={itemInput.description.value}\n min={1}\n />\n </motion.div>\n )}\n\n {qualifierType === 'variant' && (\n <motion.div\n key=\"variant-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"variant\"\n label={variantInput.label.value}\n placeholder={variantInput.placeholder.value}\n description={variantInput.description.value}\n />\n </motion.div>\n )}\n\n {qualifierType === 'meta' && (\n <motion.div\n key=\"meta-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <FormInput\n name=\"metaId\"\n label={metaIdInput.label.value}\n placeholder={metaIdInput.placeholder.value}\n description={metaIdInput.description.value}\n />\n </motion.div>\n )}\n </AnimatePresence>\n\n <FormButton\n className=\"mt-12 ml-auto\"\n type=\"submit\"\n color=\"text\"\n isLoading={isSubmitting || isPending}\n label={createDictionaryButton.ariaLabel.value}\n isFullWidth\n >\n {createDictionaryButton.text}\n </FormButton>\n </>\n );\n};\n\nexport const DictionaryCreationForm: FC<DictionaryCreationFormProps> = ({\n onDictionaryCreated,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { mutate: addDictionary, isPending } = useAddDictionary();\n const { data: projectsData } = useGetProjects();\n const DictionarySchema = useDictionarySchema(String(project?.id));\n const { form, isSubmitting } = useForm(DictionarySchema, {\n defaultValues: {\n projectIds: [project?.id],\n qualifierType: 'none',\n },\n });\n\n const onSubmitSuccess = (data: DictionaryFormData) => {\n const qualifiers: Record<string, unknown> = {};\n if (data.qualifierType === 'item' && data.item !== undefined) {\n qualifiers.item = data.item;\n } else if (data.qualifierType === 'variant' && data.variant) {\n qualifiers.variant = data.variant;\n } else if (data.qualifierType === 'meta' && data.metaId) {\n qualifiers.meta = { id: data.metaId };\n }\n\n addDictionary(\n {\n dictionary: {\n key: data.key,\n projectIds: data.projectIds,\n ...qualifiers,\n },\n },\n {\n onSuccess: () => {\n onDictionaryCreated?.();\n },\n }\n );\n };\n\n return (\n <Form\n schema={DictionarySchema}\n onSubmitSuccess={onSubmitSuccess}\n className=\"m-auto w-full max-w-100\"\n {...form}\n >\n <DictionaryCreationFormFields\n isSubmitting={isSubmitting}\n isPending={isPending}\n projectsData={projectsData}\n />\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,gCAIA,EAAE,cAAc,WAAW,mBAAmB;CAClD,MAAM,EACJ,UACA,wBACA,cACA,qBACA,WACA,cACA,gBACE,YAAY,kBAAkB;CAElC,MAAM,gBAAiB,SAAS,EAAE,MAAM,iBAAiB,CAAC,IACxD;AAEF,QACE;EACE,oBAACA,cAAD;GACE,MAAK;GACL,OAAO,SA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