@intlayer/design-system 5.1.1 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +9 -9
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
- package/dist/components/Container/index.cjs +4 -1
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +1 -1
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs +4 -1
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +13 -3
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +13 -3
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs +9 -4
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs +9 -4
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +47 -12
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +47 -12
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts +5 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +1 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.cjs +6 -16
- package/dist/components/DictionaryFieldEditor/StructureEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.mjs +7 -17
- package/dist/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +6 -5
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +7 -0
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +9 -8
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +3 -2
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/components/MarkDownRender/index.cjs.map +1 -1
- package/dist/components/MarkDownRender/index.d.ts +1 -1
- package/dist/components/MarkDownRender/index.d.ts.map +1 -1
- package/dist/components/MarkDownRender/index.mjs.map +1 -1
- package/dist/{index-BKE0uywA.js → index-BTDHuTxL.js} +2 -2
- package/dist/index-BTDHuTxL.js.map +1 -0
- package/dist/{index-CsenS2hX.cjs → index-Db5Dym4h.cjs} +2 -2
- package/dist/index-Db5Dym4h.cjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/package.json +20 -20
- package/dist/index-BKE0uywA.js.map +0 -1
- package/dist/index-CsenS2hX.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n isDarkMode?: boolean;\n mode: 'local' | 'remote';\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-1 flex-col gap-10\">\n <div className=\"flex items-center gap-2\">\n <Button\n onClick={() => onClickDictionaryList?.()}\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n id=\"return-to-dictionary-list\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n />\n <label\n className=\"cursor-pointer text-xs hover:underline\"\n htmlFor=\"return-to-dictionary-list\"\n >\n {returnToDictionaryList.text}\n </label>\n </div>\n\n <Container\n className=\"flex size-full justify-center gap-10 p-6\"\n roundedSize=\"xl\"\n >\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(mode === 'local' && value === EditorViewType.DetailsEditor)\n )}\n />\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n <SaveForm dictionary={dictionary} mode={mode} />\n </Container>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":["useConfiguration","useState","useDictionary","dictionaryFieldEditorContent","useFocusDictionaryActions","useDictionariesRecordActions","useEffect","jsx","LocaleSwitcherContentProvider","jsxs","Button","ArrowLeft","Container","SwitchSelector","DictionaryDetailsForm","StructureEditor","ContentEditor","JSONEditor","SaveForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAASA,YAAAA,iBAAiB;AAC1B,QAAA,CAAC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AA,kBACd,UAAU,CAAC,UAAU,cAAc,KAAK;AAAA,kBACxC,OAAM;AAAA,kBACN,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS;AAAA,oBACP;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBAAA;AAAA,kBACT,EACA;AAAA,oBACA,CAAC,EAAE,MAAA,MACD,EAAE,SAAS,WAAW,UAAU;AAAA,kBAAA;AAAA,gBACpC;AAAA,cACF;AAAA,cACC,eAAe,KACbN,2BAAA,IAAAO,yEAAA,uBAAA,EAAsB,YAAwB,MAAY;AAAA,cAE5D,eAAe,KACbP,2BAAAA,IAAAQ,iDAAAA,iBAAA,EAAgB,WAAwB,CAAA;AAAA,cAE1C,eAAe,KACbR,
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n isDarkMode?: boolean;\n mode: 'local' | 'remote';\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-1 flex-col gap-10\">\n <div className=\"flex items-center gap-2\">\n <Button\n onClick={() => onClickDictionaryList?.()}\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n id=\"return-to-dictionary-list\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n />\n <label\n className=\"cursor-pointer text-xs hover:underline\"\n htmlFor=\"return-to-dictionary-list\"\n >\n {returnToDictionaryList.text}\n </label>\n </div>\n\n <Container\n className=\"flex size-full justify-center gap-10 p-6\"\n roundedSize=\"xl\"\n >\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(mode === 'local' && value === EditorViewType.DetailsEditor)\n )}\n />\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n <SaveForm dictionary={dictionary} mode={mode} />\n </Container>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":["useConfiguration","useState","useDictionary","dictionaryFieldEditorContent","useFocusDictionaryActions","useDictionariesRecordActions","useEffect","jsx","LocaleSwitcherContentProvider","jsxs","Button","ArrowLeft","Container","SwitchSelector","DictionaryDetailsForm","StructureEditor","ContentEditor","JSONEditor","SaveForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAASA,YAAAA,iBAAiB;AAC1B,QAAA,CAAC,YAAY,aAAa,IAAIC,aAAA;AAAA,IAClC;AAAA;AAAA,EACF;AACM,QAAA,EAAE,2BAA2BC,cAAA;AAAA,IACjCC,+DAAAA;AAAAA,EACF;AACM,QAAA,EAAE,kBAAkB,IAAIC,sCAA0B;AAClD,QAAA,EAAE,sBAAsB,IAAIC,yCAA6B;AAE/DC,eAAAA,UAAU,MAAM;AAEd,sBAAkB,CAAC,UAAU;AAAA,MAC3B,GAAI,QAAQ,CAAC;AAAA,MACb,eAAe,WAAW;AAAA,IAAA,EAC1B;AACF,0BAAsB,CAAC,UAAU;AAAA,MAC/B,GAAG;AAAA,MACH,CAAC,WAAW,GAAG,GAA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AC,EAAE,MAAA,MACD,EAAE,SAAS,WAAW,UAAU;AAAA,kBAAA;AAAA,gBACpC;AAAA,cACF;AAAA,cACC,eAAe,KACbN,2BAAA,IAAAO,yEAAA,uBAAA,EAAsB,YAAwB,MAAY;AAAA,cAE5D,eAAe,KACbP,2BAAAA,IAAAQ,iDAAAA,iBAAA,EAAgB,WAAwB,CAAA;AAAA,cAE1C,eAAe,KACbR,2BAAA,IAAAS,+CAAA,eAAA,EAAc,YAAwB,YAAwB;AAAA,cAEhE,eAAe,KACbT,2BAAA,IAAAU,4CAAA,YAAA,EAAW,YAAwB,YAAwB;AAAA,cAE9DV,2BAAAA,IAACW,mDAAS,UAAA,EAAA,YAAwB,KAAY,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAChD,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
|
|
@@ -121,7 +121,7 @@ const DictionaryFieldEditor = ({
|
|
|
121
121
|
),
|
|
122
122
|
editorView === 0 && /* @__PURE__ */ jsx(DictionaryDetailsForm, { dictionary, mode }),
|
|
123
123
|
editorView === 2 && /* @__PURE__ */ jsx(StructureEditor, { dictionary }),
|
|
124
|
-
editorView === 1 && /* @__PURE__ */ jsx(ContentEditor, { dictionary }),
|
|
124
|
+
editorView === 1 && /* @__PURE__ */ jsx(ContentEditor, { dictionary, isDarkMode }),
|
|
125
125
|
editorView === 3 && /* @__PURE__ */ jsx(JSONEditor, { dictionary, isDarkMode }),
|
|
126
126
|
/* @__PURE__ */ jsx(SaveForm, { dictionary, mode })
|
|
127
127
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n isDarkMode?: boolean;\n mode: 'local' | 'remote';\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-1 flex-col gap-10\">\n <div className=\"flex items-center gap-2\">\n <Button\n onClick={() => onClickDictionaryList?.()}\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n id=\"return-to-dictionary-list\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n />\n <label\n className=\"cursor-pointer text-xs hover:underline\"\n htmlFor=\"return-to-dictionary-list\"\n >\n {returnToDictionaryList.text}\n </label>\n </div>\n\n <Container\n className=\"flex size-full justify-center gap-10 p-6\"\n roundedSize=\"xl\"\n >\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(mode === 'local' && value === EditorViewType.DetailsEditor)\n )}\n />\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n <SaveForm dictionary={dictionary} mode={mode} />\n </Container>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAAS,iBAAiB;AAC1B,QAAA,CAAC,YAAY,aAAa,IAAI;AAAA,IAClC;AAAA;AAAA,EACF;AACM,QAAA,EAAE,2BAA2B;AAAA,IACjC;AAAA,EACF;AACM,QAAA,EAAE,kBAAkB,IAAI,0BAA0B;AAClD,QAAA,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AAEd,sBAAkB,CAAC,UAAU;AAAA,MAC3B,GAAI,QAAQ,CAAC;AAAA,MACb,eAAe,WAAW;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CAAC,EAAE,MAAA,MACD,EAAE,SAAS,WAAW,UAAU;AAAA,kBAAA;AAAA,gBACpC;AAAA,cACF;AAAA,cACC,eAAe,KACb,oBAAA,uBAAA,EAAsB,YAAwB,MAAY;AAAA,cAE5D,eAAe,KACb,oBAAA,iBAAA,EAAgB,WAAwB,CAAA;AAAA,cAE1C,eAAe,KACb,oBAAA,eAAA,EAAc,
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n isDarkMode?: boolean;\n mode: 'local' | 'remote';\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-1 flex-col gap-10\">\n <div className=\"flex items-center gap-2\">\n <Button\n onClick={() => onClickDictionaryList?.()}\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n id=\"return-to-dictionary-list\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n />\n <label\n className=\"cursor-pointer text-xs hover:underline\"\n htmlFor=\"return-to-dictionary-list\"\n >\n {returnToDictionaryList.text}\n </label>\n </div>\n\n <Container\n className=\"flex size-full justify-center gap-10 p-6\"\n roundedSize=\"xl\"\n >\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(mode === 'local' && value === EditorViewType.DetailsEditor)\n )}\n />\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n <SaveForm dictionary={dictionary} mode={mode} />\n </Container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aAAY;AAAA,YAEZ,UAAA;AAAA,cAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,cAAc;AAAA,kBACd,UAAU,CAAC,UAAU,cAAc,KAAK;AAAA,kBACxC,OAAM;AAAA,kBACN,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS;AAAA,oBACP;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBACT;AAAA,oBACA;AAAA,sBACE,SAAS;AAAA,sBACT,OAAO;AAAA;AAAA,oBAAA;AAAA,kBACT,EACA;AAAA,oBACA,CAAC,EAAE,MAAA,MACD,EAAE,SAAS,WAAW,UAAU;AAAA,kBAAA;AAAA,gBACpC;AAAA,cACF;AAAA,cACC,eAAe,KACb,oBAAA,uBAAA,EAAsB,YAAwB,MAAY;AAAA,cAE5D,eAAe,KACb,oBAAA,iBAAA,EAAgB,WAAwB,CAAA;AAAA,cAE1C,eAAe,KACb,oBAAA,eAAA,EAAc,YAAwB,YAAwB;AAAA,cAEhE,eAAe,KACb,oBAAA,YAAA,EAAW,YAAwB,YAAwB;AAAA,cAE9D,oBAAC,UAAS,EAAA,YAAwB,KAAY,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAChD,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -35,8 +35,7 @@ const NavigationViewNode = ({
|
|
|
35
35
|
(keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && core.isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []),
|
|
36
36
|
[focusedContent?.keyPath]
|
|
37
37
|
);
|
|
38
|
-
if (isEditableSection) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
39
|
-
if (!section) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "-" });
|
|
38
|
+
if (!section || isEditableSection) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
40
39
|
if (typeof section === "object") {
|
|
41
40
|
if (nodeType === core.NodeType.ReactNode) {
|
|
42
41
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "React Node" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const sectionEl =\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] ?? '';\n addEditedContent(dictionaryKey, sectionEl, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","sectionArray","Plus","camelCaseToSentence"],"mappings":";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|
|
1
|
+
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (!section || isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const sectionEl =\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] ?? '';\n addEditedContent(dictionaryKey, sectionEl, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","sectionArray","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;AAsBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,KAAAA,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAA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AU,cAAc,YAAY;AAAA,YACpC,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,WAAWC,YAAA;AAAA,YAEV,8CAAoB,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAAJ,2BAAA;AAAA,QAACK,+BAAA;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,KAAK,IAAI,GAAG;AAAA,UAChC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQI,oCAAoB,GAAG;AAAA,UAE/B,yCAAC,OAAI,EAAA,WAAU,+BACb,UAACT,2BAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACIM,2BAAA,KAAAL,qBAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAIjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAe,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ7C,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAIjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAe,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ7C,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CA4RnD,CAAC"}
|
|
@@ -33,8 +33,7 @@ const NavigationViewNode = ({
|
|
|
33
33
|
(keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []),
|
|
34
34
|
[focusedContent?.keyPath]
|
|
35
35
|
);
|
|
36
|
-
if (isEditableSection) return /* @__PURE__ */ jsx(Fragment, {
|
|
37
|
-
if (!section) return /* @__PURE__ */ jsx(Fragment, { children: "-" });
|
|
36
|
+
if (!section || isEditableSection) return /* @__PURE__ */ jsx(Fragment, {});
|
|
38
37
|
if (typeof section === "object") {
|
|
39
38
|
if (nodeType === NodeType.ReactNode) {
|
|
40
39
|
return /* @__PURE__ */ jsx(Fragment, { children: "React Node" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const sectionEl =\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] ?? '';\n addEditedContent(dictionaryKey, sectionEl, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","sectionArray"],"mappings":";;;;;;;;;;;;AAsBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,YAAY,OAAO;AAC9B,QAAA,oBAAoB,qBAAqB,OAAO;AACtD,QAAM,gBAAgB;AAAA,IACpB,CAACA,cACE,gBAAg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AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (!section || isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const sectionEl =\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] ?? '';\n addEditedContent(dictionaryKey, sectionEl, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","sectionArray"],"mappings":";;;;;;;;;;;;AAsBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAA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EC,OAAO,GAAG,UAAU,KAAK,IAAI,GAAG;AAAA,UAChC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQ,oBAAoB,GAAG;AAAA,UAE/B,8BAAC,OAAI,EAAA,WAAU,+BACb,UAAC,oBAAA,OAAA,EAAI,WAAU,gBACb,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
@@ -11,7 +11,7 @@ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
|
11
11
|
require("../../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
12
12
|
const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
|
|
13
13
|
require("deepmerge");
|
|
14
|
-
require("../../../index-
|
|
14
|
+
require("../../../index-Db5Dym4h.cjs");
|
|
15
15
|
require("@intlayer/config/client");
|
|
16
16
|
require("../../Button/Button.cjs");
|
|
17
17
|
require("../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs");
|
|
@@ -9,7 +9,7 @@ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
|
9
9
|
import "../../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
10
10
|
import { usePushDictionaries, useWriteDictionary, useAuditContentDeclaration } from "../../../hooks/intlayerAPIHooks.mjs";
|
|
11
11
|
import "deepmerge";
|
|
12
|
-
import "../../../index-
|
|
12
|
+
import "../../../index-BTDHuTxL.js";
|
|
13
13
|
import "@intlayer/config/client";
|
|
14
14
|
import "../../Button/Button.mjs";
|
|
15
15
|
import "../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs";
|
|
@@ -3,29 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
5
|
const editorReact = require("@intlayer/editor-react");
|
|
6
|
-
const components_Container_index = require("../Container/index.cjs");
|
|
7
6
|
const components_DictionaryFieldEditor_StructureView_StructureView = require("./StructureView/StructureView.cjs");
|
|
8
7
|
const StructureEditor = ({ dictionary }) => {
|
|
9
8
|
const { content: dictionaryContent, key } = dictionary;
|
|
10
9
|
const { editedContent } = editorReact.useEditedContent();
|
|
11
10
|
const initialSection = editedContent?.[key]?.content ?? dictionaryContent;
|
|
12
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13
|
-
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-scroll p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12
|
+
components_DictionaryFieldEditor_StructureView_StructureView.NodeView,
|
|
14
13
|
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
className: "w-full overflow-scroll p-3",
|
|
19
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
-
components_DictionaryFieldEditor_StructureView_StructureView.StructureView,
|
|
21
|
-
{
|
|
22
|
-
keyPath: [],
|
|
23
|
-
section: initialSection,
|
|
24
|
-
dictionaryKey: key
|
|
25
|
-
}
|
|
26
|
-
)
|
|
14
|
+
section: initialSection,
|
|
15
|
+
keyPath: [],
|
|
16
|
+
dictionaryKey: dictionary.key
|
|
27
17
|
}
|
|
28
|
-
);
|
|
18
|
+
) });
|
|
29
19
|
};
|
|
30
20
|
exports.StructureEditor = StructureEditor;
|
|
31
21
|
//# sourceMappingURL=StructureEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { type FC } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"StructureEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { type FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content: dictionaryContent, key } = dictionary;\n const { editedContent } = useEditedContent();\n const initialSection = editedContent?.[key]?.content ?? dictionaryContent;\n\n return (\n <div className=\"w-full overflow-scroll p-5\">\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryKey={dictionary.key}\n />\n </div>\n );\n};\n"],"names":["useEditedContent","jsx","NodeView"],"mappings":";;;;;;AAWO,MAAM,kBAAuC,CAAC,EAAE,iBAAiB;AACtE,QAAM,EAAE,SAAS,mBAAmB,IAAQ,IAAA;AACtC,QAAA,EAAE,cAAc,IAAIA,6BAAiB;AAC3C,QAAM,iBAAiB,gBAAgB,GAAG,GAAG,WAAW;AAGtD,SAAAC,2BAAAA,IAAC,OAAI,EAAA,WAAU,8BACb,UAAAA,2BAAA;AAAA,IAACC,6DAAA;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,eAAe,WAAW;AAAA,IAAA;AAAA,EAAA,GAE9B;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StructureEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,eAAe,CAc/C,CAAC"}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEditedContent } from "@intlayer/editor-react";
|
|
4
|
-
import {
|
|
5
|
-
import { StructureView } from "./StructureView/StructureView.mjs";
|
|
4
|
+
import { NodeView } from "./StructureView/StructureView.mjs";
|
|
6
5
|
const StructureEditor = ({ dictionary }) => {
|
|
7
6
|
const { content: dictionaryContent, key } = dictionary;
|
|
8
7
|
const { editedContent } = useEditedContent();
|
|
9
8
|
const initialSection = editedContent?.[key]?.content ?? dictionaryContent;
|
|
10
|
-
return /* @__PURE__ */ jsx(
|
|
11
|
-
|
|
9
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full overflow-scroll p-5", children: /* @__PURE__ */ jsx(
|
|
10
|
+
NodeView,
|
|
12
11
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
className: "w-full overflow-scroll p-3",
|
|
17
|
-
children: /* @__PURE__ */ jsx(
|
|
18
|
-
StructureView,
|
|
19
|
-
{
|
|
20
|
-
keyPath: [],
|
|
21
|
-
section: initialSection,
|
|
22
|
-
dictionaryKey: key
|
|
23
|
-
}
|
|
24
|
-
)
|
|
12
|
+
section: initialSection,
|
|
13
|
+
keyPath: [],
|
|
14
|
+
dictionaryKey: dictionary.key
|
|
25
15
|
}
|
|
26
|
-
);
|
|
16
|
+
) });
|
|
27
17
|
};
|
|
28
18
|
export {
|
|
29
19
|
StructureEditor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { type FC } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"StructureEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { type FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content: dictionaryContent, key } = dictionary;\n const { editedContent } = useEditedContent();\n const initialSection = editedContent?.[key]?.content ?? dictionaryContent;\n\n return (\n <div className=\"w-full overflow-scroll p-5\">\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryKey={dictionary.key}\n />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAWO,MAAM,kBAAuC,CAAC,EAAE,iBAAiB;AACtE,QAAM,EAAE,SAAS,mBAAmB,IAAQ,IAAA;AACtC,QAAA,EAAE,cAAc,IAAI,iBAAiB;AAC3C,QAAM,iBAAiB,gBAAgB,GAAG,GAAG,WAAW;AAGtD,SAAA,oBAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,eAAe,WAAW;AAAA,IAAA;AAAA,EAAA,GAE9B;AAEJ;"}
|
|
@@ -139,13 +139,13 @@ const NodeView = ({
|
|
|
139
139
|
{
|
|
140
140
|
transparency: "xl",
|
|
141
141
|
roundedSize: "xl",
|
|
142
|
-
background: "hoverable",
|
|
143
142
|
className: "w-full min-w-80 gap-2 px-5 py-2",
|
|
144
|
-
|
|
143
|
+
border: true,
|
|
144
|
+
borderColor: "text",
|
|
145
145
|
"aria-selected": core.isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),
|
|
146
146
|
onClick: () => setFocusedContentKeyPath(keyPath),
|
|
147
147
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col items-start justify-between gap-3", children: [
|
|
148
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
148
|
+
typeof sectionKey === "string" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
149
149
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between gap-10", children: [
|
|
150
150
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
151
151
|
components_EditableField_EditableFieldInput.EditableFieldInput,
|
|
@@ -208,7 +208,7 @@ const ObjectView = ({
|
|
|
208
208
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Not an object" });
|
|
209
209
|
}
|
|
210
210
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
211
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mr-auto flex flex-col gap-
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mr-auto flex flex-col gap-4", children: Object.keys(section).map((key) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
212
212
|
NodeView,
|
|
213
213
|
{
|
|
214
214
|
sectionKey: key,
|
|
@@ -225,7 +225,7 @@ const ObjectView = ({
|
|
|
225
225
|
size: "md",
|
|
226
226
|
color: "text",
|
|
227
227
|
Icon: lucideReact.Plus,
|
|
228
|
-
className: "
|
|
228
|
+
className: "flex-1",
|
|
229
229
|
onClick: () => {
|
|
230
230
|
const newKey = "newKey";
|
|
231
231
|
const newKeyPath = [
|
|
@@ -265,6 +265,7 @@ const StructureView = ({
|
|
|
265
265
|
}
|
|
266
266
|
);
|
|
267
267
|
};
|
|
268
|
+
exports.NodeView = NodeView;
|
|
268
269
|
exports.ObjectView = ObjectView;
|
|
269
270
|
exports.StructureView = StructureView;
|
|
270
271
|
//# sourceMappingURL=StructureView.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyPath,\n type TypedNode,\n type ContentNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n NodeType,\n getDefaultNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration().internationalization.locales;\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nconst NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useDictionary(structureViewContent);\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryKey, keyName, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: keyName } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <Container\n transparency=\"xl\"\n roundedSize=\"xl\"\n background=\"hoverable\"\n className=\"w-full min-w-80 gap-2 px-5 py-2\"\n backgroundColor=\"contrast\"\n aria-selected={isSameKeyPath(keyPath, focusedContent?.keyPath ?? [])}\n onClick={() => setFocusedContentKeyPath(keyPath)}\n >\n <div className=\"flex w-full flex-col items-start justify-between gap-3\">\n <div className=\"w-full\">\n <div className=\"flex w-full items-center justify-between gap-10\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n placeholder={titleInput.placeholder.value}\n defaultValue={sectionKey}\n onSave={(value) => handleRenameNodeKey(value)}\n variant=\"invisible\"\n />\n <Button\n label={deleteButton.label.value}\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"text-neutral dark:text-neutral-dark ml-3 text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n\n <NodeTypeView\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryKey, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { addNodeButton } = useDictionary(structureViewContent);\n const { setFocusedContentKeyPath } = useFocusDictionaryActions();\n const { addEditedContent } = useEditedContentActions();\n\n if (!section || typeof section !== 'object') {\n return <div>Not an object</div>;\n }\n\n return (\n <div className=\"flex flex-col gap-2\">\n <ul className=\"mr-auto flex flex-col gap-2\">\n {Object.keys(section).map((key) => (\n <li key={key} className=\"flex w-full\">\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeType.Object, key }]}\n dictionaryKey={dictionaryKey}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant=\"hoverable\"\n size=\"md\"\n color=\"text\"\n Icon={Plus}\n className=\"w-80\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeType.Object, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryKey, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n if (\n !section ||\n typeof section !== 'object' ||\n typeof section.nodeType === 'string'\n ) {\n return (\n <NodeView\n sectionKey=\"content\"\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n};\n"],"names":["useConfiguration","getNodeType","getNodeChildren","getDefaultNode","NodeType","jsxs","jsx","NodeTypeSelector","nodeType","Fragment","useFocusDictionary","useEditedContentActions","useDictionary","structureViewContent","Container","isSameKeyPath","EditableFieldInput","Button","Trash","camelCaseToSentence","useFocusDictionaryActions","Plus"],"mappings":";;;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A,YACH,EAAE,MAAMjB,KAAAA,SAAS,QAAQ,KAAK,OAAO;AAAA,UACvC;AACiB,2BAAA,eAAe,IAAI,UAAU;AAC9C,mCAAyB,UAAU;AAAA,QACrC;AAAA,QAEC,UAAc,cAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAQO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,MAAA,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAC5B;AAEE,WAAAE,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"StructureView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyPath,\n type TypedNode,\n type ContentNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n NodeType,\n getDefaultNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration().internationalization.locales;\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey?: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useDictionary(structureViewContent);\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryKey, keyName, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: keyName } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <Container\n transparency=\"xl\"\n roundedSize=\"xl\"\n className=\"w-full min-w-80 gap-2 px-5 py-2\"\n border\n borderColor=\"text\"\n aria-selected={isSameKeyPath(keyPath, focusedContent?.keyPath ?? [])}\n onClick={() => setFocusedContentKeyPath(keyPath)}\n >\n <div className=\"flex w-full flex-col items-start justify-between gap-3\">\n {typeof sectionKey === 'string' && (\n <div className=\"w-full\">\n <div className=\"flex w-full items-center justify-between gap-10\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n placeholder={titleInput.placeholder.value}\n defaultValue={sectionKey}\n onSave={(value) => handleRenameNodeKey(value)}\n variant=\"invisible\"\n />\n <Button\n label={deleteButton.label.value}\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"text-neutral dark:text-neutral-dark ml-3 text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n )}\n <NodeTypeView\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryKey, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { addNodeButton } = useDictionary(structureViewContent);\n const { setFocusedContentKeyPath } = useFocusDictionaryActions();\n const { addEditedContent } = useEditedContentActions();\n\n if (!section || typeof section !== 'object') {\n return <div>Not an object</div>;\n }\n\n return (\n <div className=\"flex flex-col gap-2\">\n <ul className=\"mr-auto flex flex-col gap-4\">\n {Object.keys(section).map((key) => (\n <li key={key} className=\"flex w-full\">\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeType.Object, key }]}\n dictionaryKey={dictionaryKey}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant=\"hoverable\"\n size=\"md\"\n color=\"text\"\n Icon={Plus}\n className=\"flex-1\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeType.Object, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryKey, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n if (\n !section ||\n typeof section !== 'object' ||\n typeof section.nodeType === 'string'\n ) {\n return (\n <NodeView\n sectionKey={'content'}\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n};\n"],"names":["useConfiguration","getNodeType","getNodeChildren","getDefaultNode","NodeType","jsxs","jsx","NodeTypeSelector","nodeType","Fragment","useFocusDictionary","useEditedContentActions","useDictionary","structureViewContent","Container","isSameKeyPath","EditableFieldInput","Button","Trash","camelCaseToSentence","useFocusDictionaryActions","Plus"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,MAAM;AACE,QAAA,UAAUA,YAAAA,mBAAmB,qBAAqB;AAClD,QAAA,WAAWC,iBAAY,OAAO;AAC9B,QAAA,WAAWC,qBAAgB,OAAO;AAElC,QAAA,mBAAmB,CAAC,YAA0B;AAClD,UAAM,qBAAqBC,KAAA;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,yBAAqB,kBAAkB;AAAA,EACzC;AAGE,MAAA,aAAaC,cAAS,eACtB,aAAaA,cAAS,aACtB,aAAaA,cAAS,aACtB;AACA,UAAM,WAAW,OAAO;AAAA,MACrB,QAAiC,QAAgC;AAAA,MAClE,CAAC;AACH,UAAM,kBAAkB;AAAA,MACtB,GAAG;AAAA,MACH,EAAE,MAAM,UAAU,KAAK,SAAS;AAAA,IAClC;AAGE,WAAAC,2BAAA,KAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,MAAAC,2BAAA;AAAA,QAACC,kDAAA;AAAA,QAAA;AAAA,UACC;AAAA,UACA,eAAe,CAACC,cACd;AAAA,YACEL,KAAA,eAAeK,WAAU,OAAO;AAAA,UAAA;AAAA,QAClC;AAAA,MAEJ;AAAA,MAEAF,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SAAS;AAAA,UACT,SAAS;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;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AK;AAAA,QACpD;AAAA,MAAA;AAAA,IAAA,KALK,GAOT,CACD,GACH;AAAA,IACAE,2BAAA;AAAA,MAACW,yBAAA;AAAA,MAAA;AAAA,QACC,OAAO,cAAc,MAAM;AAAA,QAC3B,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,OAAM;AAAA,QACN,MAAMI,YAAA;AAAA,QACN,WAAU;AAAA,QACV,SAAS,MAAM;AACb,gBAAM,SAAS;AACf,gBAAM,aAAa;AAAA,YACjB,GAAG;AAAA,YACH,EAAE,MAAMjB,KAAAA,SAAS,QAAQ,KAAK,OAAO;AAAA,UACvC;AACiB,2BAAA,eAAe,IAAI,UAAU;AAC9C,mCAAyB,UAAU;AAAA,QACrC;AAAA,QAEC,UAAc,cAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAQO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,MAAA,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAC5B;AAEE,WAAAE,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;;"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { KeyPath, ContentNode } from '@intlayer/core';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
+
type NodeWrapperProps = {
|
|
4
|
+
sectionKey?: string;
|
|
5
|
+
dictionaryKey: string;
|
|
6
|
+
keyPath: KeyPath[];
|
|
7
|
+
section: ContentNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const NodeView: FC<NodeWrapperProps>;
|
|
3
10
|
type ObjectViewProps = {
|
|
4
11
|
dictionaryKey: string;
|
|
5
12
|
keyPath: KeyPath[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,WAAW,EAMjB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StructureView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,WAAW,EAMjB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AA6HhC,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CA4EzC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgD1C,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA2BhD,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { isSameKeyPath, NodeType, getNodeType, getNodeChildren, getDefaultNode } from "@intlayer/core";
|
|
4
|
+
import { useFocusDictionary, useEditedContentActions, useFocusDictionaryActions, useConfiguration } from "@intlayer/editor-react";
|
|
5
|
+
import { Trash, Plus } from "lucide-react";
|
|
6
6
|
import { useDictionary } from "react-intlayer";
|
|
7
7
|
import { camelCaseToSentence } from "../../../utils/camelCase.mjs";
|
|
8
8
|
import { Button } from "../../Button/Button.mjs";
|
|
@@ -137,13 +137,13 @@ const NodeView = ({
|
|
|
137
137
|
{
|
|
138
138
|
transparency: "xl",
|
|
139
139
|
roundedSize: "xl",
|
|
140
|
-
background: "hoverable",
|
|
141
140
|
className: "w-full min-w-80 gap-2 px-5 py-2",
|
|
142
|
-
|
|
141
|
+
border: true,
|
|
142
|
+
borderColor: "text",
|
|
143
143
|
"aria-selected": isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),
|
|
144
144
|
onClick: () => setFocusedContentKeyPath(keyPath),
|
|
145
145
|
children: /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-start justify-between gap-3", children: [
|
|
146
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
146
|
+
typeof sectionKey === "string" && /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
147
147
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-10", children: [
|
|
148
148
|
/* @__PURE__ */ jsx(
|
|
149
149
|
EditableFieldInput,
|
|
@@ -206,7 +206,7 @@ const ObjectView = ({
|
|
|
206
206
|
return /* @__PURE__ */ jsx("div", { children: "Not an object" });
|
|
207
207
|
}
|
|
208
208
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
209
|
-
/* @__PURE__ */ jsx("ul", { className: "mr-auto flex flex-col gap-
|
|
209
|
+
/* @__PURE__ */ jsx("ul", { className: "mr-auto flex flex-col gap-4", children: Object.keys(section).map((key) => /* @__PURE__ */ jsx("li", { className: "flex w-full", children: /* @__PURE__ */ jsx(
|
|
210
210
|
NodeView,
|
|
211
211
|
{
|
|
212
212
|
sectionKey: key,
|
|
@@ -223,7 +223,7 @@ const ObjectView = ({
|
|
|
223
223
|
size: "md",
|
|
224
224
|
color: "text",
|
|
225
225
|
Icon: Plus,
|
|
226
|
-
className: "
|
|
226
|
+
className: "flex-1",
|
|
227
227
|
onClick: () => {
|
|
228
228
|
const newKey = "newKey";
|
|
229
229
|
const newKeyPath = [
|
|
@@ -264,6 +264,7 @@ const StructureView = ({
|
|
|
264
264
|
);
|
|
265
265
|
};
|
|
266
266
|
export {
|
|
267
|
+
NodeView,
|
|
267
268
|
ObjectView,
|
|
268
269
|
StructureView
|
|
269
270
|
};
|