@intlayer/design-system 8.2.4 → 8.3.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/Accordion/Accordion.mjs +1 -1
- package/dist/esm/components/Avatar/index.mjs +1 -1
- package/dist/esm/components/Breadcrumb/index.mjs +1 -1
- package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/esm/components/Browser/Browser.mjs +1 -1
- package/dist/esm/components/Carousel/index.mjs +4 -4
- package/dist/esm/components/CollapsibleTable/CollapsibleTable.mjs +1 -1
- package/dist/esm/components/ContentEditor/ContentEditor.mjs +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorInput.mjs +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/esm/components/CopyButton/index.mjs +1 -1
- package/dist/esm/components/CopyToClipboard/index.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/getIsEditableSection.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldLayout.mjs +1 -1
- package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs +1 -1
- package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
- package/dist/esm/components/Flags/Flag.mjs +1 -1
- package/dist/esm/components/Flags/Flag.mjs.map +1 -1
- package/dist/esm/components/HTMLRender/HTMLRender.mjs.map +1 -1
- package/dist/esm/components/HideShow/index.mjs +1 -1
- package/dist/esm/components/IDE/FileTree.mjs +1 -1
- package/dist/esm/components/Input/InputPassword.mjs +1 -1
- package/dist/esm/components/Input/OTPInput.mjs +2 -2
- package/dist/esm/components/LanguageBackground/index.mjs +1 -1
- package/dist/esm/components/LanguageBackground/index.mjs.map +1 -1
- package/dist/esm/components/Link/Link.mjs +1 -1
- package/dist/esm/components/Link/Link.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/esm/components/MaxHeightSmoother/index.mjs +1 -1
- package/dist/esm/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/esm/components/Modal/Modal.mjs +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs +1 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs +1 -1
- package/dist/esm/components/Select/Multiselect.mjs +1 -1
- package/dist/esm/components/Table/Table.mjs +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs +1 -1
- package/dist/esm/components/Toaster/Toast.mjs +1 -1
- package/dist/esm/components/index.mjs +1 -1
- package/dist/esm/hooks/reactQuery.mjs +1 -1
- package/dist/esm/hooks/reactQuery.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useAuth.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs.map +1 -1
- package/dist/esm/hooks/useIntlayerAPI.mjs.map +1 -1
- package/dist/esm/libs/auth.mjs +1 -1
- package/dist/esm/libs/auth.mjs.map +1 -1
- package/dist/esm/providers/ReactQueryProvider.mjs +1 -1
- package/dist/types/components/Breadcrumb/breadcrumb.content.d.ts +3 -3
- package/dist/types/components/Breadcrumb/index.d.ts +1 -1
- package/dist/types/components/Browser/Browser.content.d.ts +17 -17
- package/dist/types/components/Button/Button.d.ts +1 -1
- package/dist/types/components/Carousel/index.content.d.ts +7 -7
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +2 -2
- package/dist/types/components/Command/index.d.ts +1 -1
- package/dist/types/components/Container/index.d.ts +6 -6
- package/dist/types/components/CopyButton/CopyButton.content.d.ts +3 -3
- package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts +2 -1
- package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/ConditionWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/ConditionWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/HtmlWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/HtmlWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/index.d.ts +3 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditor.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +2 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +25 -25
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts +9 -9
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +55 -55
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts +33 -33
- package/dist/types/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/JSONEditor.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts +2 -1
- package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts +4 -4
- package/dist/types/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +25 -25
- package/dist/types/components/DictionaryFieldEditor/NodeTypeSelector.d.ts +2 -1
- package/dist/types/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +33 -33
- package/dist/types/components/DictionaryFieldEditor/StructureEditor.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +2 -1
- package/dist/types/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/StructureView/structureView.content.d.ts +9 -9
- package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts +7 -7
- package/dist/types/components/DictionaryFieldEditor/dictionaryFieldEditor.content.d.ts +5 -5
- package/dist/types/components/DictionaryFieldEditor/getIsEditableSection.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +31 -31
- package/dist/types/components/ExpandCollapse/expandCollapse.content.d.ts +3 -3
- package/dist/types/components/Flags/Flag.d.ts +1 -1
- package/dist/types/components/Flags/Flag.d.ts.map +1 -1
- package/dist/types/components/HTMLRender/HTMLRender.d.ts +1 -1
- package/dist/types/components/IDE/code.content.d.ts +5 -5
- package/dist/types/components/IDE/copyCode.content.d.ts +5 -5
- package/dist/types/components/IDE/selectors.content.d.ts +13 -13
- package/dist/types/components/Input/Checkbox.d.ts +1 -1
- package/dist/types/components/LanguageBackground/index.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +2 -2
- package/dist/types/components/Loader/index.content.d.ts +3 -3
- package/dist/types/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.d.ts.map +1 -1
- package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts +17 -17
- package/dist/types/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts +1 -1
- package/dist/types/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts.map +1 -1
- package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts +13 -13
- package/dist/types/components/MarkDownRender/MarkDownRender.d.ts +2 -2
- package/dist/types/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +2 -2
- package/dist/types/components/Pagination/pagination.content.d.ts +11 -11
- package/dist/types/components/RightDrawer/rightDrawer.content.d.ts +5 -5
- package/dist/types/components/Tab/Tab.d.ts +1 -1
- package/dist/types/components/TabSelector/TabSelector.d.ts +1 -1
- package/dist/types/components/Table/table.content.d.ts +3 -3
- package/dist/types/components/Tag/index.d.ts +1 -1
- package/dist/types/components/Terminal/terminal.content.d.ts +5 -5
- package/dist/types/hooks/useAuth/useAuth.d.ts +1 -1
- package/dist/types/hooks/useAuth/useOAuth2.d.ts +1 -1
- package/dist/types/hooks/useAuth/useSession.d.ts +1 -1
- package/dist/types/hooks/useIntlayerAPI.d.ts +1 -1
- package/dist/types/libs/auth.d.ts +1 -1
- package/package.json +30 -28
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Container as e}from"../../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonSize as r,ButtonTextAlign as i,ButtonVariant as a}from"../../Button/Button.mjs";import{InputVariant as o}from"../../Input/Input.mjs";import{useAuditContentDeclarationField as s}from"../../../hooks/reactQuery.mjs";import{SwitchSelector as c,SwitchSelectorColor as l,SwitchSelectorSize as u}from"../../SwitchSelector/index.mjs";import{useLocaleSwitcherContent as d}from"../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";import{ContentEditorInput as f}from"../../ContentEditor/ContentEditorInput.mjs";import{ContentEditorTextArea as p}from"../../ContentEditor/ContentEditorTextArea.mjs";import{Label as m}from"../../Label/index.mjs";import{MarkdownRenderer as h}from"../../MarkDownRender/MarkDownRender.mjs";import{renameKey as g}from"../../../utils/object.mjs";import{EnumKeyInput as _}from"../EnumKeyInput.mjs";import{Plus as v,Trash as y,WandSparkles as b}from"lucide-react";import{Fragment as x,useState as S}from"react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";import{useIntlayer as E,useLocale as D}from"react-intlayer";import{getLocaleName as O}from"@intlayer/core/localization";import{useConfiguration as k,useEditedContent as A}from"@intlayer/editor-react";import{getEmptyNode as j,getNodeType as M}from"@intlayer/core/dictionaryManipulator";import{NodeType as N}from"@intlayer/types";const P=[`filePath`,`id`,`nodeType`],F=({keyPath:e,dictionary:i,...c})=>{let{editedContent:l,addEditedContent:u}=A(),d=k(),{mutate:f,isPending:m}=s();return w(p,{variant:o.DEFAULT,onContentChange:t=>u(i.localId,t,e),additionalButtons:w(t,{Icon:b,label:`Audit`,variant:a.HOVERABLE,size:r.ICON_SM,color:n.TEXT,className:`cursor-pointer hover:scale-110`,isLoading:m,onClick:()=>{f({fileContent:JSON.stringify({...i,...l?.[i.localId]??{}}),keyPath:e,locales:d.internationalization.locales??[],aiOptions:{apiKey:d.ai?.apiKey,model:d.ai?.model,temperature:d.ai?.temperature}},{onSuccess:t=>{if(t?.data)try{let n=t.data.fileContent;u(i.localId,n,e)}catch(e){console.error(e)}}})}}),...c})},I=({keyPath:e,dictionary:t,...n})=>{let{addEditedContent:r}=A();return w(f,{variant:o.DEFAULT,onContentChange:n=>r(t.localId,n,e),...n})},L=[{content:`False`,value:!1},{content:`True`,value:!0}],R=({dictionary:e,keyPath:t,...n})=>{let{addEditedContent:r}=A();return w(c,{choices:L,value:!0,onChange:n=>r(e.localId,n,t),color:l.TEXT,size:u.SM,...n})},z=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let{locale:i,defaultLocale:a}=D(),{selectedLocales:o,availableLocales:s}=d(),c=e[N.Translation],l=Object.keys(c),u=s.length>o.length?o:[...new Set([...s,...l])],f=e[N.Translation];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:u.map(e=>{let o=`${JSON.stringify(t)}-translation-${e}`;return T(x,{children:[w(`tr`,{className:`mt-2 w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:O(e,i)})}),w(`tr`,{className:`flex`,children:w(`td`,{className:`flex w-full`,children:w($,{section:f[e]??j(f[a]),keyPath:[...t,{type:N.Translation,key:e}],dictionary:n,renderSection:r})})})]},o)})})})},B=({section:e,keyPath:r,dictionary:o,renderSection:s})=>{let{addEditedContent:c}=A(),{addNewEnumeration:l,removeEnumeration:u}=E(`navigation-view`),d=e[N.Enumeration],f=Object.keys(d)[0];return T(`div`,{className:`flex flex-col gap-2`,children:[w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:Object.keys(e[N.Enumeration]).map(n=>{let i=[...r,{type:N.Enumeration,key:n}],a=`${JSON.stringify(r)}-enumeration-${n}`;return T(x,{children:[w(`tr`,{className:`mt-2 w-full`,children:w(`td`,{className:`flex w-full`,children:w(`div`,{className:`flex flex-1`,children:w(t,{label:u.label.value,variant:`hoverable`,size:`sm`,color:`error`,className:`ml-auto text-neutral hover:text-error`,Icon:y,onClick:()=>c(o.localId,void 0,i),children:u.text})})})}),w(`tr`,{className:`w-full p-2`,children:w(`td`,{className:`flex w-full`,children:w(_,{value:n,onChange:t=>{let i=e[N.Enumeration],a=g(i,n,t),s={...e,[N.Enumeration]:a};console.log(`newValue`,s),c(o.localId,s,r)}})})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w(Q,{section:d[n]??j(d[f]),keyPath:i,dictionary:o,renderSection:s})})})]},a)})})}),w(t,{label:l.label.value,variant:a.HOVERABLE,color:n.NEUTRAL,textAlign:i.LEFT,isFullWidth:!0,onClick:()=>c(o.localId,j(d[f])??``,[...r,{type:N.Enumeration,key:`unknown`}]),Icon:v,className:`m-2`,children:l.text})]})},V=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let i=e[N.Condition];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:[`true`,`false`,`fallback`].map(e=>{let a=`${JSON.stringify(t)}-condition-${e}`;return T(x,{children:[w(`tr`,{className:`mt-2 block w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(e)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:i[e]??j(i.true),keyPath:[...t,{type:N.Condition,key:e}],dictionary:n,renderSection:r})})})]},a)})})})},H=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let i=e[N.Gender];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:[`male`,`female`,`fallback`].map(e=>{let a=`${JSON.stringify(t)}-gender-${e}`;return T(x,{children:[w(`tr`,{className:`mt-2 block w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(e)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:i[e]??j(i.male),keyPath:[...t,{type:N.Gender,key:e}],dictionary:n,renderSection:r})})})]},a)})})})},U=({section:e,keyPath:r,dictionary:o,renderSection:s})=>{let{addEditedContent:c}=A(),{addNewElement:l,removeElement:u}=E(`navigation-view`);return T(`div`,{className:`flex flex-col gap-2`,children:[w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:e.map((n,i)=>{let a=`${JSON.stringify(r)}-array-${i}`;return T(x,{children:[w(`tr`,{className:`mt-2 w-full p-2`,children:w(`td`,{className:`flex w-full`,children:T(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[w(`span`,{className:`text-xs`,children:String(i)}),w(t,{label:u.label.value,variant:`hoverable`,size:`sm`,color:`error`,className:`ml-auto text-neutral hover:text-error`,onClick:()=>{let e=[...r,{type:N.Array,key:i}];c(o.localId,void 0,e)},Icon:y,children:u.text})]})})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:n??j(e[0]),keyPath:[...r,{type:N.Array,key:i}],dictionary:o,renderSection:s})})})]},a)})})}),w(t,{label:l.label.value,variant:a.HOVERABLE,color:n.NEUTRAL,textAlign:i.LEFT,isFullWidth:!0,onClick:()=>{let t=[...r,{type:N.Array,key:e.length}];c(o.localId,j(e[0])??``,t,!1)},Icon:v,children:l.text})]})},W=({section:e,keyPath:t,dictionary:n,renderSection:r})=>w(C,{children:w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex flex-col gap-2`,children:Object.keys(e).map(i=>{let a=[...t,{type:N.Object,key:i}],o=e,s=Object.keys(o)[0],c=o[i]??j(o[s]),l=`${JSON.stringify(t)}-object-${i}`;return T(x,{children:[w(`tr`,{className:`mt-2 p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(i)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w(Q,{section:c,keyPath:a,dictionary:n,renderSection:r})})})]},l)})})})});var G=function(e){return e[e.Edit=0]=`Edit`,e[e.Preview=1]=`Preview`,e}(G||{}),K=function(e){return e[e.Edit=0]=`Edit`,e[e.Preview=1]=`Preview`,e}(K||{});const q=({section:e,keyPath:t,dictionary:n})=>{let[r,i]=S(K.Edit),a=[{content:`Edit`,value:K.Edit},{content:`Preview`,value:K.Preview}],o=[...t,{type:N.HTML}],s=e[N.HTML];return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[w(c,{choices:a,value:r,onChange:i,color:l.TEXT,size:u.SM,className:`ml-auto`}),w($,{section:s,keyPath:o,dictionary:n,renderSection:r===K.Preview?e=>w(`div`,{dangerouslySetInnerHTML:{__html:e}}):void 0})]})},J=({section:e,keyPath:t,dictionary:n,isDarkMode:r})=>{let[i,a]=S(G.Edit),o=[{content:`Edit`,value:G.Edit},{content:`Preview`,value:G.Preview}],s=[...t,{type:N.Markdown}],d=e[N.Markdown];return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[w(c,{choices:o,value:i,onChange:a,color:l.TEXT,size:u.SM,className:`ml-auto`}),w($,{section:d,keyPath:s,dictionary:n,renderSection:i===G.Preview?e=>w(h,{isDarkMode:r,children:e}):void 0})]})},Y=({section:e,keyPath:t,...n})=>{let r=[...t,{type:N.Insertion}],i=e[N.Insertion];return w(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:w($,{section:i,keyPath:r,...n})})},X=({section:e,keyPath:t,...n})=>{let r=[...t,{type:N.File}],i=e[N.File],{content:a}=e;return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[T(`span`,{className:`text-neutral text-sm`,children:[i,` `]}),w($,{section:a,keyPath:r,...n})]})},Z=({keyPath:e,dictionary:t,renderSection:n,section:r,...i})=>{let{addEditedContent:a}=A(),s=r[N.Nested],c=[...e,{type:N.Nested}];return T(`div`,{className:`flex w-full flex-col gap-4 p-2`,children:[w(m,{children:`Dictionary key`}),w(f,{"aria-label":`Edit field`,type:`text`,variant:o.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...s,dictionaryKey:String(e)},c)},children:s.dictionaryKey??``}),w(m,{children:`Path (optional)`}),w(f,{"aria-label":`Edit field`,type:`text`,variant:o.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...s,path:e===``?void 0:e},c)},children:s.path??``})]})},Q=({section:e,keyPath:t,dictionary:n,renderSection:r,isDarkMode:i})=>{let{tsxNotEditable:a}=E(`navigation-view`),s=M(e);return s===N.ReactNode?T(`div`,{className:`flex w-full flex-col gap-2`,children:[w(`span`,{children:`(React Node)`}),w(`span`,{className:`flex text-neutral text-xs`,children:a})]}):s===N.Nested?w(Z,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Translation?w(z,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Enumeration?w(B,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Condition?w(V,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Gender?w(H,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Insertion?w(Y,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Markdown?w(J,{dictionary:n,keyPath:t,section:e,isDarkMode:i}):s===N.HTML?w(q,{dictionary:n,keyPath:t,section:e}):s===N.File?w(X,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Array?w(U,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Object?w(W,{dictionary:n,renderSection:r,keyPath:t,section:e}):s===N.Number?w(`div`,{className:`w-full p-2`,children:w(I,{dictionary:n,keyPath:t,type:`number`,"aria-label":`Edit field`,children:e})}):s===N.Text?w(`div`,{className:`w-full p-2`,children:typeof r==`function`?r(e):w(F,{variant:o.DEFAULT,"aria-label":`Edit field`,keyPath:t,dictionary:n,children:e})}):s===N.Boolean?w(`div`,{className:`w-full p-2`,children:w(R,{dictionary:n,keyPath:t,value:e})}):T(`div`,{className:`w-full p-2`,children:[`Error. Format not supported.`,JSON.stringify(e,null,2),JSON.stringify(t,null,2),`NodeType : `,s]})},$=t=>w(e,{border:!0,background:`none`,className:`top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky`,roundedSize:`xl`,children:w(Q,{...t})});export{Q as TextEditor,$ as TextEditorContainer,P as traceKeys};
|
|
1
|
+
"use client";import{renameKey as e}from"../../../utils/object.mjs";import{Container as t}from"../../Container/index.mjs";import{Button as n,ButtonColor as r,ButtonSize as i,ButtonTextAlign as a,ButtonVariant as o}from"../../Button/Button.mjs";import{InputVariant as s}from"../../Input/Input.mjs";import{useAuditContentDeclarationField as c}from"../../../hooks/reactQuery.mjs";import{SwitchSelector as l,SwitchSelectorColor as u,SwitchSelectorSize as d}from"../../SwitchSelector/index.mjs";import{useLocaleSwitcherContent as f}from"../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";import{ContentEditorInput as p}from"../../ContentEditor/ContentEditorInput.mjs";import{ContentEditorTextArea as m}from"../../ContentEditor/ContentEditorTextArea.mjs";import{Label as h}from"../../Label/index.mjs";import{MarkdownRenderer as g}from"../../MarkDownRender/MarkDownRender.mjs";import{EnumKeyInput as _}from"../EnumKeyInput.mjs";import{Fragment as v,useState as y}from"react";import{Plus as b,Trash as x,WandSparkles as S}from"lucide-react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";import{useIntlayer as E,useLocale as D}from"react-intlayer";import{getLocaleName as O}from"@intlayer/core/localization";import{useConfiguration as k,useEditedContent as A}from"@intlayer/editor-react";import{getEmptyNode as j,getNodeType as M}from"@intlayer/core/dictionaryManipulator";import{NodeType as N}from"@intlayer/types/nodeType";const P=[`filePath`,`id`,`nodeType`],F=({keyPath:e,dictionary:t,...a})=>{let{editedContent:l,addEditedContent:u}=A(),d=k(),{mutate:f,isPending:p}=c();return w(m,{variant:s.DEFAULT,onContentChange:n=>u(t.localId,n,e),additionalButtons:w(n,{Icon:S,label:`Audit`,variant:o.HOVERABLE,size:i.ICON_SM,color:r.TEXT,className:`cursor-pointer hover:scale-110`,isLoading:p,onClick:()=>{f({fileContent:JSON.stringify({...t,...l?.[t.localId]??{}}),keyPath:e,locales:d.internationalization.locales??[],aiOptions:{apiKey:d.ai?.apiKey,model:d.ai?.model,temperature:d.ai?.temperature}},{onSuccess:n=>{if(n?.data)try{let r=n.data.fileContent;u(t.localId,r,e)}catch(e){console.error(e)}}})}}),...a})},I=({keyPath:e,dictionary:t,...n})=>{let{addEditedContent:r}=A();return w(p,{variant:s.DEFAULT,onContentChange:n=>r(t.localId,n,e),...n})},L=[{content:`False`,value:!1},{content:`True`,value:!0}],R=({dictionary:e,keyPath:t,...n})=>{let{addEditedContent:r}=A();return w(l,{choices:L,value:!0,onChange:n=>r(e.localId,n,t),color:u.TEXT,size:d.SM,...n})},z=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let{locale:i,defaultLocale:a}=D(),{selectedLocales:o,availableLocales:s}=f(),c=e[N.Translation],l=Object.keys(c),u=s.length>o.length?o:[...new Set([...s,...l])],d=e[N.Translation];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:u.map(e=>{let o=`${JSON.stringify(t)}-translation-${e}`;return T(v,{children:[w(`tr`,{className:`mt-2 w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:O(e,i)})}),w(`tr`,{className:`flex`,children:w(`td`,{className:`flex w-full`,children:w($,{section:d[e]??j(d[a]),keyPath:[...t,{type:N.Translation,key:e}],dictionary:n,renderSection:r})})})]},o)})})})},B=({section:t,keyPath:i,dictionary:s,renderSection:c})=>{let{addEditedContent:l}=A(),{addNewEnumeration:u,removeEnumeration:d}=E(`navigation-view`),f=t[N.Enumeration],p=Object.keys(f)[0];return T(`div`,{className:`flex flex-col gap-2`,children:[w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:Object.keys(t[N.Enumeration]).map(r=>{let a=[...i,{type:N.Enumeration,key:r}],o=`${JSON.stringify(i)}-enumeration-${r}`;return T(v,{children:[w(`tr`,{className:`mt-2 w-full`,children:w(`td`,{className:`flex w-full`,children:w(`div`,{className:`flex flex-1`,children:w(n,{label:d.label.value,variant:`hoverable`,size:`sm`,color:`error`,className:`ml-auto text-neutral hover:text-error`,Icon:x,onClick:()=>l(s.localId,void 0,a),children:d.text})})})}),w(`tr`,{className:`w-full p-2`,children:w(`td`,{className:`flex w-full`,children:w(_,{value:r,onChange:n=>{let a=t[N.Enumeration],o=e(a,r,n),c={...t,[N.Enumeration]:o};console.log(`newValue`,c),l(s.localId,c,i)}})})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w(Q,{section:f[r]??j(f[p]),keyPath:a,dictionary:s,renderSection:c})})})]},o)})})}),w(n,{label:u.label.value,variant:o.HOVERABLE,color:r.NEUTRAL,textAlign:a.LEFT,isFullWidth:!0,onClick:()=>l(s.localId,j(f[p])??``,[...i,{type:N.Enumeration,key:`unknown`}]),Icon:b,className:`m-2`,children:u.text})]})},V=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let i=e[N.Condition];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:[`true`,`false`,`fallback`].map(e=>{let a=`${JSON.stringify(t)}-condition-${e}`;return T(v,{children:[w(`tr`,{className:`mt-2 block w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(e)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:i[e]??j(i.true),keyPath:[...t,{type:N.Condition,key:e}],dictionary:n,renderSection:r})})})]},a)})})})},H=({section:e,keyPath:t,dictionary:n,renderSection:r})=>{let i=e[N.Gender];return w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:[`male`,`female`,`fallback`].map(e=>{let a=`${JSON.stringify(t)}-gender-${e}`;return T(v,{children:[w(`tr`,{className:`mt-2 block w-full p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(e)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:i[e]??j(i.male),keyPath:[...t,{type:N.Gender,key:e}],dictionary:n,renderSection:r})})})]},a)})})})},U=({section:e,keyPath:t,dictionary:i,renderSection:s})=>{let{addEditedContent:c}=A(),{addNewElement:l,removeElement:u}=E(`navigation-view`);return T(`div`,{className:`flex flex-col gap-2`,children:[w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex w-full flex-col gap-2`,children:e.map((r,a)=>{let o=`${JSON.stringify(t)}-array-${a}`;return T(v,{children:[w(`tr`,{className:`mt-2 w-full p-2`,children:w(`td`,{className:`flex w-full`,children:T(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[w(`span`,{className:`text-xs`,children:String(a)}),w(n,{label:u.label.value,variant:`hoverable`,size:`sm`,color:`error`,className:`ml-auto text-neutral hover:text-error`,onClick:()=>{let e=[...t,{type:N.Array,key:a}];c(i.localId,void 0,e)},Icon:x,children:u.text})]})})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w($,{section:r??j(e[0]),keyPath:[...t,{type:N.Array,key:a}],dictionary:i,renderSection:s})})})]},o)})})}),w(n,{label:l.label.value,variant:o.HOVERABLE,color:r.NEUTRAL,textAlign:a.LEFT,isFullWidth:!0,onClick:()=>{let n=[...t,{type:N.Array,key:e.length}];c(i.localId,j(e[0])??``,n,!1)},Icon:b,children:l.text})]})},W=({section:e,keyPath:t,dictionary:n,renderSection:r})=>w(C,{children:w(`table`,{className:`w-full`,children:w(`tbody`,{className:`flex flex-col gap-2`,children:Object.keys(e).map(i=>{let a=[...t,{type:N.Object,key:i}],o=e,s=Object.keys(o)[0],c=o[i]??j(o[s]),l=`${JSON.stringify(t)}-object-${i}`;return T(v,{children:[w(`tr`,{className:`mt-2 p-2 text-xs`,children:w(`td`,{className:`flex w-full`,children:String(i)})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w(Q,{section:c,keyPath:a,dictionary:n,renderSection:r})})})]},l)})})})});var G=function(e){return e[e.Edit=0]=`Edit`,e[e.Preview=1]=`Preview`,e}(G||{}),K=function(e){return e[e.Edit=0]=`Edit`,e[e.Preview=1]=`Preview`,e}(K||{});const q=({section:e,keyPath:t,dictionary:n})=>{let[r,i]=y(K.Edit),a=[{content:`Edit`,value:K.Edit},{content:`Preview`,value:K.Preview}],o=[...t,{type:N.HTML}],s=e[N.HTML];return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[w(l,{choices:a,value:r,onChange:i,color:u.TEXT,size:d.SM,className:`ml-auto`}),w($,{section:s,keyPath:o,dictionary:n,renderSection:r===K.Preview?e=>w(`div`,{dangerouslySetInnerHTML:{__html:e}}):void 0})]})},J=({section:e,keyPath:t,dictionary:n,isDarkMode:r})=>{let[i,a]=y(G.Edit),o=[{content:`Edit`,value:G.Edit},{content:`Preview`,value:G.Preview}],s=[...t,{type:N.Markdown}],c=e[N.Markdown];return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[w(l,{choices:o,value:i,onChange:a,color:u.TEXT,size:d.SM,className:`ml-auto`}),w($,{section:c,keyPath:s,dictionary:n,renderSection:i===G.Preview?e=>w(g,{isDarkMode:r,children:e}):void 0})]})},Y=({section:e,keyPath:t,...n})=>{let r=[...t,{type:N.Insertion}],i=e[N.Insertion];return w(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:w($,{section:i,keyPath:r,...n})})},X=({section:e,keyPath:t,...n})=>{let r=[...t,{type:N.File}],i=e[N.File],{content:a}=e;return T(`div`,{className:`flex w-full flex-col justify-center gap-6 p-2`,children:[T(`span`,{className:`text-neutral text-sm`,children:[i,` `]}),w($,{section:a,keyPath:r,...n})]})},Z=({keyPath:e,dictionary:t,renderSection:n,section:r,...i})=>{let{addEditedContent:a}=A(),o=r[N.Nested],c=[...e,{type:N.Nested}];return T(`div`,{className:`flex w-full flex-col gap-4 p-2`,children:[w(h,{children:`Dictionary key`}),w(p,{"aria-label":`Edit field`,type:`text`,variant:s.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...o,dictionaryKey:String(e)},c)},children:o.dictionaryKey??``}),w(h,{children:`Path (optional)`}),w(p,{"aria-label":`Edit field`,type:`text`,variant:s.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...o,path:e===``?void 0:e},c)},children:o.path??``})]})},Q=({section:e,keyPath:t,dictionary:n,renderSection:r,isDarkMode:i})=>{let{tsxNotEditable:a}=E(`navigation-view`),o=M(e);return o===N.ReactNode?T(`div`,{className:`flex w-full flex-col gap-2`,children:[w(`span`,{children:`(React Node)`}),w(`span`,{className:`flex text-neutral text-xs`,children:a})]}):o===N.Nested?w(Z,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Translation?w(z,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Enumeration?w(B,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Condition?w(V,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Gender?w(H,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Insertion?w(Y,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Markdown?w(J,{dictionary:n,keyPath:t,section:e,isDarkMode:i}):o===N.HTML?w(q,{dictionary:n,keyPath:t,section:e}):o===N.File?w(X,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Array?w(U,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Object?w(W,{dictionary:n,renderSection:r,keyPath:t,section:e}):o===N.Number?w(`div`,{className:`w-full p-2`,children:w(I,{dictionary:n,keyPath:t,type:`number`,"aria-label":`Edit field`,children:e})}):o===N.Text?w(`div`,{className:`w-full p-2`,children:typeof r==`function`?r(e):w(F,{variant:s.DEFAULT,"aria-label":`Edit field`,keyPath:t,dictionary:n,children:e})}):o===N.Boolean?w(`div`,{className:`w-full p-2`,children:w(R,{dictionary:n,keyPath:t,value:e})}):T(`div`,{className:`w-full p-2`,children:[`Error. Format not supported.`,JSON.stringify(e,null,2),JSON.stringify(t,null,2),`NodeType : `,o]})},$=e=>w(t,{border:!0,background:`none`,className:`top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky`,roundedSize:`xl`,children:w(Q,{...e})});export{Q as TextEditor,$ as TextEditorContainer,P as traceKeys};
|
|
2
2
|
//# sourceMappingURL=TextEditor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase","MarkdownRenderer"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '@components/ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '@components/ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '@components/Input';\nimport { Label } from '@components/Label';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '@components/MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '@components/SwitchSelector';\nimport { useAuditContentDeclarationField } from '@hooks/reactQuery';\nimport {\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n GenderContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport {\n type ContentNode,\n type Dictionary,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { renameKey } from '@utils/object';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-translation-${translationKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"flex w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ] as KeyPath[];\n const uniqueKey = `${JSON.stringify(keyPath)}-enumeration-${enumKey}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full\">\n <td className=\"flex w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n Icon={Trash}\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </td>\n </tr>\n <tr className=\"w-full p-2\">\n <td className=\"flex w-full\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n console.log('newValue', newValue);\n\n addEditedContent(\n dictionary.localId!,\n newValue,\n keyPath\n );\n }}\n />\n </td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-condition-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-gender-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-array-${index}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2\">\n <td className=\"flex w-full\">\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index, // Fixed: Use index instead of length\n },\n ];\n addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </div>\n </td>\n </tr>\n\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length, // Keeps length for adding new items\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 p-2 text-xs\">\n <td className=\"flex w-full\">{String(key)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nenum HtmlViewMode {\n Edit,\n Preview,\n}\n\nconst HtmlTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n}) => {\n const [mode, setMode] = useState(HtmlViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: HtmlViewMode.Edit,\n },\n {\n content: 'Preview',\n value: HtmlViewMode.Preview,\n },\n ] as SwitchSelectorChoices<HtmlViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeType.HTML\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === HtmlViewMode.Preview\n ? (content) => (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML content is user-controlled and rendered in editor context\n <div dangerouslySetInnerHTML={{ __html: content }} />\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <span>(React Node)</span>\n <span className=\"flex text-neutral text-xs\">{tsxNotEditable}</span>\n </div>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"],"mappings":"m6CA4DA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAU3D,GAAyD,CAC7D,UACA,aACA,GAAG,KACC,CACJ,GAAM,CAAE,gBAAe,oBAAqB,GAAkB,CACxD,EAAgB,GAAkB,CAClC,CAAE,OAAQ,EAA8B,UAAW,GACvD,GAAiC,CAEnC,OACE,EAACA,EAAD,CACE,QAAS,EAAa,QACtB,gBAAkB,GAChB,EAAiB,EAAW,QAAU,EAAU,EAAQ,CAE1D,kBACE,EAAC,EAAD,CACE,KAAM,EACN,MAAM,QACN,QAAS,EAAc,UACvB,KAAM,EAAW,QACjB,MAAO,EAAY,KACnB,UAAU,iCACV,UAAW,EACX,YAAe,CACb,EACE,CACE,YAAa,KAAK,UAAU,CAC1B,GAAG,EACH,GAAI,IAAgB,EAAW,UAAa,EAAE,CAC/C,CAAC,CACF,UACA,QAAS,EAAc,qBAAqB,SAAW,EAAE,CACzD,UAAW,CACT,OAAQ,EAAc,IAAI,OAC1B,MAAO,EAAc,IAAI,MACzB,YAAa,EAAc,IAAI,YAChC,CACF,CACD,CACE,UAAY,GAAa,CAClB,MAAU,KAEf,GAAI,CACF,IAAM,EAAgB,EAAS,KAAK,YAEpC,EACE,EAAW,QACX,EACA,EACD,OACM,EAAO,CACd,QAAQ,MAAM,EAAM,GAGzB,CACF,EAEH,CAAA,CAEJ,GAAI,EACJ,CAAA,EAYA,GAAmD,CACvD,UACA,aACA,GAAG,KACC,CACJ,GAAM,CAAE,oBAAqB,GAAkB,CAE/C,OACE,EAACC,EAAD,CACE,QAAS,EAAa,QACtB,gBAAkB,GAChB,EAAiB,EAAW,QAAU,EAAU,EAAQ,CAE1D,GAAI,EACJ,CAAA,EAIA,EAAgB,CACpB,CACE,QAAS,QACT,MAAO,GACR,CACD,CACE,QAAS,OACT,MAAO,GACR,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AAA,CAIF,IAAa,EAAS,OAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,KAAK,SACL,aAAW,sBAEV,EACkB,CAAA,CACjB,CAAA,CAIN,IAAa,EAAS,KAEtB,EAAC,MAAD,CAAK,UAAU,sBACZ,OAAO,GAAkB,WACxB,EAAc,EAAkB,CAEhC,EAAC,EAAD,CACE,QAAS,EAAa,QACtB,aAAW,aACF,UACG,sBAEX,EACqB,CAAA,CAEtB,CAAA,CAIN,IAAa,EAAS,QAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,MAAO,EACP,CAAA,CACE,CAAA,CAKR,EAAC,MAAD,CAAK,UAAU,sBAAf,CAA4B,+BAEzB,KAAK,UAAU,EAAS,KAAM,EAAE,CAChC,KAAK,UAAU,EAAS,KAAM,EAAE,CAAC,cACtB,EACR,IAIG,EAA4C,GACvD,EAAC,EAAD,CACE,OAAA,GACA,WAAW,OACX,UAAU,wEACV,YAAY,cAEZ,EAAC,EAAD,CAAY,GAAI,EAAS,CAAA,CACf,CAAA"}
|
|
1
|
+
{"version":3,"file":"TextEditor.mjs","names":["ContentEditorTextAreaBase","ContentEditorInputBase","MarkdownRenderer"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '@components/ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '@components/ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '@components/Input';\nimport { Label } from '@components/Label';\nimport { useLocaleSwitcherContent } from '@components/LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '@components/MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '@components/SwitchSelector';\nimport { useAuditContentDeclarationField } from '@hooks/reactQuery';\nimport {\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n GenderContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { renameKey } from '@utils/object';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-translation-${translationKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"flex w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ] as KeyPath[];\n const uniqueKey = `${JSON.stringify(keyPath)}-enumeration-${enumKey}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full\">\n <td className=\"flex w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n Icon={Trash}\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </td>\n </tr>\n <tr className=\"w-full p-2\">\n <td className=\"flex w-full\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n console.log('newValue', newValue);\n\n addEditedContent(\n dictionary.localId!,\n newValue,\n keyPath\n );\n }}\n />\n </td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-condition-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-gender-${condKey}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const uniqueKey = `${JSON.stringify(keyPath)}-array-${index}`;\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 w-full p-2\">\n <td className=\"flex w-full\">\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index, // Fixed: Use index instead of length\n },\n ];\n addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </div>\n </td>\n </tr>\n\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length, // Keeps length for adding new items\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n const uniqueKey = `${JSON.stringify(keyPath)}-object-${key}`;\n\n return (\n <Fragment key={uniqueKey}>\n <tr className=\"mt-2 p-2 text-xs\">\n <td className=\"flex w-full\">{String(key)}</td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nenum HtmlViewMode {\n Edit,\n Preview,\n}\n\nconst HtmlTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n}) => {\n const [mode, setMode] = useState(HtmlViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: HtmlViewMode.Edit,\n },\n {\n content: 'Preview',\n value: HtmlViewMode.Preview,\n },\n ] as SwitchSelectorChoices<HtmlViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.HTML }];\n\n const content = (section as HTMLContent<ContentNode>)[\n NodeType.HTML\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === HtmlViewMode.Preview\n ? (content) => (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML content is user-controlled and rendered in editor context\n <div dangerouslySetInnerHTML={{ __html: content }} />\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <span>(React Node)</span>\n <span className=\"flex text-neutral text-xs\">{tsxNotEditable}</span>\n </div>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"],"mappings":"46CAyDA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAU3D,GAAyD,CAC7D,UACA,aACA,GAAG,KACC,CACJ,GAAM,CAAE,gBAAe,oBAAqB,GAAkB,CACxD,EAAgB,GAAkB,CAClC,CAAE,OAAQ,EAA8B,UAAW,GACvD,GAAiC,CAEnC,OACE,EAACA,EAAD,CACE,QAAS,EAAa,QACtB,gBAAkB,GAChB,EAAiB,EAAW,QAAU,EAAU,EAAQ,CAE1D,kBACE,EAAC,EAAD,CACE,KAAM,EACN,MAAM,QACN,QAAS,EAAc,UACvB,KAAM,EAAW,QACjB,MAAO,EAAY,KACnB,UAAU,iCACV,UAAW,EACX,YAAe,CACb,EACE,CACE,YAAa,KAAK,UAAU,CAC1B,GAAG,EACH,GAAI,IAAgB,EAAW,UAAa,EAAE,CAC/C,CAAC,CACF,UACA,QAAS,EAAc,qBAAqB,SA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I,EAAS,CAAA,CACf,CAAA"}
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Loader as e}from"../../Loader/index.mjs";import{ButtonColor as t,ButtonSize as n,ButtonVariant as r}from"../../Button/Button.mjs";import{Checkbox as i}from"../../Input/Checkbox.mjs";import{useSession as a}from"../../../hooks/useAuth/useSession.mjs";import{useAuditContentDeclarationMetadata as o,useGetProjects as s,useGetTags as c}from"../../../hooks/reactQuery.mjs";import{MultiSelect as l}from"../../Select/Multiselect.mjs";import{Select as u}from"../../Select/Select.mjs";import{useForm as d}from"../../Form/FormBase.mjs";import{Form as f}from"../../Form/Form.mjs";import{useDictionaryDetailsSchema as p}from"./useDictionaryDetailsSchema.mjs";import{
|
|
1
|
+
"use client";import{Loader as e}from"../../Loader/index.mjs";import{ButtonColor as t,ButtonSize as n,ButtonVariant as r}from"../../Button/Button.mjs";import{Checkbox as i}from"../../Input/Checkbox.mjs";import{useSession as a}from"../../../hooks/useAuth/useSession.mjs";import{useAuditContentDeclarationMetadata as o,useGetProjects as s,useGetTags as c}from"../../../hooks/reactQuery.mjs";import{MultiSelect as l}from"../../Select/Multiselect.mjs";import{Select as u}from"../../Select/Select.mjs";import{useForm as d}from"../../Form/FormBase.mjs";import{Form as f}from"../../Form/Form.mjs";import{useDictionaryDetailsSchema as p}from"./useDictionaryDetailsSchema.mjs";import{useEffect as m}from"react";import{WandSparkles as h}from"lucide-react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{useIntlayer as v}from"react-intlayer";import{useEditedContent as y}from"@intlayer/editor-react";import{AnimatePresence as b,motion as x}from"framer-motion";import{useWatch as S}from"react-hook-form";const C=({dictionary:C,mode:w})=>{let{session:T}=a(),{project:E}=T??{},{data:D,isLoading:O}=s(),{data:k}=c(),A=D?.data??[],j=k?.data??[],M=p(String(E?.id)),{form:N,isSubmitting:P}=d(M,{defaultValues:{...C,location:C.location??`remote`}}),{editedContent:F,setEditedDictionary:I}=y(),{titleInput:L,keyInput:R,descriptionInput:z,projectInput:B,tagsSelect:V,locationSelect:H,importModeSelect:U,filePathInput:W,auditButton:G}=v(`dictionary-details`),{mutate:K,isPending:q}=o(),J=F?.[C.localId];m(()=>{N.reset({...C,location:C.location??`remote`})},[C,N?.reset]),m(()=>{J===void 0&&N.reset({...C,location:C.location??`remote`})},[J]);let Y=()=>{let e={...C,...J};K({fileContent:JSON.stringify(e)},{onSuccess:t=>{if(t?.data)try{let n=t.data.fileContent;I(t=>({...t,...e,...n})),N.reset({...e,...n})}catch(e){console.error(e)}}})},X=S({control:N.control,name:`location`}),Z=X===`local`||X===`hybrid`;return _(f,{className:`flex w-full flex-col gap-8`,...N,schema:M,children:[_(`div`,{className:`grid grid-cols-2 gap-8 max-md:grid-cols-1`,children:[g(f.EditableFieldInput,{name:`key`,label:R.label,placeholder:R.label.value,description:R.description,disabled:P,isRequired:!0,onSave:e=>{N.setValue(`key`,e,{shouldDirty:!0}),I(t=>({...C,...t??{},key:e}))}}),g(f.EditableFieldInput,{name:`title`,label:L.label,placeholder:L.placeholder.value,description:L.description,disabled:P,onSave:e=>{N.setValue(`title`,e,{shouldDirty:!0}),I(t=>({...C,...t??{},title:e}))}})]}),g(f.EditableFieldTextArea,{name:`description`,label:z.label,placeholder:z.placeholder.value,description:z.description,disabled:P,onSave:e=>{N.setValue(`description`,e,{shouldDirty:!0}),I(t=>({...C,...t??{},description:e}))}}),_(`div`,{className:`grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1`,children:[g(f.Field,{control:N.control,name:`location`,render:({field:e})=>{let t=e.value,n=t===`local`||t===`hybrid`,r=t===`remote`||t===`hybrid`,a=t=>{if(!t&&!r)return;let n=t?r?`hybrid`:`local`:`remote`;e.onChange(n);let i=t?N.getValues(`filePath`)??C.filePath:void 0;t||N.setValue(`filePath`,void 0),I(e=>({...C,...e??{},location:n,filePath:i}))},o=t=>{if(!t&&!n)return;let r=t?n?`hybrid`:`remote`:`local`;e.onChange(r),I(e=>({...C,...e??{},location:r}))};return _(f.Item,{className:`flex flex-col gap-2 px-1`,children:[g(f.Label,{className:`ml-1`,children:H.label}),_(`div`,{className:`ml-2 flex items-center gap-4 py-2`,children:[g(i,{id:`location-local`,name:`location-local`,label:H.local.value,checked:n,disabled:!w.includes(`local`)&&!w.includes(`remote`),onChange:e=>a(e.target.checked)}),g(i,{id:`location-remote`,name:`location-remote`,label:H.remote.value,checked:r,disabled:!w.includes(`remote`)&&C.location!==`remote`&&C.location!==`hybrid`,onChange:e=>o(e.target.checked)})]}),g(f.Description,{children:H.testDescription}),g(f.Message,{})]})}}),g(b,{mode:`wait`,children:Z&&g(x.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.3},className:`overflow-hidden`,children:g(f.Input,{name:`filePath`,label:W.label.value,placeholder:W.placeholder.value,description:W.description.value,disabled:P||!Z,onChange:e=>{let t=e.target.value;I(e=>({...C,...e??{},filePath:t}))}})},`filePath-input`)})]}),g(`div`,{className:`grid grid-cols-2 gap-8 max-md:grid-cols-1`,children:_(f.Select,{name:`importMode`,label:U.label.value,description:U.description.value,onValueChange:e=>{N.setValue(`importMode`,e,{shouldDirty:!0}),I(t=>({...C,...t??{},importMode:e}))},children:[g(u.Trigger,{children:g(u.Value,{placeholder:U.label.value})}),_(u.Content,{children:[g(u.Item,{value:`static`,children:U.static.value}),g(u.Item,{value:`dynamic`,children:U.dynamic.value}),g(u.Item,{value:`live`,children:U.live.value})]})]})}),_(`div`,{className:`grid grid-cols-2 gap-8 max-md:grid-cols-1`,children:[_(f.MultiSelect,{name:`projectIds`,label:B.label.value,description:B.description,onValueChange:e=>{let t=[e].flat();N.setValue(`projectIds`,t,{shouldDirty:!0}),I(e=>({...C,...e??{},projectIds:t}))},children:[g(l.Trigger,{getBadgeValue:e=>A?.find(t=>String(t.id)===e)?.name??e,children:g(l.Input,{placeholder:B.placeholder.value})}),g(l.Content,{children:g(e,{isLoading:O,children:g(l.List,{children:A?.map(e=>g(l.Item,{value:String(e.id),children:e.name},String(e.id)))})})})]}),_(f.MultiSelect,{name:`tags`,label:V.label.value,description:V.description,onValueChange:e=>{let t=[e].flat();N.setValue(`tags`,t,{shouldDirty:!0}),I(e=>({...C,...e??{},tags:t}))},children:[g(l.Trigger,{getBadgeValue:e=>j?.find(t=>String(t.key)===e)?.name??e,children:g(l.Input,{placeholder:V.placeholder.value})}),g(l.Content,{children:g(e,{isLoading:O,children:g(l.List,{children:j?.map(e=>g(l.Item,{value:String(e.key),children:e.name??e.key},String(e.key)))})})})]})]}),g(`div`,{className:`flex flex-wrap items-center justify-end gap-2 max-md:flex-col`,children:g(f.Button,{type:`button`,size:n.ICON_MD,label:G.label.value,Icon:h,variant:r.OUTLINE,color:t.TEXT,className:`max-md:w-full`,onClick:Y,disabled:P||q,isLoading:q})})]})};export{C as DictionaryDetailsForm};
|
|
2
2
|
//# sourceMappingURL=DictionaryDetailsForm.mjs.map
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = response.data.fileContent;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n filePath: newFilePath,\n }));\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n }));\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n filePath: value,\n }));\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n importMode: value as any,\n }));\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":"y+BA2BA,MAAa,GAAqD,CAChE,aACA,UACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,KAAM,EAAc,UAAW,GACrC,GAAgB,CACZ,CAAE,KAAM,GAAa,GAAY,CAEjC,EAAY,GAAc,MAAQ,EAAE,CACpC,EAAW,GAAU,MAAQ,EAAE,CAE/B,EAA0B,EAC9B,OAAO,GAAS,GAAG,CACpB,CACK,CAAE,OAAM,gBAAiBA,EAAQ,EAAyB,CAC9D,cAAe,CACb,GAAG,EACH,SAAU,EAAW,UAAY,SAClC,CACF,CAAC,CACI,CAAE,gBAAe,uBAAwB,GAAkB,CAC3D,CACJ,aACA,WACA,mBACA,eACA,aACA,iBACA,mBACA,gBACA,eACE,EAAY,qBAAqB,CAC/B,CAAE,OAAQ,EAAyB,UAAW,GAClD,GAAoC,CAChC,EACJ,IAA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AA,CACL,GAEnB,EAAC,EAAK,YAAN,CACE,KAAK,OACL,MAAO,EAAW,MAAM,MACxB,YAAa,EAAW,YACxB,cAAgB,GAAU,CACxB,IAAM,EAAa,CAAC,EAAM,CAAC,MAAM,CACjC,EAAK,SAAS,OAAQ,EAAY,CAAE,YAAa,GAAM,CAAC,CACxD,EAAqB,IAAU,CAC7B,GAAG,EACH,GAAI,GAAQ,EAAE,CACd,KAAM,EACP,EAAE,WAXP,CAcE,EAAC,EAAY,QAAb,CACE,cAAgB,GACd,GAAS,KAAM,GAAa,OAAO,EAAI,IAAI,GAAK,EAAM,EAAE,MACxD,WAGF,EAAC,EAAY,MAAb,CAAmB,YAAa,EAAW,YAAY,MAAS,CAAA,CAC5C,CAAA,CACtB,EAAC,EAAY,QAAb,CAAA,SACE,EAAC,EAAD,CAAQ,UAAW,WACjB,EAAC,EAAY,KAAb,CAAA,SACG,GAAS,IAAK,GACb,EAAC,EAAY,KAAb,CAEE,MAAO,OAAO,EAAI,IAAI,UAErB,EAAI,MAAQ,EAAI,IACA,CAJZ,OAAO,EAAI,IAAI,CAIH,CACnB,CACe,CAAA,CACZ,CAAA,CACW,CAAA,CACL,GACf,GAEN,EAAC,MAAD,CAAK,UAAU,yEACb,EAAC,EAAK,OAAN,CACE,KAAK,SACL,KAAM,EAAW,QACjB,MAAO,EAAY,MAAM,MACzB,KAAM,EACN,QAAS,EAAc,QACvB,MAAO,EAAY,KACnB,UAAU,gBACV,QAAS,EACT,SAAU,GAAgB,EAC1B,UAAW,EACX,CAAA,CACE,CAAA,CACD"}
|
|
1
|
+
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = response.data.fileContent;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n filePath: newFilePath,\n }));\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n }));\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n filePath: value,\n }));\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n importMode: value as any,\n }));\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":"y+BA2BA,MAAa,GAAqD,CAChE,aACA,UACI,CACJ,GAAM,CAAE,WAAY,GAAY,CAC1B,CAAE,WAAY,GAAW,EAAE,CAC3B,CAAE,KAAM,EAAc,UAAW,GACrC,GAAgB,CACZ,CAAE,KAAM,GAAa,GAAY,CAEjC,EAAY,GAAc,MAAQ,EAAE,CACpC,EAAW,GAAU,MAAQ,EAAE,CAE/B,EAA0B,EAC9B,OAAO,GAAS,GAAG,CACpB,CACK,CAAE,OAAM,gBA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@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Button as e,ButtonColor as t,ButtonVariant as n}from"../Button/Button.mjs";import{CopyToClipboard as r}from"../CopyToClipboard/index.mjs";import{LocaleSwitcherContentProvider as i}from"../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";import{Tab as a}from"../Tab/Tab.mjs";import{ContentEditor as o}from"./ContentEditor.mjs";import{DictionaryDetailsForm as s}from"./DictionaryDetails/DictionaryDetailsForm.mjs";import{JSONEditor as c}from"./JSONEditor.mjs";import{SaveForm as l}from"./SaveForm/SaveForm.mjs";import{StructureEditor as u}from"./StructureEditor.mjs";import{
|
|
1
|
+
"use client";import{Button as e,ButtonColor as t,ButtonVariant as n}from"../Button/Button.mjs";import{CopyToClipboard as r}from"../CopyToClipboard/index.mjs";import{LocaleSwitcherContentProvider as i}from"../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";import{Tab as a}from"../Tab/Tab.mjs";import{ContentEditor as o}from"./ContentEditor.mjs";import{DictionaryDetailsForm as s}from"./DictionaryDetails/DictionaryDetailsForm.mjs";import{JSONEditor as c}from"./JSONEditor.mjs";import{SaveForm as l}from"./SaveForm/SaveForm.mjs";import{StructureEditor as u}from"./StructureEditor.mjs";import{useEffect as d}from"react";import{ArrowLeft as f}from"lucide-react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{useIntlayer as h}from"react-intlayer";import{useConfiguration as g,useDictionariesRecordActions as _,useFocusUnmergedDictionary as v}from"@intlayer/editor-react";const y=({dictionary:y,onClickDictionaryList:b,isDarkMode:x,mode:S,onDelete:C,onSave:w,showReturnButton:T=!0})=>{let E=g(),{returnToDictionaryList:D}=h(`dictionary-field-editor`),{setFocusedContent:O}=v(),{setLocaleDictionaries:k}=_();return d(()=>{O(e=>({...e??{},dictionaryKey:y.key,dictionaryLocalId:y.localId})),k(e=>({...e,[y.localId]:y}))},[]),p(i,{availableLocales:E?.internationalization.locales??[],children:m(`div`,{className:`relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden`,children:[T&&p(e,{onClick:b,variant:n.HOVERABLE,className:`z-10 mr-auto mb-6 ml-5 shrink-0`,color:t.TEXT,Icon:f,label:D.label.value,children:D.text}),p(`div`,{className:`min-h-0 flex-1`,children:m(a,{defaultTab:`content`,variant:`ghost`,fullHeight:!0,headerClassName:`sticky top-0 z-10 rounded-xl bg-background/20 pb-4`,children:[S.includes(`remote`)&&p(a.Item,{label:`Details`,value:`details`,children:p(s,{dictionary:y,mode:S})}),p(a.Item,{label:`Structure`,value:`structure`,children:p(u,{dictionary:y})}),p(a.Item,{label:`Content`,value:`content`,children:p(o,{dictionary:y,isDarkMode:x})}),p(a.Item,{label:`JSON`,value:`json`,children:p(c,{dictionary:y,isDarkMode:x})})]})}),m(`div`,{className:`sticky bottom-16 z-20 flex shrink-0 flex-wrap items-center justify-end gap-10 border-card border-t p-4 md:bottom-0`,children:[p(r,{text:y.id,className:`text-nowrap text-neutral text-sm`,size:9,children:y.id}),p(l,{dictionary:y,mode:S,onDelete:()=>{O(null),C?.()},onSave:w})]})]})})};export{y as DictionaryFieldEditor};
|
|
2
2
|
//# sourceMappingURL=DictionaryFieldEditor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.localId!]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"sticky bottom-16 z-20 flex shrink-0 flex-wrap items-center justify-end gap-10 border-card border-t p-4 md:bottom-0\">\n <CopyToClipboard\n text={dictionary.id!}\n className=\"text-nowrap text-neutral text-sm\"\n size={9}\n >\n {dictionary.id}\n </CopyToClipboard>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n onSave={onSave}\n />\n </div>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"mappings":"83BA+BA,MAAa,GAAyD,CACpE,aACA,wBACA,aACA,OACA,WACA,SACA,mBAAmB,MACf,CACJ,IAAM,EAAS,GAAkB,CAC3B,CAAE,0BAA2B,EAAY,0BAA0B,CACnE,CAAE,qBAAsB,GAA4B,CACpD,CAAE,yBAA0B,GAA8B,CAehE,OAbA,MAAgB,CAEd,EAAmB,IAAU,CAC3B,GAAI,GAAQ,EAAE,CACd,cAAe,EAAW,IAC1B,kBAAmB,EAAW,QAC/B,EAAE,CACH,EAAuB,IAAU,CAC/B,GAAG,GACF,EAAW,SAAW,EACxB,EAAE,EACF,EAAE,CAAC,CAGJ,EAAC,EAAD,CACE,iBAAkB,GAAQ,qBAAqB,SAAW,EAAE,UAE5D,EAAC,MAAD,CAAK,UAAU,kFAAf,CACG,GACC,EAAC,EAAD,CACE,QAAS,EACT,QAAS,EAAc,UACvB,UAAU,kCACV,MAAO,EAAY,KACnB,KAAM,EACN,MAAO,EAAuB,MAAM,eAEnC,EAAuB,KACjB,CAAA,CAGX,EAAC,MAAD,CAAK,UAAU,0BACb,EAAC,EAAD,CACE,WAAW,UACX,QAAQ,QACR,WAAA,GACA,gBAAgB,8DAJlB,CAMG,EAAK,SAAS,SAAS,EACtB,EAAC,EAAI,KAAL,CAAU,MAAM,UAAU,MAAM,mBAC9B,EAAC,EAAD,CAAmC,aAAkB,OAAQ,CAAA,CACpD,CAAA,CAEb,EAAC,EAAI,KAAL,CAAU,MAAM,YAAY,MAAM,qBAChC,EAAC,EAAD,CAA6B,aAAc,CAAA,CAClC,CAAA,CACX,EAAC,EAAI,KAAL,CAAU,MAAM,UAAU,MAAM,mBAC9B,EAAC,EAAD,CAA2B,aAAwB,aAAc,CAAA,CACxD,CAAA,CACX,EAAC,EAAI,KAAL,CAAU,MAAM,OAAO,MAAM,gBAC3B,EAAC,EAAD,CAAwB,aAAwB,aAAc,CAAA,CACrD,CAAA,CACP,GACF,CAAA,CAEN,EAAC,MAAD,CAAK,UAAU,8HAAf,CACE,EAAC,EAAD,CACE,KAAM,EAAW,GACjB,UAAU,mCACV,KAAM,WAEL,EAAW,GACI,CAAA,CAClB,EAAC,EAAD,CACc,aACN,OACN,aAAgB,CACd,EAAkB,KAAK,CACvB,KAAY,EAEN,SACR,CAAA,CACE,GACF,GACwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.localId!]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"sticky bottom-16 z-20 flex shrink-0 flex-wrap items-center justify-end gap-10 border-card border-t p-4 md:bottom-0\">\n <CopyToClipboard\n text={dictionary.id!}\n className=\"text-nowrap text-neutral text-sm\"\n size={9}\n >\n {dictionary.id}\n </CopyToClipboard>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n onSave={onSave}\n />\n </div>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"mappings":"83BA+BA,MAAa,GAAyD,CACpE,aACA,wBACA,aACA,OACA,WACA,SACA,mBAAmB,MACf,CACJ,IAAM,EAAS,GAAkB,CAC3B,CAAE,0BAA2B,EAAY,0BAA0B,CACnE,CAAE,qBAAsB,GAA4B,CACpD,CAAE,yBAA0B,GAA8B,CAehE,OAbA,MAAgB,CAEd,EAAmB,IAAU,CAC3B,GAAI,GAAQ,EAAE,CACd,cAAe,EAAW,IAC1B,kBAAmB,EAAW,QAC/B,EAAE,CACH,EAAuB,IAAU,CAC/B,GAAG,GACF,EAAW,SAAW,EACxB,EAAE,EACF,EAAE,CAAC,CAGJ,EAAC,EAAD,CACE,iBAAkB,GAAQ,qBAAqB,SAAW,EAAE,UAE5D,EAAC,MAAD,CAAK,UAAU,kFAAf,CACG,GACC,EAAC,EAAD,CACE,QAAS,EACT,QAAS,EAAc,UACvB,UAAU,kCACV,MAAO,EAAY,KACnB,KAAM,EACN,MAAO,EAAuB,MAAM,eAEnC,EAAuB,KACjB,CAAA,CAGX,EAAC,MAAD,CAAK,UAAU,0BACb,EAAC,EAAD,CACE,WAAW,UACX,QAAQ,QACR,WAAA,GACA,gBAAgB,8DAJlB,CAMG,EAAK,SAAS,SAAS,EACtB,EAAC,EAAI,KAAL,CAAU,MAAM,UAAU,MAAM,mBAC9B,EAAC,EAAD,CAAmC,aAAkB,OAAQ,CAAA,CACpD,CAAA,CAEb,EAAC,EAAI,KAAL,CAAU,MAAM,YAAY,MAAM,qBAChC,EAAC,EAAD,CAA6B,aAAc,CAAA,CAClC,CAAA,CACX,EAAC,EAAI,KAAL,CAAU,MAAM,UAAU,MAAM,mBAC9B,EAAC,EAAD,CAA2B,aAAwB,aAAc,CAAA,CACxD,CAAA,CACX,EAAC,EAAI,KAAL,CAAU,MAAM,OAAO,MAAM,gBAC3B,EAAC,EAAD,CAAwB,aAAwB,aAAc,CAAA,CACrD,CAAA,CACP,GACF,CAAA,CAEN,EAAC,MAAD,CAAK,UAAU,8HAAf,CACE,EAAC,EAAD,CACE,KAAM,EAAW,GACjB,UAAU,mCACV,KAAM,WAEL,EAAW,GACI,CAAA,CAClB,EAAC,EAAD,CACc,aACN,OACN,aAAgB,CACd,EAAkB,KAAK,CACvB,KAAY,EAEN,SACR,CAAA,CACE,GACF,GACwB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":"qJAUA,MAAa,GAAmC,CAAE,aAAY,gBAAiB,CAC7E,GAAM,CAAE,mBAAkB,iBAAkB,GAAkB,CAExD,EAAe,GAAgC,CACnD,GAAI,CAEF,OADA,KAAK,MAAM,EAAW,CACf,QACQ,CACf,MAAO,KAIL,EACJ,IAAgB,EAAW,UAAW,SAAW,GAAY,QAE/D,OACE,EAAC,EAAD,CACE,SAAS,OACT,SAAW,GAAY,CACjB,EAAY,GAAW,KAAK,EAC9B,EAAiB,EAAW,QAAU,KAAK,MAAM,GAAW,KAAK,CAAC,EAG1D,sBAEX,KAAK,UAAU,EAAkB,KAAM,EAAE,CAC/B,CAAA"}
|
|
1
|
+
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":"qJAUA,MAAa,GAAmC,CAAE,aAAY,gBAAiB,CAC7E,GAAM,CAAE,mBAAkB,iBAAkB,GAAkB,CAExD,EAAe,GAAgC,CACnD,GAAI,CAEF,OADA,KAAK,MAAM,EAAW,CACf,QACQ,CACf,MAAO,KAIL,EACJ,IAAgB,EAAW,UAAW,SAAW,GAAY,QAE/D,OACE,EAAC,EAAD,CACE,SAAS,OACT,SAAW,GAAY,CACjB,EAAY,GAAW,KAAK,EAC9B,EAAiB,EAAW,QAAU,KAAK,MAAM,GAAW,KAAK,CAAC,EAG1D,sBAEX,KAAK,UAAU,EAAkB,KAAM,EAAE,CAC/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { KeyPath
|
|
1
|
+
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { FC } from 'react';\nimport { Breadcrumb, type BreadcrumbLink } from '../Breadcrumb';\nimport type { LinkColor } from '../Link';\n\ntype KeyPathBreadcrumbProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n onClickKeyPath?: (keyPath: KeyPath[]) => void;\n locale?: Locale;\n color?: LinkColor | `${LinkColor}`;\n showDictionaryKey?: boolean;\n};\n\nexport const KeyPathBreadcrumb: FC<KeyPathBreadcrumbProps> = ({\n keyPath,\n dictionaryKey,\n onClickKeyPath,\n locale,\n color,\n showDictionaryKey = true,\n}) => {\n const formattedKeyPath: BreadcrumbLink[] = [\n ...(showDictionaryKey\n ? [\n {\n text: camelCaseToSentence(dictionaryKey),\n onClick: onClickKeyPath ? () => onClickKeyPath([]) : undefined,\n },\n ]\n : []),\n ...keyPath.map((el, index) => ({\n onClick: onClickKeyPath\n ? () =>\n // With keyPath = [{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}, {type: NodeType.Object, key: '1'}]\n // If index is 0 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}])\n // If index is 1 -> onFocusKeyPath([{type: NodeType.Object, key: '0'}, {type: NodeType.Array, key: '0'}])\n onClickKeyPath?.(keyPath.slice(0, index + 1))\n : undefined,\n\n text: el.key?.toString() ?? '',\n })),\n ];\n\n return (\n <Breadcrumb\n links={formattedKeyPath}\n locale={locale}\n elementType=\"location\"\n color={color}\n />\n );\n};\n"],"mappings":"2JAgBA,MAAa,GAAiD,CAC5D,UACA,gBACA,iBACA,SACA,QACA,oBAAoB,MAyBlB,EAAC,EAAD,CACE,MAxBuC,CACzC,GAAI,EACA,CACE,CACE,KAAM,EAAoB,EAAc,CACxC,QAAS,MAAuB,EAAe,EAAE,CAAC,CAAG,IAAA,GACtD,CACF,CACD,EAAE,CACN,GAAG,EAAQ,KAAK,EAAI,KAAW,CAC7B,QAAS,MAKH,IAAiB,EAAQ,MAAM,EAAG,EAAQ,EAAE,CAAC,CAC/C,IAAA,GAEJ,KAAM,EAAG,KAAK,UAAU,EAAI,GAC7B,EAAE,CACJ,CAKW,SACR,YAAY,WACL,QACP,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Button as e,ButtonColor as t,ButtonTextAlign as n,ButtonVariant as r}from"../../Button/Button.mjs";import{Accordion as i}from"../../Accordion/Accordion.mjs";import{getIsEditableSection as a}from"../getIsEditableSection.mjs";import{ChevronRight as
|
|
1
|
+
import{Button as e,ButtonColor as t,ButtonTextAlign as n,ButtonVariant as r}from"../../Button/Button.mjs";import{Accordion as i}from"../../Accordion/Accordion.mjs";import{getIsEditableSection as a}from"../getIsEditableSection.mjs";import o from"@intlayer/config/built";import{ChevronRight as s,Plus as c}from"lucide-react";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";import{useIntlayer as f}from"react-intlayer";import{useEditedContentActions as p,useEditorLocale as m,useFocusUnmergedDictionary as h}from"@intlayer/editor-react";import{getContentNodeByKeyPath as g,getEmptyNode as _,getNodeType as v}from"@intlayer/core/dictionaryManipulator";import{NodeType as y}from"@intlayer/types/nodeType";import{isSameKeyPath as b}from"@intlayer/core/utils";import{camelCaseToSentence as x}from"@intlayer/config/client";const S=[`filePath`,`id`,`nodeType`],C=({section:S,keyPath:w,dictionary:T})=>{let{locales:E}=o.internationalization,D=g(S,w,m()),{addEditedContent:O}=p(),{setFocusedContentKeyPath:k,focusedContent:A}=h(),{addNewElement:j,goToField:M}=f(`navigation-view`),N=v(D),P=e=>(A?.keyPath?.length??0)>0&&b(e,A?.keyPath??[]),F=a(D);return D?F?u(e,{label:M.label.value,variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(w),IconRight:s,children:x(w[w.length-1].key)}):typeof D==`object`?N===y.ReactNode?u(l,{children:`React Node`}):N===y.Translation?u(`div`,{className:`flex flex-col justify-between gap-2`,children:E.map(e=>u(C,{keyPath:[...w,{type:y.Translation,key:e}],section:S,dictionary:T},e))}):N===y.Enumeration||N===y.Condition?u(`div`,{className:`flex flex-col justify-between gap-2`,children:Object.keys(D[N]).map(e=>u(C,{keyPath:[...w,{type:N,key:e}],section:S,dictionary:T},e))}):N===y.Array?d(`div`,{className:`flex flex-col justify-between gap-2`,children:[D.map((n,o)=>{let c=[...w,{type:y.Array,key:o}];return a(n)?d(e,{label:`${M.label.value} ${o}`,variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(c),IconRight:s,isActive:P(c),children:[`Item `,o]},JSON.stringify(c)):u(i,{label:`${M.label.value} ${o}`,header:`Item ${o}`,isActive:P(c),onClick:()=>k(c),children:u(`div`,{className:`mt-2 flex w-full max-w-full`,children:u(`div`,{className:`flex-1 pl-10`,children:u(C,{keyPath:c,section:S,dictionary:T})})})},JSON.stringify(c))}),u(e,{label:j.label.value,variant:r.HOVERABLE,color:t.NEUTRAL,textAlign:n.LEFT,onClick:()=>{let e=[...w,{type:y.Array,key:D.length}],t=D,n=_(t[t.length-1])??``;O(T.localId,n,e,!1),k(e)},Icon:c,children:j.text})]}):typeof D.nodeType==`string`?u(C,{keyPath:[...w,{type:D.nodeType}],section:S,dictionary:T}):u(`div`,{className:`flex w-full max-w-full flex-col justify-between gap-2`,children:Object.keys(D).map(n=>{let o=[...w,{type:y.Object,key:n}];return a(g(S,o))?u(e,{label:`${M.label.value} ${n}`,isActive:P(o),variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(o),IconRight:s,children:x(n)},n):u(i,{label:`${M.label.value} ${n}`,isActive:P(o),onClick:()=>k(o),header:x(n),children:u(`div`,{className:`mt-2 flex w-full max-w-full`,children:u(`div`,{className:`flex-1 pl-10`,children:u(C,{keyPath:o,section:S,dictionary:T})})})},n)})}):d(l,{children:[`Error loading section --`,N,`--`,JSON.stringify(D),`--`,JSON.stringify(w)]}):u(l,{})};export{C as NavigationViewNode,S as traceKeys};
|
|
2
2
|
//# sourceMappingURL=NavigationViewNode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport configuration from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport {\n type KeyPath,\n type LocalDictionaryId,\n NodeType,\n} from '@intlayer/types';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = configuration.internationalization;\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"mappings":"szBA+BA,MAAa,EAAsB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,EAAS,OAAQ,MAAK,CAC/B,CAsBD,OAnB6B,EADV,EAAwB,EAAa,EAAa,CACR,CAIzD,EAAC,EAAD,CACE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IAEnC,SAAU,EAAc,EAAa,CACrC,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAa,CACrD,UAAW,WAEV,EAAoB,EAAI,CAClB,CATF,EASE,CAKX,EAAC,EAAD,CAEE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IACnC,SAAU,EAAc,EAAa,CACrC,YAAe,EAAyB,EAAa,CACrD,OAAQ,EAAoB,EAAI,UAEhC,EAAC,MAAD,CAAK,UAAU,uCACb,EAAC,MAAD,CAAK,UAAU,wBACb,EAAC,EAAD,CACE,QAAS,EACT,QAAS,EACG,aACZ,CAAA,CACE,CAAA,CACF,CAAA,CACI,CAfL,EAeK,EAEd,CACE,CAAA,CAKR,EAAA,EAAA,CAAA,SAAA,CAAE,2BAEC,EAAS,KAET,KAAK,UAAU,EAAQ,CAAC,KAExB,KAAK,UAAU,EAAQ,CACvB,CAAA,CAAA,CArOgB,EAAA,EAAA,EAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport configuration from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { LocalDictionaryId } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = configuration.internationalization;\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"mappings":"+zBA6BA,MAAa,EAAsB,CAAC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,OAAQ,MAAK,CAC/B,CAsBD,OAnB6B,EADV,EAAwB,EAAa,EAAa,CACR,CAIzD,EAAC,EAAD,CACE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IAEnC,SAAU,EAAc,EAAa,CACrC,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,UAAU,SACV,YAAe,EAAyB,EAAa,CACrD,UAAW,WAEV,EAAoB,EAAI,CAClB,CATF,EASE,CAKX,EAAC,EAAD,CAEE,MAAO,GAAG,EAAU,MAAM,MAAM,GAAG,IACnC,SAAU,EAAc,EAAa,CACrC,YAAe,EAAyB,EAAa,CACrD,OAAQ,EAAoB,EAAI,UAEhC,EAAC,MAAD,CAAK,UAAU,uCACb,EAAC,MAAD,CAAK,UAAU,wBACb,EAAC,EAAD,CACE,QAAS,EACT,QAAS,EACG,aACZ,CAAA,CACE,CAAA,CACF,CAAA,CACI,CAfL,EAeK,EAEd,CACE,CAAA,CAKR,EAAA,EAAA,CAAA,SAAA,CAAE,2BAEC,EAAS,KAET,KAAK,UAAU,EAAQ,CAAC,KAExB,KAAK,UAAU,EAAQ,CACvB,CAAA,CAAA,CArOgB,EAAA,EAAA,EAAK,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Select as e}from"../Select/Select.mjs";import{useState as t}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useIntlayer as i}from"react-intlayer";import{getNodeType as a}from"@intlayer/core/dictionaryManipulator";import{NodeType as o}from"@intlayer/types";const s=({section:s,onValueChange:c})=>{let{multilingual:l,text:u,number:d,boolean:f,node:p,array:m,enumeration:h,triggerPlaceHolder:g,nest:_,gender:v,condition:y,markdown:b,insertion:x,reactNode:S,file:C}=i(`node-type-selector`),[w,T]=t(a(s));return r(e,{value:w,onValueChange:e=>{T(e),c(e)},children:[n(e.Trigger,{children:n(e.Value,{placeholder:g})}),r(e.Content,{children:[n(e.Item,{value:o.Translation,children:l}),n(e.Item,{value:o.Text,children:u}),n(e.Item,{value:o.Number,children:d}),n(e.Item,{value:o.Boolean,children:f}),n(e.Item,{value:o.Object,children:p}),n(e.Item,{value:o.Array,children:m}),n(e.Item,{value:o.Enumeration,children:h}),n(e.Item,{value:o.Gender,children:v}),n(e.Item,{value:o.Insertion,children:x}),n(e.Item,{value:o.Markdown,children:b}),n(e.Item,{value:o.Nested,children:_}),n(e.Item,{value:o.Condition,children:y}),n(e.Item,{value:o.ReactNode,disabled:!0,children:S}),n(e.Item,{value:o.File,children:C})]})]})};export{s as NodeTypeSelector};
|
|
1
|
+
"use client";import{Select as e}from"../Select/Select.mjs";import{useState as t}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useIntlayer as i}from"react-intlayer";import{getNodeType as a}from"@intlayer/core/dictionaryManipulator";import{NodeType as o}from"@intlayer/types/nodeType";const s=({section:s,onValueChange:c})=>{let{multilingual:l,text:u,number:d,boolean:f,node:p,array:m,enumeration:h,triggerPlaceHolder:g,nest:_,gender:v,condition:y,markdown:b,insertion:x,reactNode:S,file:C}=i(`node-type-selector`),[w,T]=t(a(s));return r(e,{value:w,onValueChange:e=>{T(e),c(e)},children:[n(e.Trigger,{children:n(e.Value,{placeholder:g})}),r(e.Content,{children:[n(e.Item,{value:o.Translation,children:l}),n(e.Item,{value:o.Text,children:u}),n(e.Item,{value:o.Number,children:d}),n(e.Item,{value:o.Boolean,children:f}),n(e.Item,{value:o.Object,children:p}),n(e.Item,{value:o.Array,children:m}),n(e.Item,{value:o.Enumeration,children:h}),n(e.Item,{value:o.Gender,children:v}),n(e.Item,{value:o.Insertion,children:x}),n(e.Item,{value:o.Markdown,children:b}),n(e.Item,{value:o.Nested,children:_}),n(e.Item,{value:o.Condition,children:y}),n(e.Item,{value:o.ReactNode,disabled:!0,children:S}),n(e.Item,{value:o.File,children:C})]})]})};export{s as NodeTypeSelector};
|
|
2
2
|
//# sourceMappingURL=NodeTypeSelector.mjs.map
|