@intlayer/design-system 8.3.3 → 8.4.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/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/BooleanWrapper.mjs +2 -0
- package/dist/esm/components/DictionaryEditor/NodeWrapper/BooleanWrapper.mjs.map +1 -0
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NumberWrapper.mjs +2 -0
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NumberWrapper.mjs.map +1 -0
- 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/ContentEditorView/TextEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +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/KeyPathBreadcrumb.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +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/Form/elements/OTPElement.mjs +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/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/Navbar/MobileNavbar.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/index.mjs +1 -1
- package/dist/esm/hooks/index.mjs +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs +1 -1
- package/dist/types/components/Badge/index.d.ts +2 -2
- package/dist/types/components/Button/Button.d.ts +3 -3
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +1 -1
- package/dist/types/components/Command/index.d.ts +2 -2
- package/dist/types/components/Container/index.d.ts +7 -7
- package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts +0 -2
- package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryEditor/NodeWrapper/BooleanWrapper.d.ts +11 -0
- package/dist/types/components/DictionaryEditor/NodeWrapper/BooleanWrapper.d.ts.map +1 -0
- package/dist/types/components/DictionaryEditor/NodeWrapper/NumberWrapper.d.ts +11 -0
- package/dist/types/components/DictionaryEditor/NodeWrapper/NumberWrapper.d.ts.map +1 -0
- package/dist/types/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
- package/dist/types/components/Input/Checkbox.d.ts +1 -1
- package/dist/types/components/Link/Link.d.ts +3 -3
- package/dist/types/components/Pagination/Pagination.d.ts +2 -2
- package/dist/types/components/SwitchSelector/index.d.ts +1 -1
- package/dist/types/components/Tab/Tab.d.ts +2 -2
- package/dist/types/components/TabSelector/TabSelector.d.ts +1 -1
- package/dist/types/components/Tag/index.d.ts +2 -2
- package/package.json +16 -16
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Button as
|
|
1
|
+
"use client";import{useUser as e}from"../../hooks/useUser/index.mjs";import{Button as t,ButtonColor as n,ButtonSize as r,ButtonVariant as i}from"../Button/Button.mjs";import{AutoCompleteTextarea as a}from"../TextArea/AutocompleteTextArea.mjs";import{useEffect as o,useState as s}from"react";import{Check as c,X as l}from"lucide-react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";const p=({children:p,onContentChange:m,disabled:h,validate:g,additionalButtons:_,...v})=>{let{isAuthenticated:y}=e(),[b,x]=s(p),[S,C]=s(0),w=b!==p,T=()=>{x(p),C(e=>e+1)},E=()=>{m(b)},D=e=>x(e.currentTarget.value??``),O=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!h&&k?(e.preventDefault(),E()):e.key===`Escape`&&(e.preventDefault(),T())};o(()=>{x(p),C(e=>e+1)},[p]);let k=g?.(b)??!0;return f(`div`,{className:`flex size-full flex-col items-center justify-between gap-2`,role:`group`,"aria-label":`Content editor textarea`,children:[d(a,{onChange:D,onKeyDown:O,variant:`invisible`,className:`size-full`,value:p,isActive:y,disabled:h,"aria-label":`Editable textarea content`,"aria-describedby":w||_?`content-editor-textarea-actions`:void 0,"aria-invalid":!k,...v},S),(w||_)&&f(`div`,{id:`content-editor-textarea-actions`,className:`flex w-full items-center justify-end gap-2`,role:`group`,"aria-label":`Edit actions`,children:[w&&f(u,{children:[d(t,{Icon:c,label:`Save changes${k?``:` (invalid content)`}`,variant:i.HOVERABLE,color:n.TEXT,size:r.ICON_SM,className:`cursor-pointer hover:scale-110`,disabled:h||!k,onClick:E,"aria-describedby":k?void 0:`textarea-validation-error`}),d(t,{Icon:l,label:`Cancel changes`,variant:i.HOVERABLE,size:r.ICON_SM,color:n.TEXT,className:`cursor-pointer hover:scale-110`,onClick:T,disabled:h})]}),_]})]},p)};export{p as ContentEditorTextArea};
|
|
2
2
|
//# sourceMappingURL=ContentEditorTextArea.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{NodeWrapper as e}from"./NodeWrapper/index.mjs";import{createElement as t}from"react";import{jsx as n}from"react/jsx-runtime";import{useEditedContent as r,useFocusUnmergedDictionary as
|
|
1
|
+
"use client";import{NodeWrapper as e}from"./NodeWrapper/index.mjs";import{createElement as t}from"react";import{jsx as n}from"react/jsx-runtime";import{useEditedContent as r,useEditorLocale as i,useFocusUnmergedDictionary as a}from"@intlayer/editor-react";const o=({dictionary:o,...s})=>{let c=i(),{editedContent:l,addEditedContent:u}=r(),{focusedContent:d,setFocusedContentKeyPath:f}=a();return n(`div`,{className:`flex flex-col gap-2`,children:t(e,{...s,keyPath:[],locale:c,dictionary:o,key:`${JSON.stringify((l?.[o.localId]??o).content)}${c}`,editedContent:l?.[o.localId]?.content,focusedKeyPath:d?.keyPath,section:o.content,onContentChange:e=>{u(o.localId,e.newValue,e.keyPath)},onFocusKeyPath:f})})};export{o as DictionaryEditor};
|
|
2
2
|
//# sourceMappingURL=DictionaryEditor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEditedContent,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type {
|
|
1
|
+
{"version":3,"file":"DictionaryEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEditedContent,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n onDelete?: () => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n ...props\n}) => {\n const locale = useEditorLocale();\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n\n return (\n <div className=\"flex flex-col gap-2\">\n <NodeWrapper\n {...props}\n keyPath={[]}\n locale={locale as Locale}\n dictionary={dictionary}\n key={`${JSON.stringify(\n (editedContent?.[dictionary.localId!] ?? dictionary).content\n )}${locale}`}\n editedContent={editedContent?.[dictionary.localId!]?.content}\n focusedKeyPath={focusedContent?.keyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(\n dictionary.localId!,\n content.newValue,\n content.keyPath\n );\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n );\n};\n"],"mappings":"gQAiBA,MAAa,GAA+C,CAC1D,aACA,GAAG,KACC,CACJ,IAAM,EAAS,GAAiB,CAC1B,CAAE,gBAAe,oBAAqB,GAAkB,CACxD,CAAE,iBAAgB,4BACtB,GAA4B,CAE9B,OACE,EAAC,MAAD,CAAK,UAAU,+BACb,EAAC,EAAD,CACE,GAAI,EACJ,QAAS,EAAE,CACH,SACI,aACZ,IAAK,GAAG,KAAK,WACV,IAAgB,EAAW,UAAa,GAAY,QACtD,GAAG,IACJ,cAAe,IAAgB,EAAW,UAAW,QACrD,eAAgB,GAAgB,QAChC,QAAS,EAAW,QACpB,gBAAkB,GAAY,CAC5B,EACE,EAAW,QACX,EAAQ,SACR,EAAQ,QACT,EAEH,eAAgB,EAChB,CAAA,CACE,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{cn as e}from"../../../utils/cn.mjs";import{SwitchSelector as t}from"../../SwitchSelector/index.mjs";import{Fragment as n,jsx as r}from"react/jsx-runtime";import{useEditorLocale as i}from"@intlayer/editor-react";import{getContentNodeByKeyPath as a}from"@intlayer/core/dictionaryManipulator";const o=({keyPath:o,section:s,editedContent:c,onContentChange:l,onFocusKeyPath:u})=>{let d=a(c,o,i());if(d!==void 0&&typeof d!=`boolean`)return r(n,{children:`Error loading section - Edited content incoherence with the original content format`});let f=o.length,p=d??s;return r(`button`,{type:`button`,className:e(`w-full rounded-md p-2 text-left transition`,`hover:bg-card/30 [&:has(.section:hover)]:bg-transparent`,f===2&&`hover:bg-card/30`,f>=3&&``),onClick:e=>{e.stopPropagation(),u(o)},children:r(t,{value:p,onChange:e=>l({keyPath:o,newValue:String(e)})})})};export{o as BooleanWrapper};
|
|
2
|
+
//# sourceMappingURL=BooleanWrapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BooleanWrapper.mjs","names":[],"sources":["../../../../../src/components/DictionaryEditor/NodeWrapper/BooleanWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { useEditorLocale } from '@intlayer/editor-react';\nimport { cn } from '@utils/cn';\nimport type { FC } from 'react';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport type { NodeWrapperProps } from './index';\n\nexport type BooleanWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: boolean;\n};\n\nexport const BooleanWrapper: FC<BooleanWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const currentLocale = useEditorLocale();\n const editedContentValue = getContentNodeByKeyPath(\n editedContent,\n keyPath,\n currentLocale\n );\n\n if (\n editedContentValue !== undefined &&\n typeof editedContentValue !== 'boolean'\n ) {\n return (\n <>\n Error loading section - Edited content incoherence with the original\n content format\n </>\n );\n }\n\n const level = keyPath.length;\n const value = editedContentValue ?? section;\n\n return (\n <button\n type=\"button\"\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <SwitchSelector\n value={value}\n onChange={(newValue) =>\n onContentChange({ keyPath, newValue: String(newValue) })\n }\n />\n </button>\n );\n};\n"],"mappings":"sTAaA,MAAa,GAA2C,CACtD,UACA,UACA,gBACA,kBACA,oBACI,CAEJ,IAAM,EAAqB,EACzB,EACA,EAHoB,GAAiB,CAKtC,CAED,GACE,IAAuB,IAAA,IACvB,OAAO,GAAuB,UAE9B,OACE,EAAA,EAAA,CAAA,SAAE,sFAGC,CAAA,CAIP,IAAM,EAAQ,EAAQ,OAChB,EAAQ,GAAsB,EAEpC,OACE,EAAC,SAAD,CACE,KAAK,SACL,UAAW,EACT,6CACA,0DACA,IAAU,GAAK,mBACf,GAAS,GAAK,GACf,CACD,QAAU,GAAM,CACd,EAAE,iBAAiB,CACnB,EAAe,EAAQ,WAGzB,EAAC,EAAD,CACS,QACP,SAAW,GACT,EAAgB,CAAE,UAAS,SAAU,OAAO,EAAS,CAAE,CAAC,CAE1D,CAAA,CACK,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ItemLayout as e}from"../ItemLayout.mjs";import{NodeWrapper as t,traceKeys as n}from"./index.mjs";import{
|
|
1
|
+
import{ItemLayout as e}from"../ItemLayout.mjs";import{NodeWrapper as t,traceKeys as n}from"./index.mjs";import{memo as r,useMemo as i}from"react";import{jsx as a}from"react/jsx-runtime";import{camelCaseToSentence as o}from"@intlayer/config/client";import{NodeType as s}from"@intlayer/types/nodeType";import{isSameKeyPath as c}from"@intlayer/core/utils";const l=r(r=>{let{keyPath:l,section:u,focusedKeyPath:d=[],onFocusKeyPath:f}=r;return i(()=>Object.keys(u??{}).filter(e=>!n.includes(e)),[u]).map(n=>{let i={key:n,type:s.Object},p=[...l,i],m=c(p,d);return a(e,{level:l.length,title:o(n),description:``,isSelected:m,onClick:e=>{e.stopPropagation(),f(m?[]:p)},children:a(t,{...r,keyPath:p,section:u[n]})},n)})});export{l as NestedObjectWrapper};
|
|
2
2
|
//# sourceMappingURL=NestedObjectWrapper.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{cn as e}from"../../../utils/cn.mjs";import{EditableFieldInput as t}from"../../EditableField/EditableFieldInput.mjs";import{Fragment as n,jsx as r}from"react/jsx-runtime";import{useEditorLocale as i}from"@intlayer/editor-react";import{getContentNodeByKeyPath as a}from"@intlayer/core/dictionaryManipulator";const o=({keyPath:o,section:s,editedContent:c,onContentChange:l,onFocusKeyPath:u})=>{let d=a(c,o,i());if(d!==void 0&&typeof d!=`number`)return r(n,{children:`Error loading section - Edited content incoherence with the original content format`});let f=o.length,p=String(d??s);return r(`button`,{type:`button`,className:e(`w-full rounded-md p-2 text-left transition`,`hover:bg-card/30 [&:has(.section:hover)]:bg-transparent`,f===2&&`hover:bg-card/30`,f>=3&&``),onClick:e=>{e.stopPropagation(),u(o)},children:r(t,{"aria-label":`Editable number field`,type:`number`,defaultValue:p,onSave:e=>l({keyPath:o,newValue:e}),onCancel:()=>null})})};export{o as NumberWrapper};
|
|
2
|
+
//# sourceMappingURL=NumberWrapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberWrapper.mjs","names":[],"sources":["../../../../../src/components/DictionaryEditor/NodeWrapper/NumberWrapper.tsx"],"sourcesContent":["import { EditableFieldInput } from '@components/EditableField';\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { useEditorLocale } from '@intlayer/editor-react';\nimport { cn } from '@utils/cn';\nimport type { FC } from 'react';\nimport type { NodeWrapperProps } from './index';\n\nexport type NumberWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: number;\n};\n\nexport const NumberWrapper: FC<NumberWrapperProps> = ({\n keyPath,\n section,\n editedContent,\n onContentChange,\n onFocusKeyPath,\n}) => {\n const currentLocale = useEditorLocale();\n const editedContentValue = getContentNodeByKeyPath(\n editedContent,\n keyPath,\n currentLocale\n );\n\n if (\n editedContentValue !== undefined &&\n typeof editedContentValue !== 'number'\n ) {\n return (\n <>\n Error loading section - Edited content incoherence with the original\n content format\n </>\n );\n }\n\n const level = keyPath.length;\n const content = String(editedContentValue ?? section);\n\n return (\n <button\n type=\"button\"\n className={cn(\n 'w-full rounded-md p-2 text-left transition',\n 'hover:bg-card/30 [&:has(.section:hover)]:bg-transparent',\n level === 2 && 'hover:bg-card/30',\n level >= 3 && ''\n )}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(keyPath);\n }}\n >\n <EditableFieldInput\n aria-label=\"Editable number field\"\n type=\"number\"\n defaultValue={content}\n onSave={(newValue) => onContentChange({ keyPath, newValue })}\n onCancel={() => null}\n />\n </button>\n );\n};\n"],"mappings":"yTAWA,MAAa,GAAyC,CACpD,UACA,UACA,gBACA,kBACA,oBACI,CAEJ,IAAM,EAAqB,EACzB,EACA,EAHoB,GAAiB,CAKtC,CAED,GACE,IAAuB,IAAA,IACvB,OAAO,GAAuB,SAE9B,OACE,EAAA,EAAA,CAAA,SAAE,sFAGC,CAAA,CAIP,IAAM,EAAQ,EAAQ,OAChB,EAAU,OAAO,GAAsB,EAAQ,CAErD,OACE,EAAC,SAAD,CACE,KAAK,SACL,UAAW,EACT,6CACA,0DACA,IAAU,GAAK,mBACf,GAAS,GAAK,GACf,CACD,QAAU,GAAM,CACd,EAAE,iBAAiB,CACnB,EAAe,EAAQ,WAGzB,EAAC,EAAD,CACE,aAAW,wBACX,KAAK,SACL,aAAc,EACd,OAAS,GAAa,EAAgB,CAAE,UAAS,WAAU,CAAC,CAC5D,aAAgB,KAChB,CAAA,CACK,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{ArrayWrapper as e}from"./ArrayWrapper.mjs";import{
|
|
1
|
+
"use client";import{ArrayWrapper as e}from"./ArrayWrapper.mjs";import{BooleanWrapper as t}from"./BooleanWrapper.mjs";import{ConditionWrapper as n}from"./ConditionWrapper.mjs";import{EnumerationWrapper as r}from"./EnumerationWrapper.mjs";import{StringWrapper as i}from"./StringWrapper.mjs";import{FileWrapper as a}from"./FileWrapper.mjs";import{HtmlWrapper as o}from"./HtmlWrapper.mjs";import{InsertionWrapper as s}from"./InsertionWrapper.mjs";import{MarkdownWrapper as c}from"./MarkdownWrapper.mjs";import{NestedObjectWrapper as l}from"./NestedObjectWrapper.mjs";import{NumberWrapper as u}from"./NumberWrapper.mjs";import{TranslationWrapper as d}from"./TranslationWrapper.mjs";import{memo as f,useMemo as p}from"react";import{jsx as m}from"react/jsx-runtime";import{useEditorLocale as h}from"@intlayer/editor-react";import{getContentNodeByKeyPath as g,getNodeType as _}from"@intlayer/core/dictionaryManipulator";import{NodeType as v}from"@intlayer/types/nodeType";const y=[`filePath`,`id`,`nodeType`],b=f(f=>{let y=h(),b=p(()=>g(f.editedContent,f.keyPath,y)??f.section,[f.editedContent,f.keyPath,f.section]),x=p(()=>_(b),[b]);if(typeof b==`object`)return x===v.ReactNode?m(`span`,{className:`text-neutral text-xs`,children:`React node not editable`}):x===v.Nested?m(`div`,{className:`ml-2 grid grid-cols-[auto,1fr] gap-2`,children:`[Nested] Dictionary`}):x===v.Markdown?m(c,{...f,section:b}):x===v.HTML?m(o,{...f,section:b}):x===v.Translation?m(d,{...f,section:b}):x===v.Enumeration?m(r,{...f,section:b}):x===v.Condition?m(n,{...f,section:b}):x===v.Insertion?m(s,{...f,section:b}):x===v.Array?m(e,{...f,section:b}):x===v.File?m(a,{...f,section:b}):m(l,{...f,section:b});if(typeof b==`string`)return m(i,{...f,section:b});if(typeof b==`number`)return m(u,{...f,section:b});if(typeof b==`boolean`)return m(t,{...f,section:b})});export{b as NodeWrapper,y as traceKeys};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useEditorLocale } 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 { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, memo, type ReactNode, useMemo } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { FileWrapper } from './FileWrapper';\nimport { HtmlWrapper } from './HtmlWrapper';\nimport { InsertionWrapper } from './InsertionWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locale;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n renderSection?: (content: string) => ReactNode;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = memo((props) => {\n const currentLocale = useEditorLocale();\n const section = useMemo(() => {\n const editedContentValue = getContentNodeByKeyPath(\n props.editedContent,\n props.keyPath,\n currentLocale\n );\n return editedContentValue ?? props.section;\n }, [props.editedContent, props.keyPath, props.section]);\n\n const nodeType = useMemo(() => getNodeType(section), [section]);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper\n {...props}\n section={section as MarkdownContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlWrapper {...props} section={section as HTMLContent<ContentNode>} />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionWrapper\n {...props}\n section={section as InsertionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return <FileWrapper {...props} section={section as FileContent} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as unknown as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n TranslationContent,\n} from '@intlayer/core/transpiler';\nimport { useEditorLocale } 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 { NodeType } from '@intlayer/types/nodeType';\nimport { type FC, memo, type ReactNode, useMemo } from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { BooleanWrapper } from './BooleanWrapper';\nimport { ConditionWrapper } from './ConditionWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { FileWrapper } from './FileWrapper';\nimport { HtmlWrapper } from './HtmlWrapper';\nimport { InsertionWrapper } from './InsertionWrapper';\nimport { MarkdownWrapper } from './MarkdownWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { NumberWrapper } from './NumberWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n section: ContentNode;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locale;\n editedContent: ContentNode;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n renderSection?: (content: string) => ReactNode;\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = memo((props) => {\n const currentLocale = useEditorLocale();\n const section = useMemo(() => {\n const editedContentValue = getContentNodeByKeyPath(\n props.editedContent,\n props.keyPath,\n currentLocale\n );\n return editedContentValue ?? props.section;\n }, [props.editedContent, props.keyPath, props.section]);\n\n const nodeType = useMemo(() => getNodeType(section), [section]);\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <span className=\"text-neutral text-xs\">React node not editable</span>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n [Nested] Dictionary\n </div>\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownWrapper\n {...props}\n section={section as MarkdownContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.HTML) {\n return (\n <HtmlWrapper {...props} section={section as HTMLContent<ContentNode>} />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionWrapper\n {...props}\n section={section as ConditionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionWrapper\n {...props}\n section={section as InsertionContent<ContentNode>}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayWrapper\n {...props}\n section={section as unknown as ContentNode[]}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return <FileWrapper {...props} section={section as FileContent} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as unknown as Record<string, ContentNode>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n\n if (typeof section === 'number') {\n return <NumberWrapper {...props} section={section} />;\n }\n\n if (typeof section === 'boolean') {\n return <BooleanWrapper {...props} section={section} />;\n }\n});\n"],"mappings":"o8BAkCA,MAAa,EAAsB,CAAC,WAAY,KAAM,WAAW,CAepD,EAAoC,EAAM,GAAU,CAC/D,IAAM,EAAgB,GAAiB,CACjC,EAAU,MACa,EACzB,EAAM,cACN,EAAM,QACN,EACD,EAC4B,EAAM,QAClC,CAAC,EAAM,cAAe,EAAM,QAAS,EAAM,QAAQ,CAAC,CAEjD,EAAW,MAAc,EAAY,EAAQ,CAAE,CAAC,EAAQ,CAAC,CAE/D,GAAI,OAAO,GAAY,SA+ErB,OA9EI,IAAa,EAAS,UAEtB,EAAC,OAAD,CAAM,UAAU,gCAAuB,0BAA8B,CAAA,CAIrE,IAAa,EAAS,OAEtB,EAAC,MAAD,CAAK,UAAU,gDAAuC,sBAEhD,CAAA,CAIN,IAAa,EAAS,SAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,KAEtB,EAAC,EAAD,CAAa,GAAI,EAAgB,UAAuC,CAAA,CAIxE,IAAa,EAAS,YAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,YAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,UAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,UAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,MAEtB,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIF,IAAa,EAAS,KACjB,EAAC,EAAD,CAAa,GAAI,EAAgB,UAA0B,CAAA,CAIlE,EAAC,EAAD,CACE,GAAI,EACK,UACT,CAAA,CAIN,GAAI,OAAO,GAAY,SACrB,OAAO,EAAC,EAAD,CAAe,GAAI,EAAgB,UAAW,CAAA,CAGvD,GAAI,OAAO,GAAY,SACrB,OAAO,EAAC,EAAD,CAAe,GAAI,EAAgB,UAAW,CAAA,CAGvD,GAAI,OAAO,GAAY,UACrB,OAAO,EAAC,EAAD,CAAgB,GAAI,EAAgB,UAAW,CAAA,EAExD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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};
|
|
1
|
+
"use client";import{renameKey as e}from"../../../utils/object.mjs";import{useAuditContentDeclarationField as t}from"../../../hooks/reactQuery.mjs";import{Container as n}from"../../Container/index.mjs";import{Button as r,ButtonColor as i,ButtonSize as a,ButtonTextAlign as o,ButtonVariant as s}from"../../Button/Button.mjs";import{InputVariant as c}from"../../Input/Input.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{useConfiguration as E,useEditedContent as D}from"@intlayer/editor-react";import{useIntlayer as O,useLocale as k}from"react-intlayer";import{getLocaleName as A}from"@intlayer/core/localization";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:n,...o})=>{let{editedContent:l,addEditedContent:u}=D(),d=E(),{mutate:f,isPending:p}=t();return w(m,{variant:c.DEFAULT,onContentChange:t=>u(n.localId,t,e),additionalButtons:w(r,{Icon:S,label:`Audit`,variant:s.HOVERABLE,size:a.ICON_SM,color:i.TEXT,className:`cursor-pointer hover:scale-110`,isLoading:p,onClick:()=>{f({fileContent:JSON.stringify({...n,...l?.[n.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 r=t.data.fileContent;u(n.localId,r,e)}catch(e){console.error(e)}}})}}),...o})},I=({keyPath:e,dictionary:t,...n})=>{let{addEditedContent:r}=D();return w(p,{variant:c.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}=D();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}=k(),{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:A(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:n,dictionary:a,renderSection:c})=>{let{addEditedContent:l}=D(),{addNewEnumeration:u,removeEnumeration:d}=O(`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(i=>{let o=[...n,{type:N.Enumeration,key:i}],s=`${JSON.stringify(n)}-enumeration-${i}`;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(r,{label:d.label.value,variant:`hoverable`,size:`sm`,color:`error`,className:`ml-auto text-neutral hover:text-error`,Icon:x,onClick:()=>l(a.localId,void 0,o),children:d.text})})})}),w(`tr`,{className:`w-full p-2`,children:w(`td`,{className:`flex w-full`,children:w(_,{value:i,onChange:r=>{let o=t[N.Enumeration],s=e(o,i,r),c={...t,[N.Enumeration]:s};console.log(`newValue`,c),l(a.localId,c,n)}})})}),w(`tr`,{className:`block w-full`,children:w(`td`,{className:`flex w-full`,children:w(Q,{section:f[i]??j(f[p]),keyPath:o,dictionary:a,renderSection:c})})})]},s)})})}),w(r,{label:u.label.value,variant:s.HOVERABLE,color:i.NEUTRAL,textAlign:o.LEFT,isFullWidth:!0,onClick:()=>l(a.localId,j(f[p])??``,[...n,{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:n,renderSection:a})=>{let{addEditedContent:c}=D(),{addNewElement:l,removeElement:u}=O(`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((i,o)=>{let s=`${JSON.stringify(t)}-array-${o}`;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(o)}),w(r,{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:o}];c(n.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:i??j(e[0]),keyPath:[...t,{type:N.Array,key:o}],dictionary:n,renderSection:a})})})]},s)})})}),w(r,{label:l.label.value,variant:s.HOVERABLE,color:i.NEUTRAL,textAlign:o.LEFT,isFullWidth:!0,onClick:()=>{let r=[...t,{type:N.Array,key:e.length}];c(n.localId,j(e[0])??``,r,!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}=D(),o=r[N.Nested],s=[...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:c.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...o,dictionaryKey:String(e)},s)},children:o.dictionaryKey??``}),w(h,{children:`Path (optional)`}),w(p,{"aria-label":`Edit field`,type:`text`,variant:c.DEFAULT,...i,onContentChange:e=>{a(t.localId,{...o,path:e===``?void 0:e},s)},children:o.path??``})]})},Q=({section:e,keyPath:t,dictionary:n,renderSection:r,isDarkMode:i})=>{let{tsxNotEditable:a}=O(`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:c.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(n,{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 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,EAA8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X,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,GAAe,qBAAqB,SAAW,EAAE,CAC1D,UAAW,CACT,OAAQ,GAAe,IAAI,OAC3B,MAAO,GAAe,IAAI,MAC1B,YAAa,GAAe,IAAI,YACjC,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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ACH,UACA,UACG,aACZ,CAAA,CAIF,IAAa,EAAS,KAEtB,EAAC,EAAD,CACc,aACH,UACA,UACT,CAAA,CAIF,IAAa,EAAS,KAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,MAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,OAEtB,EAAC,EAAD,CACc,aACG,gBACN,UACA,UACT,CAAA,CAIF,IAAa,EAAS,OAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,KAAK,SACL,aAAW,sBAEV,EACkB,CAAA,CACjB,CAAA,CAIN,IAAa,EAAS,KAEtB,EAAC,MAAD,CAAK,UAAU,sBACZ,OAAO,GAAkB,WACxB,EAAc,EAAkB,CAEhC,EAAC,EAAD,CACE,QAAS,EAAa,QACtB,aAAW,aACF,UACG,sBAEX,EACqB,CAAA,CAEtB,CAAA,CAIN,IAAa,EAAS,QAEtB,EAAC,MAAD,CAAK,UAAU,sBACb,EAAC,EAAD,CACc,aACH,UACT,MAAO,EACP,CAAA,CACE,CAAA,CAKR,EAAC,MAAD,CAAK,UAAU,sBAAf,CAA4B,+BAEzB,KAAK,UAAU,EAAS,KAAM,EAAE,CAChC,KAAK,UAAU,EAAS,KAAM,EAAE,CAAC,cACtB,EACR,IAIG,EAA4C,GACvD,EAAC,EAAD,CACE,OAAA,GACA,WAAW,OACX,UAAU,wEACV,YAAY,cAEZ,EAAC,EAAD,CAAY,GAAI,EAAS,CAAA,CACf,CAAA"}
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useSession as e}from"../../../hooks/useAuth/useSession.mjs";import{useAddDictionary as t,useGetProjects as n}from"../../../hooks/reactQuery.mjs";import{ButtonColor as r}from"../../Button/Button.mjs";import{MultiSelect as i}from"../../Select/Multiselect.mjs";import{useForm as a}from"../../Form/FormBase.mjs";import{Form as o}from"../../Form/Form.mjs";import{useDictionarySchema as s}from"./useDictionaryFormSchema.mjs";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{useIntlayer as u}from"react-intlayer";const d=({onDictionaryCreated:d})=>{let{session:f}=e(),{project:p}=f??{},{mutate:m,isPending:h}=t(),{data:g}=n(),_=s(String(p?.id)),{form:v,isSubmitting:y}=a(_),{keyInput:b,createDictionaryButton:x,projectInput:S}=u(`dictionary-form`);return l(o,{schema:_,onSubmitSuccess:e=>{m({dictionary:e},{onSuccess:()=>{d?.()}})},className:`m-auto w-full max-w-[400px]`,...v,children:[c(o.Input,{name:`key`,label:b.label.value,placeholder:b.placeholder.value,isRequired:!0}),l(o.MultiSelect,{name:`projectIds`,label:S.label.value,children:[c(i.Trigger,{getBadgeValue:e=>g?.data?.find(t=>String(t.id)===e)?.name??e,children:c(i.Input,{placeholder:S.placeholder.value})}),c(i.Content,{children:c(i.List,{children:g?.data?.map(e=>c(i.Item,{value:String(e.id),children:e.name},String(e.id)))})})]}),c(o.Button,{className:`mt-12 ml-auto`,type:`submit`,color:r.TEXT,isLoading:y||h,label:x.ariaLabel.value,isFullWidth:!0,children:x.text})]})};export{d as DictionaryCreationForm};
|
|
2
2
|
//# sourceMappingURL=DictionaryCreationForm.mjs.map
|
package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useSession as e}from"../../../hooks/useAuth/useSession.mjs";import{useAuditContentDeclarationMetadata as t,useGetProjects as n,useGetTags as r}from"../../../hooks/reactQuery.mjs";import{Loader as i}from"../../Loader/index.mjs";import{ButtonColor as a,ButtonSize as o,ButtonVariant as s}from"../../Button/Button.mjs";import{Checkbox as c}from"../../Input/Checkbox.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{useEditedContent as v}from"@intlayer/editor-react";import{useIntlayer as y}from"react-intlayer";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}=e(),{project:E}=T??{},{data:D,isLoading:O}=n(),{data:k}=r(),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}=v(),{titleInput:L,keyInput:R,descriptionInput:z,projectInput:B,tagsSelect:V,locationSelect:H,importModeSelect:U,filePathInput:W,auditButton:G}=y(`dictionary-details`),{mutate:K,isPending:q}=t(),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`,i=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}))},a=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(c,{id:`location-local`,name:`location-local`,label:H.local.value,checked:n,disabled:!w.includes(`local`)&&!w.includes(`remote`),onChange:e=>i(e.target.checked)}),g(c,{id:`location-remote`,name:`location-remote`,label:H.remote.value,checked:r,disabled:!w.includes(`remote`)&&C.location!==`remote`&&C.location!==`hybrid`,onChange:e=>a(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(i,{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(i,{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:o.ICON_MD,label:G.label.value,Icon:h,variant:s.OUTLINE,color:a.TEXT,className:`max-md:w-full`,onClick:Y,disabled:P||q,isLoading:q})})]})};export{C as DictionaryDetailsForm};
|
|
2
2
|
//# sourceMappingURL=DictionaryDetailsForm.mjs.map
|
|
@@ -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{useEffect as d}from"react";import{ArrowLeft as f}from"lucide-react";import{jsx as p,jsxs as m}from"react/jsx-runtime";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{useConfiguration as h,useDictionariesRecordActions as g,useFocusUnmergedDictionary as _}from"@intlayer/editor-react";import{useIntlayer as v}from"react-intlayer";const y=({dictionary:y,onClickDictionaryList:b,isDarkMode:x,mode:S,onDelete:C,onSave:w,showReturnButton:T=!0})=>{let E=h(),{returnToDictionaryList:D}=v(`dictionary-field-editor`),{focusedContent:O,setFocusedContent:k}=_(),{setLocaleDictionary:A}=g();return d(()=>{k({...O??{},dictionaryKey:y.key,dictionaryLocalId:y.localId}),A(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:()=>{k(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/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 {
|
|
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 { focusedContent, setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionary } = useDictionariesRecordActions();\n\n useEffect(() => {\n setFocusedContent({\n ...(focusedContent ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n });\n setLocaleDictionary(dictionary);\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,iBAAgB,qBAAsB,GAA4B,CACpE,CAAE,uBAAwB,GAA8B,CAW9D,OATA,MAAgB,CACd,EAAkB,CAChB,GAAI,GAAkB,EAAE,CACxB,cAAe,EAAW,IAC1B,kBAAmB,EAAW,QAC/B,CAAC,CACF,EAAoB,EAAW,EAC9B,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,2 +1,2 @@
|
|
|
1
|
-
import{Breadcrumb as e}from"../Breadcrumb/index.mjs";import{
|
|
1
|
+
import{Breadcrumb as e}from"../Breadcrumb/index.mjs";import{jsx as t}from"react/jsx-runtime";import{camelCaseToSentence as n}from"@intlayer/config/client";const r=({keyPath:r,dictionaryKey:i,onClickKeyPath:a,locale:o,color:s,showDictionaryKey:c=!0})=>t(e,{links:[...c?[{text:n(i),onClick:a?()=>a([]):void 0}]:[],...r.map((e,t)=>({onClick:a?()=>a?.(r.slice(0,t+1)):void 0,text:e.key?.toString()??``}))],locale:o,elementType:`location`,color:s});export{r as KeyPathBreadcrumb};
|
|
2
2
|
//# sourceMappingURL=KeyPathBreadcrumb.mjs.map
|
|
@@ -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
|
|
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 o,Plus as s}from"lucide-react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import d from"@intlayer/config/built";import{camelCaseToSentence as f}from"@intlayer/config/client";import{useEditedContentActions as p,useEditorLocale as m,useFocusUnmergedDictionary as h}from"@intlayer/editor-react";import{useIntlayer as g}from"react-intlayer";import{getContentNodeByKeyPath as _,getEmptyNode as v,getNodeType as y}from"@intlayer/core/dictionaryManipulator";import{NodeType as b}from"@intlayer/types/nodeType";import{isSameKeyPath as x}from"@intlayer/core/utils";const S=[`filePath`,`id`,`nodeType`],C=({section:S,keyPath:w,dictionary:T})=>{let{locales:E}=d.internationalization,D=_(S,w,m()),{addEditedContent:O}=p(),{setFocusedContentKeyPath:k,focusedContent:A}=h(),{addNewElement:j,goToField:M}=g(`navigation-view`),N=y(D),P=e=>(A?.keyPath?.length??0)>0&&x(e,A?.keyPath??[]),F=a(D);return D?F?l(e,{label:M.label.value,variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(w),IconRight:o,children:f(w[w.length-1].key)}):typeof D==`object`?N===b.ReactNode?l(c,{children:`React Node`}):N===b.Translation?l(`div`,{className:`flex flex-col justify-between gap-2`,children:E.map(e=>l(C,{keyPath:[...w,{type:b.Translation,key:e}],section:S,dictionary:T},e))}):N===b.Enumeration||N===b.Condition?l(`div`,{className:`flex flex-col justify-between gap-2`,children:Object.keys(D[N]).map(e=>l(C,{keyPath:[...w,{type:N,key:e}],section:S,dictionary:T},e))}):N===b.Array?u(`div`,{className:`flex flex-col justify-between gap-2`,children:[D.map((n,s)=>{let c=[...w,{type:b.Array,key:s}];return a(n)?u(e,{label:`${M.label.value} ${s}`,variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(c),IconRight:o,isActive:P(c),children:[`Item `,s]},JSON.stringify(c)):l(i,{label:`${M.label.value} ${s}`,header:`Item ${s}`,isActive:P(c),onClick:()=>k(c),children:l(`div`,{className:`mt-2 flex w-full max-w-full`,children:l(`div`,{className:`flex-1 pl-10`,children:l(C,{keyPath:c,section:S,dictionary:T})})})},JSON.stringify(c))}),l(e,{label:j.label.value,variant:r.HOVERABLE,color:t.NEUTRAL,textAlign:n.LEFT,onClick:()=>{let e=[...w,{type:b.Array,key:D.length}],t=D,n=v(t[t.length-1])??``;O(T.localId,n,e,!1),k(e)},Icon:s,children:j.text})]}):typeof D.nodeType==`string`?l(C,{keyPath:[...w,{type:D.nodeType}],section:S,dictionary:T}):l(`div`,{className:`flex w-full max-w-full flex-col justify-between gap-2`,children:Object.keys(D).map(n=>{let s=[...w,{type:b.Object,key:n}];return a(_(S,s))?l(e,{label:`${M.label.value} ${n}`,isActive:P(s),variant:r.HOVERABLE,color:t.TEXT,className:`w-full`,onClick:()=>k(s),IconRight:o,children:f(n)},n):l(i,{label:`${M.label.value} ${n}`,isActive:P(s),onClick:()=>k(s),header:f(n),children:l(`div`,{className:`mt-2 flex w-full max-w-full`,children:l(`div`,{className:`flex-1 pl-10`,children:l(C,{keyPath:s,section:S,dictionary:T})})})},n)})}):u(c,{children:[`Error loading section --`,N,`--`,JSON.stringify(D),`--`,JSON.stringify(w)]}):l(c,{})};export{C as NavigationViewNode,S as traceKeys};
|
|
2
2
|
//# sourceMappingURL=NavigationViewNode.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../../../utils/cn.mjs";import{
|
|
1
|
+
"use client";import{cn as e}from"../../../utils/cn.mjs";import{useAuth as t}from"../../../hooks/useAuth/useAuth.mjs";import{useDeleteDictionary as n,usePushDictionaries as r,useWriteDictionary as i}from"../../../hooks/reactQuery.mjs";import{ButtonColor as a,ButtonVariant as o}from"../../Button/Button.mjs";import{Modal as s,ModalSize as c}from"../../Modal/Modal.mjs";import{Form as l}from"../../Form/Form.mjs";import{useState as u}from"react";import{ArrowUpFromLine as d,Download as f,RotateCcw as p,Save as m,Trash as h}from"lucide-react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{useDictionariesRecordActions as y,useEditedContent as b}from"@intlayer/editor-react";import{useIntlayer as x}from"react-intlayer";const S=({dictionary:S,mode:C,className:w,onDelete:T,onSave:E,...D})=>{let[O,k]=u(!1),{setLocaleDictionary:A}=y(),{mutate:j,isPending:M}=n(),{mutate:N,isPending:P}=i(),{mutate:F,isPending:I}=r(),L=P||I,{editedContent:R,restoreEditedContent:z}=b(),{deleteButton:B,resetButton:V,saveButton:H,publishButton:U,downloadButton:W,confirmation:G}=x(`save-dictionary-details`),{isAuthenticated:K}=t(),q=R?.[S.localId],J=q&&JSON.stringify(q)!==JSON.stringify(S),Y=S?.id!==void 0,X=async()=>{R?.[S.localId]&&N({dictionary:{...S,...R?.[S.localId]}},{onSuccess:()=>{A(R?.[S.localId]),z(S.localId),k(!1),E?.()}})},Z=()=>{let e={...S,...R?.[S.localId]};F({dictionaries:[e]},{onSuccess:t=>{t&&(A(e),z(S.localId),E?.())}})},Q=()=>{S.id&&j({dictionaryId:S.id},{onSuccess:e=>{e&&T?.()}})};return v(g,{children:[_(s,{isOpen:O,title:G.title.value,size:c.MD,onClose:()=>k(!1),padding:`md`,children:v(`form`,{className:`size-full`,children:[_(`p`,{className:`py-4 text-neutral text-sm`,children:G.message}),v(`div`,{className:`mt-12 flex justify-end gap-2 max-md:flex-col`,children:[_(l.Button,{label:G.cancelButton.label.value,disabled:!J||L,color:a.TEXT,className:`max-md:w-full`,variant:o.OUTLINE,onClick:()=>k(!1),children:G.cancelButton.text}),_(l.Button,{label:G.confirmButton.label.value,disabled:!J||L,Icon:m,color:a.TEXT,className:`max-md:w-full`,isLoading:I,onClick:X,children:G.confirmButton.text})]})]})}),v(`form`,{className:e(`flex justify-end gap-2 max-md:flex-col`,w),...D,children:[C.includes(`remote`)&&Y&&T&&K&&_(l.Button,{label:B.label.value,Icon:h,color:a.ERROR,variant:o.OUTLINE,className:`max-md:w-full`,isLoading:M,onClick:Q,children:B.text}),J&&_(l.Button,{label:V.label.value,disabled:!J,Icon:p,variant:o.OUTLINE,color:a.TEXT,className:`max-md:w-full`,onClick:()=>z(S.localId),children:V.text}),C.includes(`local`)&&_(l.Button,{label:W.label.value,disabled:!J||L,Icon:f,color:a.TEXT,variant:K?o.OUTLINE:o.DEFAULT,className:`max-md:w-full`,isLoading:P,onClick:()=>k(!0),children:W.text}),C.includes(`remote`)&&K&&!Y&&_(l.Button,{label:U.label.value,disabled:L,Icon:d,color:a.TEXT,className:`max-md:w-full`,isLoading:I,onClick:Z,children:U.text}),C.includes(`remote`)&&K&&Y&&J&&_(l.Button,{label:H.label.value,disabled:!J||L,Icon:m,color:`text`,className:`max-md:w-full`,isLoading:I,onClick:Z,children:H.text})]})]})};export{S as SaveForm};
|
|
2
2
|
//# sourceMappingURL=SaveForm.mjs.map
|
|
@@ -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,ButtonVariant as i}from"../../Button/Button.mjs";import{InputVariant as a}from"../../Input/Input.mjs";import{EditableFieldInput as o}from"../../EditableField/EditableFieldInput.mjs";import{NodeTypeSelector as s}from"../NodeTypeSelector.mjs";import{
|
|
1
|
+
"use client";import{Container as e}from"../../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonSize as r,ButtonVariant as i}from"../../Button/Button.mjs";import{InputVariant as a}from"../../Input/Input.mjs";import{EditableFieldInput as o}from"../../EditableField/EditableFieldInput.mjs";import{NodeTypeSelector as s}from"../NodeTypeSelector.mjs";import{Plus as c,Trash as l}from"lucide-react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";import{camelCaseToSentence as p}from"@intlayer/config/client";import{useConfiguration as m,useEditedContentActions as h,useFocusUnmergedDictionary as g}from"@intlayer/editor-react";import{useIntlayer as _}from"react-intlayer";import{getDefaultNode as v,getNodeChildren as y,getNodeType as b}from"@intlayer/core/dictionaryManipulator";import{NodeType as x}from"@intlayer/types/nodeType";import{isSameKeyPath as S}from"@intlayer/core/utils";const C=({section:e,dictionaryLocalId:t,keyPath:n,onNodeTypeChange:r})=>{let i=m()?.internationalization.locales??[],a=b(e),o=y(e),c=e=>{r(v(a,i,e))};if(a===x.Translation||a===x.Condition||a===x.Gender||a===x.Enumeration){let l=Object.keys(e[a])[0],u=[...n,{type:a,key:l}];return f(`div`,{className:`flex w-full flex-col gap-1`,children:[d(s,{section:e,onValueChange:e=>r(v(e,i))}),d(C,{section:o,keyPath:u,dictionaryLocalId:t,onNodeTypeChange:c})]})}if(a===x.Array){let l=[...n,{type:a,key:0}];return f(`div`,{className:`flex w-full flex-col gap-1`,children:[d(s,{section:e,onValueChange:e=>r(v(e,i))}),d(C,{section:o,keyPath:l,dictionaryLocalId:t,onNodeTypeChange:c})]})}return a===x.Object?f(u,{children:[d(s,{section:e,onValueChange:e=>r(v(e,i))}),d(`div`,{className:`mt-6 ml-10`,children:d(E,{keyPath:n,section:e,dictionaryLocalId:t})})]}):d(s,{section:e,onValueChange:e=>r(v(e,i))})},w=({sectionKey:s,section:c,keyPath:u,dictionaryLocalId:m})=>{let{focusedContent:v,setFocusedContentKeyPath:y}=g(),{renameEditedContent:b,addEditedContent:x}=h(),{titleInput:w,deleteButton:T}=_(`structure-view`),E=e=>{b(m,e,u);let t=u.slice(0,-1),n=u[u.length-1];y([...t,{...n,key:e}])};return d(e,{transparency:`xl`,roundedSize:`xl`,className:`w-full min-w-80 gap-2 overflow-auto px-5 py-2`,border:!0,borderColor:`text`,background:`none`,"aria-selected":S(u,v?.keyPath??[]),onClick:()=>y(u),children:f(`div`,{className:`flex w-full flex-col items-start justify-between gap-3`,children:[typeof s==`string`&&f(`div`,{className:`w-full`,children:[f(`div`,{className:`flex w-full items-center justify-between gap-10`,children:[d(o,{name:`key`,"aria-label":`Key`,placeholder:w.placeholder.value,defaultValue:s,onSave:e=>E(e),variant:a.INVISIBLE}),d(t,{label:T.label.value,variant:i.HOVERABLE,size:r.ICON_SM,color:n.TEXT,className:`translate-x-2`,Icon:l,onClick:()=>{x(m,void 0,u),y(u.slice(0,-1))}})]}),f(`span`,{className:`ml-3 text-neutral text-sm`,children:[`( `,p(s),` )`]})]}),d(C,{keyPath:u,dictionaryLocalId:m,section:c,onNodeTypeChange:e=>{x(m,e,u)}})]})})},T=({section:e,keyPath:a,dictionaryLocalId:o})=>{let{addNodeButton:s}=_(`structure-view`),{setFocusedContentKeyPath:l}=g(),{addEditedContent:u}=h();return!e||typeof e!=`object`?d(`div`,{children:`Not an object`}):f(`div`,{className:`flex flex-col gap-2 overflow-y-auto`,children:[d(`ul`,{className:`mr-auto flex flex-col gap-4`,children:Object.keys(e).map(t=>d(`li`,{className:`flex w-full`,children:d(w,{sectionKey:t,section:e?.[t],keyPath:[...a,{type:x.Object,key:t}],dictionaryLocalId:o})},`${JSON.stringify(a)}-object-${t}`))}),d(t,{label:s.label.value,variant:i.HOVERABLE,size:r.MD,color:n.TEXT,Icon:c,className:`flex-1`,onClick:()=>{let e=[...a,{type:x.Object,key:`newKey`}];u(o,``,e),l(e)},children:s.text})]})},E=({section:e,keyPath:t,dictionaryLocalId:n})=>!e||typeof e!=`object`||typeof e.nodeType==`string`?d(w,{sectionKey:`content`,section:e,keyPath:t,dictionaryLocalId:n}):d(T,{section:e,keyPath:t,dictionaryLocalId:n});export{w as NodeView,T as ObjectView,E as StructureView};
|
|
2
2
|
//# sourceMappingURL=StructureView.mjs.map
|