@intlayer/design-system 8.9.1 → 8.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/esm/components/Avatar/image.mjs.map +1 -1
- package/dist/esm/components/Avatar/index.mjs.map +1 -1
- package/dist/esm/components/Badge/index.mjs.map +1 -1
- package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/esm/components/Browser/Browser.mjs.map +1 -1
- package/dist/esm/components/Button/Button.mjs.map +1 -1
- package/dist/esm/components/Carousel/index.mjs.map +1 -1
- package/dist/esm/components/ClickOutsideDiv/index.mjs.map +1 -1
- package/dist/esm/components/CollapsibleTable/CollapsibleTable.mjs.map +1 -1
- package/dist/esm/components/Command/index.mjs.map +1 -1
- package/dist/esm/components/Container/index.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorInput.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/esm/components/CopyButton/index.mjs.map +1 -1
- package/dist/esm/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/BooleanWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NumberWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/PluralWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +2 -2
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/object.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +40 -44
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +25 -18
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +2 -2
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +3 -3
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/esm/components/DropDown/index.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
- package/dist/esm/components/Flags/Flag.mjs.map +1 -1
- package/dist/esm/components/Flags/ae.mjs.map +1 -1
- package/dist/esm/components/Flags/af.mjs.map +1 -1
- package/dist/esm/components/Flags/al.mjs.map +1 -1
- package/dist/esm/components/Flags/am.mjs.map +1 -1
- package/dist/esm/components/Flags/ar.mjs.map +1 -1
- package/dist/esm/components/Flags/at.mjs.map +1 -1
- package/dist/esm/components/Flags/au.mjs.map +1 -1
- package/dist/esm/components/Flags/az.mjs.map +1 -1
- package/dist/esm/components/Flags/ba.mjs.map +1 -1
- package/dist/esm/components/Flags/bd.mjs.map +1 -1
- package/dist/esm/components/Flags/be.mjs.map +1 -1
- package/dist/esm/components/Flags/bg.mjs.map +1 -1
- package/dist/esm/components/Flags/bh.mjs.map +1 -1
- package/dist/esm/components/Flags/bn.mjs.map +1 -1
- package/dist/esm/components/Flags/bo.mjs.map +1 -1
- package/dist/esm/components/Flags/br.mjs.map +1 -1
- package/dist/esm/components/Flags/bw.mjs.map +1 -1
- package/dist/esm/components/Flags/by.mjs.map +1 -1
- package/dist/esm/components/Flags/bz.mjs.map +1 -1
- package/dist/esm/components/Flags/ca.mjs.map +1 -1
- package/dist/esm/components/Flags/ch.mjs.map +1 -1
- package/dist/esm/components/Flags/cl.mjs.map +1 -1
- package/dist/esm/components/Flags/cn.mjs.map +1 -1
- package/dist/esm/components/Flags/co.mjs.map +1 -1
- package/dist/esm/components/Flags/cr.mjs.map +1 -1
- package/dist/esm/components/Flags/cu.mjs.map +1 -1
- package/dist/esm/components/Flags/cv.mjs.map +1 -1
- package/dist/esm/components/Flags/cz.mjs.map +1 -1
- package/dist/esm/components/Flags/de.mjs.map +1 -1
- package/dist/esm/components/Flags/dj.mjs.map +1 -1
- package/dist/esm/components/Flags/dk.mjs.map +1 -1
- package/dist/esm/components/Flags/do.mjs.map +1 -1
- package/dist/esm/components/Flags/dz.mjs.map +1 -1
- package/dist/esm/components/Flags/ec.mjs.map +1 -1
- package/dist/esm/components/Flags/ee.mjs.map +1 -1
- package/dist/esm/components/Flags/eg.mjs.map +1 -1
- package/dist/esm/components/Flags/es-ct.mjs.map +1 -1
- package/dist/esm/components/Flags/es-ga.mjs.map +1 -1
- package/dist/esm/components/Flags/es-pv.mjs.map +1 -1
- package/dist/esm/components/Flags/es.mjs.map +1 -1
- package/dist/esm/components/Flags/et.mjs.map +1 -1
- package/dist/esm/components/Flags/fi.mjs.map +1 -1
- package/dist/esm/components/Flags/fo.mjs.map +1 -1
- package/dist/esm/components/Flags/fr.mjs.map +1 -1
- package/dist/esm/components/Flags/gb-wls.mjs.map +1 -1
- package/dist/esm/components/Flags/gb.mjs.map +1 -1
- package/dist/esm/components/Flags/ge.mjs.map +1 -1
- package/dist/esm/components/Flags/gh.mjs.map +1 -1
- package/dist/esm/components/Flags/gr.mjs.map +1 -1
- package/dist/esm/components/Flags/gt.mjs.map +1 -1
- package/dist/esm/components/Flags/gw.mjs.map +1 -1
- package/dist/esm/components/Flags/hk.mjs.map +1 -1
- package/dist/esm/components/Flags/hn.mjs.map +1 -1
- package/dist/esm/components/Flags/hr.mjs.map +1 -1
- package/dist/esm/components/Flags/hu.mjs.map +1 -1
- package/dist/esm/components/Flags/id.mjs.map +1 -1
- package/dist/esm/components/Flags/ie.mjs.map +1 -1
- package/dist/esm/components/Flags/il.mjs.map +1 -1
- package/dist/esm/components/Flags/in.mjs.map +1 -1
- package/dist/esm/components/Flags/iq.mjs.map +1 -1
- package/dist/esm/components/Flags/ir.mjs.map +1 -1
- package/dist/esm/components/Flags/is.mjs.map +1 -1
- package/dist/esm/components/Flags/it.mjs.map +1 -1
- package/dist/esm/components/Flags/jm.mjs.map +1 -1
- package/dist/esm/components/Flags/jo.mjs.map +1 -1
- package/dist/esm/components/Flags/jp.mjs.map +1 -1
- package/dist/esm/components/Flags/ke.mjs.map +1 -1
- package/dist/esm/components/Flags/kg.mjs.map +1 -1
- package/dist/esm/components/Flags/kh.mjs.map +1 -1
- package/dist/esm/components/Flags/km.mjs.map +1 -1
- package/dist/esm/components/Flags/kr.mjs.map +1 -1
- package/dist/esm/components/Flags/kw.mjs.map +1 -1
- package/dist/esm/components/Flags/kz.mjs.map +1 -1
- package/dist/esm/components/Flags/la.mjs.map +1 -1
- package/dist/esm/components/Flags/lb.mjs.map +1 -1
- package/dist/esm/components/Flags/li.mjs.map +1 -1
- package/dist/esm/components/Flags/lk.mjs.map +1 -1
- package/dist/esm/components/Flags/lt.mjs.map +1 -1
- package/dist/esm/components/Flags/lu.mjs.map +1 -1
- package/dist/esm/components/Flags/lv.mjs.map +1 -1
- package/dist/esm/components/Flags/ly.mjs.map +1 -1
- package/dist/esm/components/Flags/ma.mjs.map +1 -1
- package/dist/esm/components/Flags/mc.mjs.map +1 -1
- package/dist/esm/components/Flags/md.mjs.map +1 -1
- package/dist/esm/components/Flags/mk.mjs.map +1 -1
- package/dist/esm/components/Flags/mm.mjs.map +1 -1
- package/dist/esm/components/Flags/mn.mjs.map +1 -1
- package/dist/esm/components/Flags/mo.mjs.map +1 -1
- package/dist/esm/components/Flags/mr.mjs.map +1 -1
- package/dist/esm/components/Flags/mt.mjs.map +1 -1
- package/dist/esm/components/Flags/mv.mjs.map +1 -1
- package/dist/esm/components/Flags/mx.mjs.map +1 -1
- package/dist/esm/components/Flags/my.mjs.map +1 -1
- package/dist/esm/components/Flags/mz.mjs.map +1 -1
- package/dist/esm/components/Flags/ng.mjs.map +1 -1
- package/dist/esm/components/Flags/ni.mjs.map +1 -1
- package/dist/esm/components/Flags/nl.mjs.map +1 -1
- package/dist/esm/components/Flags/no.mjs.map +1 -1
- package/dist/esm/components/Flags/np.mjs.map +1 -1
- package/dist/esm/components/Flags/nz.mjs.map +1 -1
- package/dist/esm/components/Flags/om.mjs.map +1 -1
- package/dist/esm/components/Flags/pa.mjs.map +1 -1
- package/dist/esm/components/Flags/pe.mjs.map +1 -1
- package/dist/esm/components/Flags/ph.mjs.map +1 -1
- package/dist/esm/components/Flags/pk.mjs.map +1 -1
- package/dist/esm/components/Flags/pl.mjs.map +1 -1
- package/dist/esm/components/Flags/pr.mjs.map +1 -1
- package/dist/esm/components/Flags/ps.mjs.map +1 -1
- package/dist/esm/components/Flags/pt.mjs.map +1 -1
- package/dist/esm/components/Flags/py.mjs.map +1 -1
- package/dist/esm/components/Flags/qa.mjs.map +1 -1
- package/dist/esm/components/Flags/ro.mjs.map +1 -1
- package/dist/esm/components/Flags/rs.mjs.map +1 -1
- package/dist/esm/components/Flags/ru.mjs.map +1 -1
- package/dist/esm/components/Flags/sa.mjs.map +1 -1
- package/dist/esm/components/Flags/sd.mjs.map +1 -1
- package/dist/esm/components/Flags/se.mjs.map +1 -1
- package/dist/esm/components/Flags/sg.mjs.map +1 -1
- package/dist/esm/components/Flags/si.mjs.map +1 -1
- package/dist/esm/components/Flags/sk.mjs.map +1 -1
- package/dist/esm/components/Flags/so.mjs.map +1 -1
- package/dist/esm/components/Flags/st.mjs.map +1 -1
- package/dist/esm/components/Flags/sv.mjs.map +1 -1
- package/dist/esm/components/Flags/sy.mjs.map +1 -1
- package/dist/esm/components/Flags/td.mjs.map +1 -1
- package/dist/esm/components/Flags/th.mjs.map +1 -1
- package/dist/esm/components/Flags/tl.mjs.map +1 -1
- package/dist/esm/components/Flags/tn.mjs.map +1 -1
- package/dist/esm/components/Flags/tr.mjs.map +1 -1
- package/dist/esm/components/Flags/tt.mjs.map +1 -1
- package/dist/esm/components/Flags/tw.mjs.map +1 -1
- package/dist/esm/components/Flags/tz.mjs.map +1 -1
- package/dist/esm/components/Flags/ua.mjs.map +1 -1
- package/dist/esm/components/Flags/ug.mjs.map +1 -1
- package/dist/esm/components/Flags/us.mjs.map +1 -1
- package/dist/esm/components/Flags/uy.mjs.map +1 -1
- package/dist/esm/components/Flags/uz.mjs.map +1 -1
- package/dist/esm/components/Flags/ve.mjs.map +1 -1
- package/dist/esm/components/Flags/vn.mjs.map +1 -1
- package/dist/esm/components/Flags/xx.mjs.map +1 -1
- package/dist/esm/components/Flags/ye.mjs.map +1 -1
- package/dist/esm/components/Flags/za.mjs.map +1 -1
- package/dist/esm/components/Flags/zw.mjs.map +1 -1
- package/dist/esm/components/Form/FormBase.mjs.map +1 -1
- package/dist/esm/components/Form/FormControl.mjs.map +1 -1
- package/dist/esm/components/Form/FormDescription.mjs.map +1 -1
- package/dist/esm/components/Form/FormField.mjs.map +1 -1
- package/dist/esm/components/Form/FormItem.mjs.map +1 -1
- package/dist/esm/components/Form/FormLabel.mjs.map +1 -1
- package/dist/esm/components/Form/FormMessage.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElementWrapper.mjs.map +1 -1
- package/dist/esm/components/Form/elements/MultiselectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SelectElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs.map +1 -1
- package/dist/esm/components/HTMLRender/HTMLRender.mjs.map +1 -1
- package/dist/esm/components/Headers/index.mjs.map +1 -1
- package/dist/esm/components/HeightResizer/index.mjs.map +1 -1
- package/dist/esm/components/HideShow/index.mjs.map +1 -1
- package/dist/esm/components/IDE/Code.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockHighlight.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockServer.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockShiki.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeConditionalRenderer.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeContext.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeFormatSelector.mjs.map +1 -1
- package/dist/esm/components/IDE/ContentDeclarationFormatSelector.mjs.map +1 -1
- package/dist/esm/components/IDE/CopyCode.mjs.map +1 -1
- package/dist/esm/components/IDE/FileTree.mjs.map +1 -1
- package/dist/esm/components/IDE/IDE.mjs.map +1 -1
- package/dist/esm/components/IDE/MonacoCode.mjs.map +1 -1
- package/dist/esm/components/IDE/PackageManagerSelector.mjs.map +1 -1
- package/dist/esm/components/IDE/codeTransformer.mjs.map +1 -1
- package/dist/esm/components/IDE/createFileTree.mjs.map +1 -1
- package/dist/esm/components/Input/Checkbox.mjs +2 -0
- package/dist/esm/components/Input/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Input/Input.mjs.map +1 -1
- package/dist/esm/components/Input/InputPassword.mjs.map +1 -1
- package/dist/esm/components/Input/OTPInput.mjs.map +1 -1
- package/dist/esm/components/KeyboardScreenAdapter/index.mjs.map +1 -1
- package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs.map +1 -1
- package/dist/esm/components/LanguageBackground/index.mjs.map +1 -1
- package/dist/esm/components/Link/Link.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownIframe.mjs.map +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs +5 -20
- package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/esm/components/Modal/Modal.mjs +2 -2
- package/dist/esm/components/Modal/Modal.mjs.map +1 -1
- package/dist/esm/components/Navbar/MobileNavbar.mjs +1 -1
- package/dist/esm/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/esm/components/Navbar/index.mjs.map +1 -1
- package/dist/esm/components/Navbar/useNavigation.mjs.map +1 -1
- package/dist/esm/components/Pagination/NumberItemsSelector.mjs.map +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/esm/components/Pagination/ShowingResultsNumberItems.mjs.map +1 -1
- package/dist/esm/components/Popover/dynamic.mjs.map +1 -1
- package/dist/esm/components/Popover/static.mjs.map +1 -1
- package/dist/esm/components/PressableSpan/PressableSpan.mjs.map +1 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs +3 -3
- package/dist/esm/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/esm/components/RightDrawer/isElementAtTopAndNotCovered.mjs.map +1 -1
- package/dist/esm/components/RightDrawer/useRightDrawer.mjs.map +1 -1
- package/dist/esm/components/Select/Multiselect.mjs.map +1 -1
- package/dist/esm/components/Select/Select.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/SwitchSelector.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/VerticalSwitchSelector.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/useSwitchSelector.mjs.map +1 -1
- package/dist/esm/components/Tab/Tab.mjs.map +1 -1
- package/dist/esm/components/Tab/TabContext.mjs.map +1 -1
- package/dist/esm/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/esm/components/Table/ExpandButton.mjs.map +1 -1
- package/dist/esm/components/Table/SmartTable.mjs.map +1 -1
- package/dist/esm/components/Table/TableElements.mjs +24 -0
- package/dist/esm/components/Table/TableElements.mjs.map +1 -0
- package/dist/esm/components/Table/index.mjs +2 -1
- package/dist/esm/components/Table/useTableWidths.mjs.map +1 -1
- package/dist/esm/components/Tag/index.mjs.map +1 -1
- package/dist/esm/components/TechLogo/TechLogo.mjs.map +1 -1
- package/dist/esm/components/TechLogo/types.mjs.map +1 -1
- package/dist/esm/components/Terminal/Terminal.mjs.map +1 -1
- package/dist/esm/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/ContentEditableTextArea.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/types.mjs.map +1 -1
- package/dist/esm/components/Toaster/Toast.mjs.map +1 -1
- package/dist/esm/components/Toaster/Toaster.mjs.map +1 -1
- package/dist/esm/components/Toaster/useToast.mjs.map +1 -1
- package/dist/esm/components/WithResizer/index.mjs.map +1 -1
- package/dist/esm/components/index.mjs +2 -1
- package/dist/esm/hooks/index.mjs +9 -9
- package/dist/esm/hooks/reactQuery.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useAuth.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs.map +1 -1
- package/dist/esm/hooks/useDevice.mjs.map +1 -1
- package/dist/esm/hooks/useGetElementById.mjs.map +1 -1
- package/dist/esm/hooks/useGetElementOrWindow.mjs.map +1 -1
- package/dist/esm/hooks/useHorizontalSwipe.mjs.map +1 -1
- package/dist/esm/hooks/useIntlayerAPI.mjs.map +1 -1
- package/dist/esm/hooks/useIsDarkMode.mjs.map +1 -1
- package/dist/esm/hooks/useIsMounted.mjs.map +1 -1
- package/dist/esm/hooks/useItemSelector.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboardDetector.mjs.map +1 -1
- package/dist/esm/hooks/usePersistedStore.mjs.map +1 -1
- package/dist/esm/hooks/useScreenWidth.mjs.map +1 -1
- package/dist/esm/hooks/useScrollBlockage/index.mjs.map +1 -1
- package/dist/esm/hooks/useScrollBlockage/useScrollBlockageStore.mjs.map +1 -1
- package/dist/esm/hooks/useScrollDetection.mjs.map +1 -1
- package/dist/esm/hooks/useScrollY.mjs.map +1 -1
- package/dist/esm/hooks/useSearch.mjs.map +1 -1
- package/dist/esm/hooks/useUser/index.mjs.map +1 -1
- package/dist/esm/libs/auth.mjs +1 -1
- package/dist/esm/libs/auth.mjs.map +1 -1
- package/dist/esm/providers/ReactQueryProvider.mjs.map +1 -1
- package/dist/esm/tailwind.config.mjs.map +1 -1
- package/dist/types/components/Badge/index.d.ts +1 -1
- package/dist/types/components/Button/Button.d.ts +3 -3
- package/dist/types/components/Command/index.d.ts +1 -1
- package/dist/types/components/Container/index.d.ts +2 -2
- package/dist/types/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/types/components/Input/Checkbox.d.ts +2 -1
- package/dist/types/components/Input/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +2 -2
- package/dist/types/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +1 -1
- package/dist/types/components/Tab/Tab.d.ts +1 -1
- package/dist/types/components/Table/TableElements.d.ts +23 -0
- package/dist/types/components/Table/TableElements.d.ts.map +1 -0
- package/dist/types/components/Table/index.d.ts +2 -1
- package/dist/types/components/Tag/index.d.ts +1 -1
- package/dist/types/components/index.d.ts +2 -1
- package/package.json +17 -17
package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = response.data.fileContent;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n filePath: newFilePath,\n }));\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n location: newValue,\n }));\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n color=\"text\"\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n color=\"text\"\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n filePath: value,\n }));\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n importMode: value as any,\n }));\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,yBAAqD,EAChE,YACA,WACI;CACJ,MAAM,EAAE,YAAY,YAAY;CAChC,MAAM,EAAE,YAAY,WAAW,EAAE;CACjC,MAAM,EAAE,MAAM,cAAc,WAAW,sBACrC,gBAAgB;CAClB,MAAM,EAAE,MAAM,aAAa,YAAY;CAEvC,MAAM,WAAY,cAAc,QAAQ,EAAE;CAC1C,MAAM,UAAW,UAAU,QAAQ,EAAE;CAErC,MAAM,0BAA0B,2BAC9B,OAAO,SAAS,GAAG,CACpB;CACD,MAAM,EAAE,MAAM,iBAAiBA,UAAQ,yBAAyB,EAC9D,eAAe;EACb,GAAG;EACH,UAAU,WAAW,YAAY;EAClC,EACF,CAAC;CACF,MAAM,EAAE,eAAe,wBAAwB,kBAAkB;CACjE,MAAM,EACJ,YACA,UACA,kBACA,cACA,YACA,gBACA,kBACA,eACA,gBACE,YAAY,qBAAqB;CACrC,MAAM,EAAE,QAAQ,yBAAyB,WAAW,eAClD,oCAAoC;CACtC,MAAM,oBACJ,gBAAgB,WAAW;AAE7B,iBAAgB;AACd,OAAK,MAAM;GACT,GAAG;GACH,UAAU,WAAW,YAAY;GAClC,CAAC;IACD,CAAC,YAAY,MAAM,MAAM,CAAC;AAE7B,iBAAgB;AACd,MAAI,OAAO,sBAAsB,YAC/B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S,QAAQ,YAAY,EAAE,aAAa,MAAM,CAAC;AACxD,2BAAqB,UAAU;OAC7B,GAAG;OACH,GAAI,QAAQ,EAAE;OACd,MAAM;OACP,EAAE;;eAXP,CAcE,oBAAC,YAAY,SAAb;MACE,gBAAgB,UACd,SAAS,MAAM,QAAa,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE,QACxD;gBAGF,oBAAC,YAAY,OAAb,EAAmB,aAAa,WAAW,YAAY,OAAS;MAC5C,GACtB,oBAAC,YAAY,SAAb,YACE,oBAAC,QAAD;MAAQ,WAAW;gBACjB,oBAAC,YAAY,MAAb,YACG,SAAS,KAAK,QACb,oBAAC,YAAY,MAAb;OAEE,OAAO,OAAO,IAAI,IAAI;iBAErB,IAAI,QAAQ,IAAI;OACA,EAJZ,OAAO,IAAI,IAAI,CAIH,CACnB,EACe;MACZ,GACW,EACL;OACf;;GAEN,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,KAAK,QAAN;KACE,MAAK;KACL;KACA,OAAO,YAAY,MAAM;KACzB,MAAM;KACN;KACA;KACA,WAAU;KACV,SAAS;KACT,UAAU,gBAAgB;KAC1B,WAAW;KACX;IACE;GACD"}
|
|
1
|
+
{"version":3,"file":"DictionaryDetailsForm.mjs","names":["useForm"],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonSize, ButtonVariant } from '@components/Button';\nimport { Form, useForm } from '@components/Form';\nimport { Checkbox } from '@components/Input';\nimport { Loader } from '@components/Loader';\nimport { MultiSelect, Select } from '@components/Select';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '@hooks/reactQuery';\nimport { useSession } from '@hooks/useAuth';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { useIntlayer } from 'react-intlayer';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n}) => {\n const { session } = useSession();\n const { project } = session ?? {};\n const { data: projectsData, isLoading: isLoadingProjects } =\n useGetProjects() as any;\n const { data: tagsData } = useGetTags() as any;\n\n const projects = (projectsData?.data ?? []) as any[];\n const allTags = (tagsData?.data ?? []) as any[];\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: {\n ...dictionary,\n location: dictionary.location ?? 'remote',\n },\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n projectInput,\n tagsSelect,\n locationSelect,\n importModeSelect,\n filePathInput,\n auditButton,\n } = useIntlayer('dictionary-details');\n const { mutate: auditContentDeclaration, isPending: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary =\n editedContent?.[dictionary.localId as LocalDictionaryId];\n\n useEffect(() => {\n form.reset({\n ...dictionary,\n tags: dictionary.tags ?? [],\n location: dictionary.location ?? 'remote',\n });\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset({\n ...dictionary,\n tags: dictionary.tags ?? [],\n location: dictionary.location ?? 'remote',\n });\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n auditContentDeclaration(\n {\n fileContent: JSON.stringify(dictionaryToAudit),\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n const auditedDictionary = response.data.fileContent;\n\n const merged = {\n ...dictionaryToAudit,\n ...auditedDictionary,\n tags: auditedDictionary.tags ?? dictionaryToAudit.tags ?? [],\n };\n\n setEditedDictionary(merged as Dictionary);\n form.reset(merged);\n },\n }\n );\n };\n\n const watchedLocation = useWatch({\n control: form.control,\n name: 'location',\n });\n const isLocalChecked =\n watchedLocation === 'local' || watchedLocation === 'hybrid';\n\n return (\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n >\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n key: value,\n });\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n title: value,\n });\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n description: value,\n });\n }}\n />\n <div className=\"grid grid-cols-2 gap-8 px-1 max-md:grid-cols-1\">\n <Form.Field\n control={form.control}\n name=\"location\"\n render={({ field }) => {\n const value = field.value;\n const isLocal = value === 'local' || value === 'hybrid';\n const isRemote = value === 'remote' || value === 'hybrid';\n\n const handleLocalToggle = (isChecked: boolean) => {\n if (!isChecked && !isRemote) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isRemote\n ? 'hybrid'\n : 'local'\n : 'remote';\n\n field.onChange(newValue);\n\n const newFilePath = isChecked\n ? (form.getValues('filePath') ?? dictionary.filePath)\n : undefined;\n\n if (!isChecked) {\n form.setValue('filePath', undefined);\n }\n\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n location: newValue,\n filePath: newFilePath,\n });\n };\n\n const handleRemoteToggle = (isChecked: boolean) => {\n if (!isChecked && !isLocal) return;\n\n const newValue: Dictionary['location'] = isChecked\n ? isLocal\n ? 'hybrid'\n : 'remote'\n : 'local';\n\n field.onChange(newValue);\n\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n location: newValue,\n });\n };\n\n return (\n <Form.Item className=\"flex flex-col gap-2 px-1\">\n <Form.Label className=\"ml-1\">{locationSelect.label}</Form.Label>\n <div className=\"ml-2 flex items-center gap-4 py-2\">\n <Checkbox\n id=\"location-local\"\n name=\"location-local\"\n label={locationSelect.local.value}\n color=\"text\"\n checked={isLocal}\n disabled={\n !mode.includes('local') && !mode.includes('remote')\n }\n onChange={(e) => handleLocalToggle(e.target.checked)}\n />\n <Checkbox\n id=\"location-remote\"\n name=\"location-remote\"\n label={locationSelect.remote.value}\n color=\"text\"\n checked={isRemote}\n disabled={\n !mode.includes('remote') &&\n dictionary.location !== 'remote' &&\n dictionary.location !== 'hybrid'\n }\n onChange={(e) => handleRemoteToggle(e.target.checked)}\n />\n </div>\n <Form.Description>\n {locationSelect.testDescription}\n </Form.Description>\n <Form.Message />\n </Form.Item>\n );\n }}\n />\n\n <AnimatePresence mode=\"wait\">\n {isLocalChecked && (\n <motion.div\n key=\"filePath-input\"\n initial={{ opacity: 0, height: 0 }}\n animate={{ opacity: 1, height: 'auto' }}\n exit={{ opacity: 0, height: 0 }}\n transition={{ duration: 0.3 }}\n className=\"overflow-hidden\"\n >\n <Form.Input\n name=\"filePath\"\n label={filePathInput.label.value}\n placeholder={filePathInput.placeholder.value}\n description={filePathInput.description.value}\n disabled={isSubmitting || !isLocalChecked}\n onChange={(e) => {\n const value = e.target.value;\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n filePath: value,\n });\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.Select\n name=\"importMode\"\n label={importModeSelect.label.value}\n description={importModeSelect.description.value}\n onValueChange={(value) => {\n form.setValue('importMode', value as any, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n importMode: value as any,\n });\n }}\n >\n <Select.Trigger>\n <Select.Value placeholder={importModeSelect.label.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"static\">\n {importModeSelect.static.value}\n </Select.Item>\n <Select.Item value=\"dynamic\">\n {importModeSelect.dynamic.value}\n </Select.Item>\n <Select.Item value=\"live\">\n {importModeSelect.live.value}\n </Select.Item>\n </Select.Content>\n </Form.Select>\n </div>\n <div className=\"grid grid-cols-2 gap-8 max-md:grid-cols-1\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n projectIds: valueArray,\n });\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.find((project: any) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.map((project: any) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('tags', valueArray, { shouldDirty: true });\n setEditedDictionary({\n ...dictionary,\n ...(updatedDictionary ?? {}),\n tags: valueArray,\n });\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n allTags?.find((tag: any) => String(tag.key) === value)?.name ??\n value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {allTags?.map((tag: any) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n size={ButtonSize.ICON_MD}\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n />\n </div>\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,yBAAqD,EAChE,YACA,WACI;CACJ,MAAM,EAAE,YAAY,YAAY;CAChC,MAAM,EAAE,YAAY,WAAW,EAAE;CACjC,MAAM,EAAE,MAAM,cAAc,WAAW,sBACrC,gBAAgB;CAClB,MAAM,EAAE,MAAM,aAAa,YAAY;CAEvC,MAAM,WAAY,cAAc,QAAQ,EAAE;CAC1C,MAAM,UAAW,UAAU,QAAQ,EAAE;CAErC,MAAM,0BAA0B,2BAC9B,OAAO,SAAS,GAAG,CACpB;CACD,MAAM,EAAE,MAAM,iBAAiBA,UAAQ,yBAAyB,EAC9D,eAAe;EACb,GAAG;EACH,UAAU,WAAW,YAAY;EAClC,EACF,CAAC;CACF,MAAM,EAAE,eAAe,wBAAwB,kBAAkB;CACjE,MAAM,EACJ,Y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BAAC,YAAY,MAAb,YACG,UAAU,KAAK,YACd,oBAAC,YAAY,MAAb;OAEE,OAAO,OAAO,QAAQ,GAAG;iBAExB,QAAQ;OACQ,EAJZ,OAAO,QAAQ,GAAG,CAIN,CACnB,EACe;MACZ,GACW,EACL;QAEnB,qBAAC,KAAK,aAAN;KACE,MAAK;KACL,OAAO,WAAW,MAAM;KACxB,aAAa,WAAW;KACxB,gBAAgB,UAAU;MACxB,MAAM,aAAa,CAAC,MAAM,CAAC,MAAM;MACjC,KAAK,SAAS,QAAQ,YAAY,EAAE,aAAa,MAAM,CAAC;MACxD,oBAAoB;OAClB,GAAG;OACH,GAAI,qBAAqB,EAAE;OAC3B,MAAM;OACP,CAAC;;eAXN,CAcE,oBAAC,YAAY,SAAb;MACE,gBAAgB,UACd,SAAS,MAAM,QAAa,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE,QACxD;gBAGF,oBAAC,YAAY,OAAb,EAAmB,aAAa,WAAW,YAAY,OAAS;MAC5C,GACtB,oBAAC,YAAY,SAAb,YACE,oBAAC,QAAD;MAAQ,WAAW;gBACjB,oBAAC,YAAY,MAAb,YACG,SAAS,KAAK,QACb,oBAAC,YAAY,MAAb;OAEE,OAAO,OAAO,IAAI,IAAI;iBAErB,IAAI,QAAQ,IAAI;OACA,EAJZ,OAAO,IAAI,IAAI,CAIH,CACnB,EACe;MACZ,GACW,EACL;OACf;;GAEN,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,KAAK,QAAN;KACE,MAAK;KACL;KACA,OAAO,YAAY,MAAM;KACzB,MAAM;KACN;KACA;KACA,WAAU;KACV,SAAS;KACT,UAAU,gBAAgB;KAC1B,WAAW;KACX;IACE;GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDetailsSchema.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.ts"],"sourcesContent":["import { useIntlayer } from 'react-intlayer';\nimport { z } from 'zod/v4';\n\nexport const useDictionaryDetailsSchema = (projectId: string) => {\n const {\n titleRequiredError,\n titleInvalidTypeError,\n titleMinLengthError,\n keyRequiredError,\n keyInvalidTypeError,\n keySpaceError,\n keyMinLengthError,\n descriptionRequiredError,\n descriptionInvalidTypeError,\n requiredErrorProjectId,\n invalidTypeErrorProjectId,\n invalidTypeErrorTags,\n locationRequiredError,\n locationInvalidTypeError,\n filePathRequiredError,\n filePathInvalidTypeError,\n } = useIntlayer('dictionary-detail-schema');\n\n return z.object({\n title: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? titleRequiredError.value\n : titleInvalidTypeError.value,\n })\n // Can be length of 0 or > 4\n .refine((val) => val.length === 0 || val.length >= 4, {\n error: titleMinLengthError.value,\n })\n .optional(),\n key: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? keyRequiredError.value\n : keyInvalidTypeError.value,\n })\n .min(4, { error: keyMinLengthError.value })\n /**\n * Valid :\n * my-key\n * my_key\n *\n * Invalid :\n * my key\n * my.key\n */\n .regex(/^[a-zA-Z0-9-_]+$/, { error: keySpaceError.value })\n .default(''),\n description: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? descriptionRequiredError.value\n : descriptionInvalidTypeError.value,\n })\n .optional(),\n projectIds: z\n .array(\n z.string({\n error: (issue) =>\n issue.input === undefined\n ? requiredErrorProjectId.value\n : invalidTypeErrorProjectId.value,\n })\n )\n .default([projectId]),\n tags: z\n .array(\n z.string({\n error: () => invalidTypeErrorTags.value,\n })\n )\n .default([]),\n location: z\n .enum(['local', 'remote', 'hybrid', 'plugin'], {\n error: (issue) =>\n issue.input === undefined\n ? locationRequiredError.value\n : locationInvalidTypeError.value,\n })\n .optional(),\n importMode: z.enum(['static', 'dynamic', 'fetch']).optional(),\n filePath: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? filePathRequiredError.value\n : filePathInvalidTypeError.value,\n })\n .optional(),\n });\n};\n\nexport type DictionaryDetailsFormData = z.infer<\n ReturnType<typeof useDictionaryDetailsSchema>\n>;\n"],"mappings":";;;;AAGA,MAAa,8BAA8B,cAAsB;CAC/D,MAAM,EACJ,oBACA,uBACA,qBACA,kBACA,qBACA,eACA,mBACA,0BACA,6BACA,wBACA,2BACA,sBACA,uBACA,0BACA,uBACA,6BACE,YAAY,2BAA2B;
|
|
1
|
+
{"version":3,"file":"useDictionaryDetailsSchema.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.ts"],"sourcesContent":["import { useIntlayer } from 'react-intlayer';\nimport { z } from 'zod/v4';\n\nexport const useDictionaryDetailsSchema = (projectId: string) => {\n const {\n titleRequiredError,\n titleInvalidTypeError,\n titleMinLengthError,\n keyRequiredError,\n keyInvalidTypeError,\n keySpaceError,\n keyMinLengthError,\n descriptionRequiredError,\n descriptionInvalidTypeError,\n requiredErrorProjectId,\n invalidTypeErrorProjectId,\n invalidTypeErrorTags,\n locationRequiredError,\n locationInvalidTypeError,\n filePathRequiredError,\n filePathInvalidTypeError,\n } = useIntlayer('dictionary-detail-schema');\n\n return z.object({\n title: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? titleRequiredError.value\n : titleInvalidTypeError.value,\n })\n // Can be length of 0 or > 4\n .refine((val) => val.length === 0 || val.length >= 4, {\n error: titleMinLengthError.value,\n })\n .optional(),\n key: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? keyRequiredError.value\n : keyInvalidTypeError.value,\n })\n .min(4, { error: keyMinLengthError.value })\n /**\n * Valid :\n * my-key\n * my_key\n *\n * Invalid :\n * my key\n * my.key\n */\n .regex(/^[a-zA-Z0-9-_]+$/, { error: keySpaceError.value })\n .default(''),\n description: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? descriptionRequiredError.value\n : descriptionInvalidTypeError.value,\n })\n .optional(),\n projectIds: z\n .array(\n z.string({\n error: (issue) =>\n issue.input === undefined\n ? requiredErrorProjectId.value\n : invalidTypeErrorProjectId.value,\n })\n )\n .default([projectId]),\n tags: z\n .array(\n z.string({\n error: () => invalidTypeErrorTags.value,\n })\n )\n .default([]),\n location: z\n .enum(['local', 'remote', 'hybrid', 'plugin'], {\n error: (issue) =>\n issue.input === undefined\n ? locationRequiredError.value\n : locationInvalidTypeError.value,\n })\n .optional(),\n importMode: z.enum(['static', 'dynamic', 'fetch']).optional(),\n filePath: z\n .string({\n error: (issue) =>\n issue.input === undefined\n ? filePathRequiredError.value\n : filePathInvalidTypeError.value,\n })\n .optional(),\n });\n};\n\nexport type DictionaryDetailsFormData = z.infer<\n ReturnType<typeof useDictionaryDetailsSchema>\n>;\n"],"mappings":";;;;AAGA,MAAa,8BAA8B,cAAsB;CAC/D,MAAM,EACJ,oBACA,uBACA,qBACA,kBACA,qBACA,eACA,mBACA,0BACA,6BACA,wBACA,2BACA,sBACA,uBACA,0BACA,uBACA,6BACE,YAAY,2BAA2B;CAE3C,OAAO,EAAE,OAAO;EACd,OAAO,EACJ,OAAO,EACN,QAAQ,UACN,MAAM,UAAU,SACZ,mBAAmB,QACnB,sBAAsB,OAC7B,CAAC,CAED,QAAQ,QAAQ,IAAI,WAAW,KAAK,IAAI,UAAU,GAAG,EACpD,OAAO,oBAAoB,OAC5B,CAAC,CACD,UAAU;EACb,KAAK,EACF,OAAO,EACN,QAAQ,UACN,MAAM,UAAU,SACZ,iBAAiB,QACjB,oBAAoB,OAC3B,CAAC,CACD,IAAI,GAAG,EAAE,OAAO,kBAAkB,OAAO,CAAC,CAU1C,MAAM,oBAAoB,EAAE,OAAO,cAAc,OAAO,CAAC,CACzD,QAAQ,GAAG;EACd,aAAa,EACV,OAAO,EACN,QAAQ,UACN,MAAM,UAAU,SACZ,yBAAyB,QACzB,4BAA4B,OACnC,CAAC,CACD,UAAU;EACb,YAAY,EACT,MACC,EAAE,OAAO,EACP,QAAQ,UACN,MAAM,UAAU,SACZ,uBAAuB,QACvB,0BAA0B,OACjC,CAAC,CACH,CACA,QAAQ,CAAC,UAAU,CAAC;EACvB,MAAM,EACH,MACC,EAAE,OAAO,EACP,aAAa,qBAAqB,OACnC,CAAC,CACH,CACA,QAAQ,EAAE,CAAC;EACd,UAAU,EACP,KAAK;GAAC;GAAS;GAAU;GAAU;GAAS,EAAE,EAC7C,QAAQ,UACN,MAAM,UAAU,SACZ,sBAAsB,QACtB,yBAAyB,OAChC,CAAC,CACD,UAAU;EACb,YAAY,EAAE,KAAK;GAAC;GAAU;GAAW;GAAQ,CAAC,CAAC,UAAU;EAC7D,UAAU,EACP,OAAO,EACN,QAAQ,UACN,MAAM,UAAU,SACZ,sBAAsB,QACtB,yBAAyB,OAChC,CAAC,CACD,UAAU;EACd,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { Container } from "../Container/index.mjs";
|
|
3
4
|
import { Button, ButtonColor, ButtonVariant } from "../Button/Button.mjs";
|
|
4
5
|
import { CopyToClipboard } from "../CopyToClipboard/index.mjs";
|
|
5
6
|
import { LocaleSwitcherContentProvider } from "../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
|
|
@@ -12,8 +13,8 @@ import { StructureEditor } from "./StructureEditor.mjs";
|
|
|
12
13
|
import { useEffect } from "react";
|
|
13
14
|
import { ArrowLeft } from "lucide-react";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { useConfiguration, useDictionariesRecordActions, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
16
16
|
import { useIntlayer } from "react-intlayer";
|
|
17
|
+
import { useConfiguration, useDictionariesRecordActions, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
17
18
|
|
|
18
19
|
//#region src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx
|
|
19
20
|
const DictionaryFieldEditor = ({ dictionary, onClickDictionaryList, isDarkMode, mode, onDelete, onSave, showReturnButton = true }) => {
|
|
@@ -44,7 +45,7 @@ const DictionaryFieldEditor = ({ dictionary, onClickDictionaryList, isDarkMode,
|
|
|
44
45
|
children: returnToDictionaryList.text
|
|
45
46
|
}),
|
|
46
47
|
/* @__PURE__ */ jsx("div", {
|
|
47
|
-
className: "min-h-0 flex-1",
|
|
48
|
+
className: "mb-22 min-h-0 flex-1",
|
|
48
49
|
children: /* @__PURE__ */ jsxs(Tab, {
|
|
49
50
|
defaultTab: "content",
|
|
50
51
|
variant: "ghost",
|
|
@@ -83,22 +84,28 @@ const DictionaryFieldEditor = ({ dictionary, onClickDictionaryList, isDarkMode,
|
|
|
83
84
|
]
|
|
84
85
|
})
|
|
85
86
|
}),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
className: "
|
|
88
|
-
children:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
/* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: "absolute bottom-3 z-20 w-full p-2",
|
|
89
|
+
children: /* @__PURE__ */ jsxs(Container, {
|
|
90
|
+
color: "card",
|
|
91
|
+
roundedSize: "2xl",
|
|
92
|
+
padding: "sm",
|
|
93
|
+
className: "w-full shrink-0 flex-row flex-wrap items-center justify-end gap-10 bg-background/20 md:bottom-0",
|
|
94
|
+
children: [/* @__PURE__ */ jsx(CopyToClipboard, {
|
|
95
|
+
text: dictionary.id,
|
|
96
|
+
className: "text-nowrap text-neutral text-sm",
|
|
97
|
+
size: 9,
|
|
98
|
+
children: dictionary.id
|
|
99
|
+
}), /* @__PURE__ */ jsx(SaveForm, {
|
|
100
|
+
dictionary,
|
|
101
|
+
mode,
|
|
102
|
+
onDelete: () => {
|
|
103
|
+
setFocusedContent(null);
|
|
104
|
+
onDelete?.();
|
|
105
|
+
},
|
|
106
|
+
onSave
|
|
107
|
+
})]
|
|
108
|
+
})
|
|
102
109
|
})
|
|
103
110
|
]
|
|
104
111
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { focusedContent, setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionary } = useDictionariesRecordActions();\n\n useEffect(() => {\n setFocusedContent({\n ...(focusedContent ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n });\n setLocaleDictionary(dictionary);\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization?.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport { Container } from '@components/Container';\nimport { CopyToClipboard } from '@components/CopyToClipboard';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { ArrowLeft } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonVariant } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { Tab } from '../Tab';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n onSave?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n showReturnButton?: boolean;\n};\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n onSave,\n showReturnButton = true,\n}) => {\n const config = useConfiguration();\n const { returnToDictionaryList } = useIntlayer('dictionary-field-editor');\n const { focusedContent, setFocusedContent } = useFocusUnmergedDictionary();\n const { setLocaleDictionary } = useDictionariesRecordActions();\n\n useEffect(() => {\n setFocusedContent({\n ...(focusedContent ?? {}),\n dictionaryKey: dictionary.key,\n dictionaryLocalId: dictionary.localId,\n });\n setLocaleDictionary(dictionary);\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization?.locales ?? []}\n >\n <div className=\"relative flex h-full min-h-0 w-full flex-1 flex-col md:overflow-hidden\">\n {showReturnButton && (\n <Button\n onClick={onClickDictionaryList}\n variant={ButtonVariant.HOVERABLE}\n className=\"z-10 mr-auto mb-6 ml-5 shrink-0\"\n color={ButtonColor.TEXT}\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n )}\n\n <div className=\"mb-22 min-h-0 flex-1\">\n <Tab\n defaultTab=\"content\"\n variant=\"ghost\"\n fullHeight\n headerClassName=\"sticky top-0 z-10 rounded-xl bg-background/20 pb-4\"\n >\n {mode.includes('remote') && (\n <Tab.Item label=\"Details\" value=\"details\">\n <DictionaryDetailsForm dictionary={dictionary} mode={mode} />\n </Tab.Item>\n )}\n <Tab.Item label=\"Structure\" value=\"structure\">\n <StructureEditor dictionary={dictionary} />\n </Tab.Item>\n <Tab.Item label=\"Content\" value=\"content\">\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n <Tab.Item label=\"JSON\" value=\"json\">\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n </Tab.Item>\n </Tab>\n </div>\n\n <div className=\"absolute bottom-3 z-20 w-full p-2\">\n <Container\n color=\"card\"\n roundedSize=\"2xl\"\n padding=\"sm\"\n className=\"w-full shrink-0 flex-row flex-wrap items-center justify-end gap-10 bg-background/20 md:bottom-0\"\n >\n <CopyToClipboard\n text={dictionary.id!}\n className=\"text-nowrap text-neutral text-sm\"\n size={9}\n >\n {dictionary.id}\n </CopyToClipboard>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n onSave={onSave}\n />\n </Container>\n </div>\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAa,yBAAyD,EACpE,YACA,uBACA,YACA,MACA,UACA,QACA,mBAAmB,WACf;CACJ,MAAM,SAAS,kBAAkB;CACjC,MAAM,EAAE,2BAA2B,YAAY,0BAA0B;CACzE,MAAM,EAAE,gBAAgB,sBAAsB,4BAA4B;CAC1E,MAAM,EAAE,wBAAwB,8BAA8B;CAE9D,gBAAgB;EACd,kBAAkB;GAChB,GAAI,kBAAkB,EAAE;GACxB,eAAe,WAAW;GAC1B,mBAAmB,WAAW;GAC/B,CAAC;EACF,oBAAoB,WAAW;IAC9B,EAAE,CAAC;CAEN,OACE,oBAAC,+BAAD;EACE,kBAAkB,QAAQ,sBAAsB,WAAW,EAAE;YAE7D,qBAAC,OAAD;GAAK,WAAU;aAAf;IACG,oBACC,oBAAC,QAAD;KACE,SAAS;KACT;KACA,WAAU;KACV;KACA,MAAM;KACN,OAAO,uBAAuB,MAAM;eAEnC,uBAAuB;KACjB;IAGX,oBAAC,OAAD;KAAK,WAAU;eACb,qBAAC,KAAD;MACE,YAAW;MACX,SAAQ;MACR;MACA,iBAAgB;gBAJlB;OAMG,KAAK,SAAS,SAAS,IACtB,oBAAC,IAAI,MAAL;QAAU,OAAM;QAAU,OAAM;kBAC9B,oBAAC,uBAAD;SAAmC;SAAkB;SAAQ;QACpD;OAEb,oBAAC,IAAI,MAAL;QAAU,OAAM;QAAY,OAAM;kBAChC,oBAAC,iBAAD,EAA6B,YAAc;QAClC;OACX,oBAAC,IAAI,MAAL;QAAU,OAAM;QAAU,OAAM;kBAC9B,oBAAC,eAAD;SAA2B;SAAwB;SAAc;QACxD;OACX,oBAAC,IAAI,MAAL;QAAU,OAAM;QAAO,OAAM;kBAC3B,oBAAC,YAAD;SAAwB;SAAwB;SAAc;QACrD;OACP;;KACF;IAEN,oBAAC,OAAD;KAAK,WAAU;eACb,qBAAC,WAAD;MACE,OAAM;MACN,aAAY;MACZ,SAAQ;MACR,WAAU;gBAJZ,CAME,oBAAC,iBAAD;OACE,MAAM,WAAW;OACjB,WAAU;OACV,MAAM;iBAEL,WAAW;OACI,GAClB,oBAAC,UAAD;OACc;OACN;OACN,gBAAgB;QACd,kBAAkB,KAAK;QACvB,YAAY;;OAEN;OACR,EACQ;;KACR;IACF;;EACwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumKeyInput.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useMemo, useState } from 'react';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\n\nconst extractInitialState = (\n value: string | number\n): { comparator: string | undefined; numberValue: string | undefined } => {\n let comparator: string | undefined;\n let numberValue: string | undefined;\n\n if (typeof value === 'number' || !Number.isNaN(Number(value))) {\n // If value is a number or numeric string, set comparator to '=' and numberValue accordingly\n comparator = '=';\n numberValue = value.toString();\n } else if (typeof value === 'string') {\n // Define possible comparators\n const comparators = ['<=', '>=', '<', '>', '='];\n // Find the comparator that matches the start of the string\n const matchedComparator = comparators.find((comp) =>\n value.startsWith(comp)\n );\n if (matchedComparator) {\n comparator = matchedComparator;\n numberValue = value.slice(matchedComparator.length);\n }\n }\n\n return { comparator, numberValue };\n};\n\ntype EnumKeyInputProps = {\n value: string | number;\n onChange: (value: string) => void;\n};\n\n/**\n * Example of values:\n * - `<1`\n * - `>-44.3`\n * - `=999`\n * - `<=1`\n * - `>=1`\n * - 88\n * - `-1`\n *\n */\nexport const EnumKeyInput: FC<EnumKeyInputProps> = ({ value, onChange }) => {\n const { comparator: initialComparator, numberValue: initialNumberValue } =\n useMemo(() => extractInitialState(value), [value]);\n const [comparator, setComparator] = useState<string | null>(\n initialComparator ?? null\n );\n const [numberValue, setNumberValue] = useState<string | null>(\n initialNumberValue ?? null\n );\n\n useEffect(() => {\n if (\n comparator &&\n numberValue &&\n (comparator !== initialComparator || numberValue !== initialNumberValue)\n ) {\n const newValue = `${comparator}${numberValue}`;\n\n onChange(newValue);\n }\n }, [\n comparator,\n initialComparator,\n initialNumberValue,\n numberValue,\n onChange,\n ]);\n\n return (\n <div className=\"flex gap-1\">\n <Select onValueChange={setComparator} defaultValue={initialComparator}>\n <Select.Trigger className=\"w-20\">\n <Select.Value placeholder=\"Select a comparator\" />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"<\">{`<`}</Select.Item>\n <Select.Item value=\"<=\">{`<=`}</Select.Item>\n <Select.Item value=\"=\">{`=`}</Select.Item>\n <Select.Item value=\">=\">{`>=`}</Select.Item>\n <Select.Item value=\">\">{`>`}</Select.Item>\n </Select.Content>\n </Select>\n <Input\n type=\"number\"\n aria-label=\"Quantity\"\n defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"min-w-4\"\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAMA,MAAM,uBACJ,UACwE;CACxE,IAAI;CACJ,IAAI;
|
|
1
|
+
{"version":3,"file":"EnumKeyInput.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useMemo, useState } from 'react';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\n\nconst extractInitialState = (\n value: string | number\n): { comparator: string | undefined; numberValue: string | undefined } => {\n let comparator: string | undefined;\n let numberValue: string | undefined;\n\n if (typeof value === 'number' || !Number.isNaN(Number(value))) {\n // If value is a number or numeric string, set comparator to '=' and numberValue accordingly\n comparator = '=';\n numberValue = value.toString();\n } else if (typeof value === 'string') {\n // Define possible comparators\n const comparators = ['<=', '>=', '<', '>', '='];\n // Find the comparator that matches the start of the string\n const matchedComparator = comparators.find((comp) =>\n value.startsWith(comp)\n );\n if (matchedComparator) {\n comparator = matchedComparator;\n numberValue = value.slice(matchedComparator.length);\n }\n }\n\n return { comparator, numberValue };\n};\n\ntype EnumKeyInputProps = {\n value: string | number;\n onChange: (value: string) => void;\n};\n\n/**\n * Example of values:\n * - `<1`\n * - `>-44.3`\n * - `=999`\n * - `<=1`\n * - `>=1`\n * - 88\n * - `-1`\n *\n */\nexport const EnumKeyInput: FC<EnumKeyInputProps> = ({ value, onChange }) => {\n const { comparator: initialComparator, numberValue: initialNumberValue } =\n useMemo(() => extractInitialState(value), [value]);\n const [comparator, setComparator] = useState<string | null>(\n initialComparator ?? null\n );\n const [numberValue, setNumberValue] = useState<string | null>(\n initialNumberValue ?? null\n );\n\n useEffect(() => {\n if (\n comparator &&\n numberValue &&\n (comparator !== initialComparator || numberValue !== initialNumberValue)\n ) {\n const newValue = `${comparator}${numberValue}`;\n\n onChange(newValue);\n }\n }, [\n comparator,\n initialComparator,\n initialNumberValue,\n numberValue,\n onChange,\n ]);\n\n return (\n <div className=\"flex gap-1\">\n <Select onValueChange={setComparator} defaultValue={initialComparator}>\n <Select.Trigger className=\"w-20\">\n <Select.Value placeholder=\"Select a comparator\" />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value=\"<\">{`<`}</Select.Item>\n <Select.Item value=\"<=\">{`<=`}</Select.Item>\n <Select.Item value=\"=\">{`=`}</Select.Item>\n <Select.Item value=\">=\">{`>=`}</Select.Item>\n <Select.Item value=\">\">{`>`}</Select.Item>\n </Select.Content>\n </Select>\n <Input\n type=\"number\"\n aria-label=\"Quantity\"\n defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"min-w-4\"\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAMA,MAAM,uBACJ,UACwE;CACxE,IAAI;CACJ,IAAI;CAEJ,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,EAAE;EAE7D,aAAa;EACb,cAAc,MAAM,UAAU;QACzB,IAAI,OAAO,UAAU,UAAU;EAIpC,MAAM,oBAAoB;GAFL;GAAM;GAAM;GAAK;GAAK;GAEN,CAAC,MAAM,SAC1C,MAAM,WAAW,KAAK,CACvB;EACD,IAAI,mBAAmB;GACrB,aAAa;GACb,cAAc,MAAM,MAAM,kBAAkB,OAAO;;;CAIvD,OAAO;EAAE;EAAY;EAAa;;;;;;;;;;;;;AAmBpC,MAAa,gBAAuC,EAAE,OAAO,eAAe;CAC1E,MAAM,EAAE,YAAY,mBAAmB,aAAa,uBAClD,cAAc,oBAAoB,MAAM,EAAE,CAAC,MAAM,CAAC;CACpD,MAAM,CAAC,YAAY,iBAAiB,SAClC,qBAAqB,KACtB;CACD,MAAM,CAAC,aAAa,kBAAkB,SACpC,sBAAsB,KACvB;CAED,gBAAgB;EACd,IACE,cACA,gBACC,eAAe,qBAAqB,gBAAgB,qBAIrD,SAAS,GAFW,aAAa,cAEf;IAEnB;EACD;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,QAAD;GAAQ,eAAe;GAAe,cAAc;aAApD,CACE,oBAAC,OAAO,SAAR;IAAgB,WAAU;cACxB,oBAAC,OAAO,OAAR,EAAc,aAAY,uBAAwB;IACnC,GACjB,qBAAC,OAAO,SAAR;IACE,oBAAC,OAAO,MAAR;KAAa,OAAM;eAAK;KAAkB;IAC1C,oBAAC,OAAO,MAAR;KAAa,OAAM;eAAM;KAAmB;IAC5C,oBAAC,OAAO,MAAR;KAAa,OAAM;eAAK;KAAkB;IAC1C,oBAAC,OAAO,MAAR;KAAa,OAAM;eAAM;KAAmB;IAC5C,oBAAC,OAAO,MAAR;KAAa,OAAM;eAAK;KAAkB;IAC3B,IACV;MACT,oBAAC,OAAD;GACE,MAAK;GACL,cAAW;GACX,cAAc,eAAe;GAC7B,WAAW,MAAM,eAAe,EAAE,OAAO,MAAM;GAC/C,WAAU;GACV,EACE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":";;;;;AAUA,MAAa,cAAmC,EAAE,YAAY,iBAAiB;CAC7E,MAAM,EAAE,kBAAkB,kBAAkB,kBAAkB;CAE9D,MAAM,eAAe,eAAgC;
|
|
1
|
+
{"version":3,"file":"JSONEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent =\n editedContent?.[dictionary.localId!]?.content ?? dictionary?.content;\n\n return (\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.localId!, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n );\n};\n"],"mappings":";;;;;AAUA,MAAa,cAAmC,EAAE,YAAY,iBAAiB;CAC7E,MAAM,EAAE,kBAAkB,kBAAkB,kBAAkB;CAE9D,MAAM,eAAe,eAAgC;EACnD,IAAI;GACF,KAAK,MAAM,WAAW;GACtB,OAAO;WACA,QAAQ;GACf,OAAO;;;CAIX,MAAM,mBACJ,gBAAgB,WAAW,UAAW,WAAW,YAAY;CAE/D,OACE,oBAAC,YAAD;EACE,UAAS;EACT,WAAW,YAAY;GACrB,IAAI,YAAY,WAAW,KAAK,EAC9B,iBAAiB,WAAW,SAAU,KAAK,MAAM,WAAW,KAAK,CAAC;;EAG1D;YAEX,KAAK,UAAU,kBAAkB,MAAM,EAAE;EAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { FC } from 'react';\nimport { Breadcrumb, type BreadcrumbLink } from '../Breadcrumb';\nimport type { LinkColor } from '../Link';\n\ntype KeyPathBreadcrumbProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n onClickKeyPath?: (keyPath: KeyPath[]) => void;\n locale?: Locale;\n color?: LinkColor | `${LinkColor}`;\n showDictionaryKey?: boolean;\n};\n\nexport const KeyPathBreadcrumb: FC<KeyPathBreadcrumbProps> = ({\n keyPath,\n dictionaryKey,\n onClickKeyPath,\n locale,\n color,\n showDictionaryKey = true,\n}) => {\n const formattedKeyPath: BreadcrumbLink[] = [\n ...(showDictionaryKey\n ? [\n {\n text: camelCaseToSentence(dictionaryKey),\n onClick: onClickKeyPath ? () => onClickKeyPath([]) : undefined,\n },\n ]\n : []),\n ...keyPath.map((el, index) => ({\n onClick: onClickKeyPath\n ? () =>\n // With keyPath = [{type: NodeTypes.Object, key: '0'}, {type: NodeTypes.Array, key: '0'}, {type: NodeTypes.Object, key: '1'}]\n // If index is 0 -> onFocusKeyPath([{type: NodeTypes.Object, key: '0'}])\n // If index is 1 -> onFocusKeyPath([{type: NodeTypes.Object, key: '0'}, {type: NodeTypes.Array, key: '0'}])\n onClickKeyPath?.(keyPath.slice(0, index + 1))\n : undefined,\n\n text: el.key?.toString() ?? '',\n })),\n ];\n\n return (\n <Breadcrumb\n links={formattedKeyPath}\n locale={locale}\n elementType=\"location\"\n color={color}\n />\n );\n};\n"],"mappings":";;;;;AAgBA,MAAa,qBAAiD,EAC5D,SACA,eACA,gBACA,QACA,OACA,oBAAoB,WAChB;
|
|
1
|
+
{"version":3,"file":"KeyPathBreadcrumb.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/KeyPathBreadcrumb.tsx"],"sourcesContent":["import { camelCaseToSentence } from '@intlayer/config/client';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { FC } from 'react';\nimport { Breadcrumb, type BreadcrumbLink } from '../Breadcrumb';\nimport type { LinkColor } from '../Link';\n\ntype KeyPathBreadcrumbProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n onClickKeyPath?: (keyPath: KeyPath[]) => void;\n locale?: Locale;\n color?: LinkColor | `${LinkColor}`;\n showDictionaryKey?: boolean;\n};\n\nexport const KeyPathBreadcrumb: FC<KeyPathBreadcrumbProps> = ({\n keyPath,\n dictionaryKey,\n onClickKeyPath,\n locale,\n color,\n showDictionaryKey = true,\n}) => {\n const formattedKeyPath: BreadcrumbLink[] = [\n ...(showDictionaryKey\n ? [\n {\n text: camelCaseToSentence(dictionaryKey),\n onClick: onClickKeyPath ? () => onClickKeyPath([]) : undefined,\n },\n ]\n : []),\n ...keyPath.map((el, index) => ({\n onClick: onClickKeyPath\n ? () =>\n // With keyPath = [{type: NodeTypes.Object, key: '0'}, {type: NodeTypes.Array, key: '0'}, {type: NodeTypes.Object, key: '1'}]\n // If index is 0 -> onFocusKeyPath([{type: NodeTypes.Object, key: '0'}])\n // If index is 1 -> onFocusKeyPath([{type: NodeTypes.Object, key: '0'}, {type: NodeTypes.Array, key: '0'}])\n onClickKeyPath?.(keyPath.slice(0, index + 1))\n : undefined,\n\n text: el.key?.toString() ?? '',\n })),\n ];\n\n return (\n <Breadcrumb\n links={formattedKeyPath}\n locale={locale}\n elementType=\"location\"\n color={color}\n />\n );\n};\n"],"mappings":";;;;;AAgBA,MAAa,qBAAiD,EAC5D,SACA,eACA,gBACA,QACA,OACA,oBAAoB,WAChB;CAuBJ,OACE,oBAAC,YAAD;EACE,OAAO,CAvBT,GAAI,oBACA,CACE;GACE,MAAM,oBAAoB,cAAc;GACxC,SAAS,uBAAuB,eAAe,EAAE,CAAC,GAAG;GACtD,CACF,GACD,EAAE,EACN,GAAG,QAAQ,KAAK,IAAI,WAAW;GAC7B,SAAS,uBAKH,iBAAiB,QAAQ,MAAM,GAAG,QAAQ,EAAE,CAAC,GAC/C;GAEJ,MAAM,GAAG,KAAK,UAAU,IAAI;GAC7B,EAAE,CAKsB;EACf;EACR,aAAY;EACL;EACP"}
|
|
@@ -3,13 +3,13 @@ import { Accordion } from "../../Accordion/Accordion.mjs";
|
|
|
3
3
|
import { getIsEditableSection } from "../getIsEditableSection.mjs";
|
|
4
4
|
import { ChevronRight, Plus } from "lucide-react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { internationalization } from "@intlayer/config/built";
|
|
7
|
-
import { useEditedContentActions, useEditorLocale, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
8
6
|
import { useIntlayer } from "react-intlayer";
|
|
7
|
+
import { useEditedContentActions, useEditorLocale, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
9
8
|
import { getContentNodeByKeyPath, getEmptyNode, getNodeType } from "@intlayer/core/dictionaryManipulator";
|
|
10
9
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
11
10
|
import { isSameKeyPath } from "@intlayer/core/utils";
|
|
12
11
|
import { camelCaseToSentence } from "@intlayer/config/client";
|
|
12
|
+
import { internationalization } from "@intlayer/config/built";
|
|
13
13
|
|
|
14
14
|
//#region src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx
|
|
15
15
|
const traceKeys = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { internationalization } from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { LocalDictionaryId } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = internationalization;\n\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeTypes.REACT_NODE) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeTypes.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: NodeTypes.TRANSLATION, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (\n nodeType === NodeTypes.ENUMERATION ||\n nodeType === NodeTypes.PLURAL ||\n nodeType === NodeTypes.CONDITION\n ) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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: NodeTypes.ARRAY, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeTypes.ARRAY,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA6BA,MAAa,YAAsB;CAAC;CAAY;CAAM;CAAW;AAQjE,MAAa,sBAA4C,EACvD,SAAS,aACT,SACA,iBACI;CACJ,MAAM,EAAE,YAAY;CAGpB,MAAM,UAAU,wBAAwB,aAAa,SAD/B,iBACqD,CAAC;CAC5E,MAAM,EAAE,qBAAqB,yBAAyB;CACtD,MAAM,EAAE,0BAA0B,mBAChC,4BAA4B;CAC9B,MAAM,EAAE,eAAe,cAAc,YAAY,kBAAkB;CACnE,MAAM,WAAW,YAAY,QAAQ;CACrC,MAAM,iBAAiB,aACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,SAAS,gBAAgB,WAAW,EAAE,CAAC;CACvD,MAAM,uBAAuB,qBAAqB,QAAQ;AAE1D,KAAI,CAAC,QAAS,QAAO,gCAAK;AAE1B,KAAI,qBACF,QACE,oBAAC,QAAD;EACE,OAAO,UAAU,MAAM;EACvB;EACA;EACA,WAAU;EACV,eAAe,yBAAyB,QAAQ;EAChD,WAAW;YAEV,oBAAoB,QAAQ,QAAQ,SAAS,GAAG,IAAc;EACxD;AAIb,KAAI,OAAO,YAAY,UAAU;AAC/B,MAAI,aAAa,UAAU,WACzB,QAAO,0CAAE,cAAa;AAGxB,MAAI,aAAa,UAAU,YACzB,QACE,oBAAC,OAAD;GAAK,WAAU;aACZ,QAAQ,KAAK,mBAAmB;AAM/B,WACE,oBAAC,oBAAD;KAEE,SAAS,CAPX,GAAG,SACH;MAAE,MAAM,UAAU;MAAa,KAAK;MAAgB,CAM7B;KACrB,SAAS;KACG;KACZ,EAJK,eAIL;KAEJ;GACE;AAIV,MACE,aAAa,UAAU,eACvB,aAAa,UAAU,UACvB,aAAa,U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AAc;IACR,EACL;;AAIV,MAAI,OAAO,QAAQ,aAAa,SAM9B,QACE,oBAAC,oBAAD;GACE,SAAS,CANX,GAAG,SACH,EAAE,MAAM,QAAQ,UAAU,CAKH;GACrB,SAAS;GACG;GACZ;AAKN,SACE,oBAAC,OAAD;GAAK,WAAU;aAFI,OAAO,KAAK,QAGhB,CAAC,KAAK,QAAQ;IACzB,MAAM,eAA0B,CAC9B,GAAG,SACH;KAAE,MAAM,UAAU;KAAQ;KAAK,CAChC;AAKD,QAF6B,qBADV,wBAAwB,aAAa,aACI,CAEpC,CACtB,QACE,oBAAC,QAAD;KACE,OAAO,GAAG,UAAU,MAAM,MAAM,GAAG;KAEnC,UAAU,cAAc,aAAa;KACrC;KACA;KACA,WAAU;KACV,eAAe,yBAAyB,aAAa;KACrD,WAAW;eAEV,oBAAoB,IAAI;KAClB,EATF,IASE;AAIb,WACE,oBAAC,WAAD;KAEE,OAAO,GAAG,UAAU,MAAM,MAAM,GAAG;KACnC,UAAU,cAAc,aAAa;KACrC,eAAe,yBAAyB,aAAa;KACrD,QAAQ,oBAAoB,IAAI;eAEhC,oBAAC,OAAD;MAAK,WAAU;gBACb,oBAAC,OAAD;OAAK,WAAU;iBACb,oBAAC,oBAAD;QACE,SAAS;QACT,SAAS;QACG;QACZ;OACE;MACF;KACI,EAfL,IAeK;KAEd;GACE;;AAIV,QACE;EAAE;EAEC;EAAS;EAET,KAAK,UAAU,QAAQ;EAAC;EAExB,KAAK,UAAU,QAAQ;EACvB"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { Accordion } from '@components/Accordion';\nimport {\n Button,\n ButtonColor,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { internationalization } from '@intlayer/config/built';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getContentNodeByKeyPath,\n getEmptyNode,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useEditedContentActions,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { LocalDictionaryId } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { ContentNode, Dictionary } from 'intlayer';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { getIsEditableSection } from '../getIsEditableSection';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: ContentNode;\n dictionary: Dictionary;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionary,\n}) => {\n const { locales } = internationalization;\n\n const currentLocale = useEditorLocale();\n const section = getContentNodeByKeyPath(sectionProp, keyPath, currentLocale);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } =\n useFocusUnmergedDictionary();\n const { addNewElement, goToField } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeTypes.REACT_NODE) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeTypes.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: NodeTypes.TRANSLATION, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (\n nodeType === NodeTypes.ENUMERATION ||\n nodeType === NodeTypes.PLURAL ||\n nodeType === NodeTypes.CONDITION\n ) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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: NodeTypes.ARRAY, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n isActive={getIsSelected(childKeyPath)}\n >\n Item {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={JSON.stringify(childKeyPath)}\n label={`${goToField.label.value} ${index}`}\n header={`Item ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeTypes.ARRAY,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionary.localId as LocalDictionaryId,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionary={dictionary}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA6BA,MAAa,YAAsB;CAAC;CAAY;CAAM;CAAW;AAQjE,MAAa,sBAA4C,EACvD,SAAS,aACT,SACA,iBACI;CACJ,MAAM,EAAE,YAAY;CAGpB,MAAM,UAAU,wBAAwB,aAAa,SAD/B,iBACqD,CAAC;CAC5E,MAAM,EAAE,qBAAqB,yBAAyB;CACtD,MAAM,EAAE,0BAA0B,mBAChC,4BAA4B;CAC9B,MAAM,EAAE,eAAe,cAAc,YAAY,kBAAkB;CACnE,MAAM,WAAW,YAAY,QAAQ;CACrC,MAAM,iBAAiB,aACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,SAAS,gBAAgB,WAAW,EAAE,CAAC;CACvD,MAAM,uBAAuB,qBAAqB,QAAQ;CAE1D,IAAI,CAAC,SAAS,OAAO,gCAAK;CAE1B,IAAI,sBACF,OACE,oBAAC,QAAD;EACE,OAAO,UAAU,MAAM;EACvB;EACA;EACA,WAAU;EACV,eAAe,yBAAyB,QAAQ;EAChD,WAAW;YAEV,oBAAoB,QAAQ,QAAQ,SAAS,GAAG,IAAc;EACxD;CAIb,IAAI,OAAO,YAAY,UAAU;EAC/B,IAAI,aAAa,UAAU,YACzB,OAAO,0CAAE,cAAa;EAGxB,IAAI,aAAa,UAAU,aACzB,OACE,oBAAC,OAAD;GAAK,WAAU;aACZ,QAAQ,KAAK,mBAAmB;IAM/B,OACE,oBAAC,oBAAD;KAEE,SAAS,CAPX,GAAG,SACH;MAAE,MAAM,UAAU;MAAa,KAAK;MAAgB,CAM7B;KACrB,SAAS;KACG;KACZ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I;KACP,iBACE,WAAW,SACX,gBACA,YACA,MACD;KACD,yBAAyB,WAAW;;IAEtC,MAAM;cAEL,cAAc;IACR,EACL;;EAIV,IAAI,OAAO,QAAQ,aAAa,UAM9B,OACE,oBAAC,oBAAD;GACE,SAAS,CANX,GAAG,SACH,EAAE,MAAM,QAAQ,UAAU,CAKH;GACrB,SAAS;GACG;GACZ;EAKN,OACE,oBAAC,OAAD;GAAK,WAAU;aAFI,OAAO,KAAK,QAGhB,CAAC,KAAK,QAAQ;IACzB,MAAM,eAA0B,CAC9B,GAAG,SACH;KAAE,MAAM,UAAU;KAAQ;KAAK,CAChC;IAKD,IAF6B,qBADV,wBAAwB,aAAa,aACI,CAEpC,EACtB,OACE,oBAAC,QAAD;KACE,OAAO,GAAG,UAAU,MAAM,MAAM,GAAG;KAEnC,UAAU,cAAc,aAAa;KACrC;KACA;KACA,WAAU;KACV,eAAe,yBAAyB,aAAa;KACrD,WAAW;eAEV,oBAAoB,IAAI;KAClB,EATF,IASE;IAIb,OACE,oBAAC,WAAD;KAEE,OAAO,GAAG,UAAU,MAAM,MAAM,GAAG;KACnC,UAAU,cAAc,aAAa;KACrC,eAAe,yBAAyB,aAAa;KACrD,QAAQ,oBAAoB,IAAI;eAEhC,oBAAC,OAAD;MAAK,WAAU;gBACb,oBAAC,OAAD;OAAK,WAAU;iBACb,oBAAC,oBAAD;QACE,SAAS;QACT,SAAS;QACG;QACZ;OACE;MACF;KACI,EAfL,IAeK;KAEd;GACE;;CAIV,OACE;EAAE;EAEC;EAAS;EAET,KAAK,UAAU,QAAQ;EAAC;EAExB,KAAK,UAAU,QAAQ;EACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeSelector.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getNodeType } from '@intlayer/core/dictionaryManipulator';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { type FC, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Select } from '../Select';\n\ntype NodeTypeSelectorProps = {\n section: ContentNode;\n onValueChange: (keyType: NodeType) => void;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n section,\n onValueChange: onValueChangeProp,\n}) => {\n const {\n multilingual,\n text,\n number,\n boolean,\n node,\n array,\n enumeration,\n plural,\n triggerPlaceHolder,\n nest,\n gender,\n condition,\n markdown,\n insertion,\n reactNode,\n file,\n } = useIntlayer('node-type-selector');\n const nodeType = getNodeType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n onValueChangeProp(keyType);\n };\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger>\n <Select.Value placeholder={triggerPlaceHolder} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeTypes.TRANSLATION}>{multilingual}</Select.Item>\n <Select.Item value={NodeTypes.TEXT}>{text}</Select.Item>\n <Select.Item value={NodeTypes.NUMBER}>{number}</Select.Item>\n <Select.Item value={NodeTypes.BOOLEAN}>{boolean}</Select.Item>\n <Select.Item value={NodeTypes.OBJECT}>{node}</Select.Item>\n <Select.Item value={NodeTypes.ARRAY}>{array}</Select.Item>\n <Select.Item value={NodeTypes.ENUMERATION}>{enumeration}</Select.Item>\n <Select.Item value={NodeTypes.PLURAL}>{plural}</Select.Item>\n <Select.Item value={NodeTypes.GENDER}>{gender}</Select.Item>\n <Select.Item value={NodeTypes.INSERTION}>{insertion}</Select.Item>\n <Select.Item value={NodeTypes.MARKDOWN}>{markdown}</Select.Item>\n <Select.Item value={NodeTypes.NESTED}>{nest}</Select.Item>\n <Select.Item value={NodeTypes.CONDITION}>{condition}</Select.Item>\n <Select.Item value={NodeTypes.REACT_NODE} disabled>\n {reactNode}\n </Select.Item>\n <Select.Item value={NodeTypes.FILE}>{file}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,oBAA+C,EAC1D,SACA,eAAe,wBACX;CACJ,MAAM,EACJ,cACA,MACA,QACA,SACA,MACA,OACA,aACA,QACA,oBACA,MACA,QACA,WACA,UACA,WACA,WACA,SACE,YAAY,qBAAqB;CAErC,MAAM,CAAC,SAAS,cAAc,SADb,YAAY,QAC4B,CAAC;CAE1D,MAAM,iBAAiB,YAAsB;
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getNodeType } from '@intlayer/core/dictionaryManipulator';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { type FC, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Select } from '../Select';\n\ntype NodeTypeSelectorProps = {\n section: ContentNode;\n onValueChange: (keyType: NodeType) => void;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n section,\n onValueChange: onValueChangeProp,\n}) => {\n const {\n multilingual,\n text,\n number,\n boolean,\n node,\n array,\n enumeration,\n plural,\n triggerPlaceHolder,\n nest,\n gender,\n condition,\n markdown,\n insertion,\n reactNode,\n file,\n } = useIntlayer('node-type-selector');\n const nodeType = getNodeType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n onValueChangeProp(keyType);\n };\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger>\n <Select.Value placeholder={triggerPlaceHolder} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeTypes.TRANSLATION}>{multilingual}</Select.Item>\n <Select.Item value={NodeTypes.TEXT}>{text}</Select.Item>\n <Select.Item value={NodeTypes.NUMBER}>{number}</Select.Item>\n <Select.Item value={NodeTypes.BOOLEAN}>{boolean}</Select.Item>\n <Select.Item value={NodeTypes.OBJECT}>{node}</Select.Item>\n <Select.Item value={NodeTypes.ARRAY}>{array}</Select.Item>\n <Select.Item value={NodeTypes.ENUMERATION}>{enumeration}</Select.Item>\n <Select.Item value={NodeTypes.PLURAL}>{plural}</Select.Item>\n <Select.Item value={NodeTypes.GENDER}>{gender}</Select.Item>\n <Select.Item value={NodeTypes.INSERTION}>{insertion}</Select.Item>\n <Select.Item value={NodeTypes.MARKDOWN}>{markdown}</Select.Item>\n <Select.Item value={NodeTypes.NESTED}>{nest}</Select.Item>\n <Select.Item value={NodeTypes.CONDITION}>{condition}</Select.Item>\n <Select.Item value={NodeTypes.REACT_NODE} disabled>\n {reactNode}\n </Select.Item>\n <Select.Item value={NodeTypes.FILE}>{file}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,oBAA+C,EAC1D,SACA,eAAe,wBACX;CACJ,MAAM,EACJ,cACA,MACA,QACA,SACA,MACA,OACA,aACA,QACA,oBACA,MACA,QACA,WACA,UACA,WACA,WACA,SACE,YAAY,qBAAqB;CAErC,MAAM,CAAC,SAAS,cAAc,SADb,YAAY,QAC4B,CAAC;CAE1D,MAAM,iBAAiB,YAAsB;EAC3C,WAAW,QAAQ;EACnB,kBAAkB,QAAQ;;CAG5B,OACE,qBAAC,QAAD;EAAQ,OAAO;EAAwB;YAAvC,CACE,oBAAC,OAAO,SAAR,YACE,oBAAC,OAAO,OAAR,EAAc,aAAa,oBAAsB,GAClC,GACjB,qBAAC,OAAO,SAAR;GACE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAc;IAA2B;GACvE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAO;IAAmB;GACxD,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAS;IAAqB;GAC5D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAU;IAAsB;GAC9D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAS;IAAmB;GAC1D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAQ;IAAoB;GAC1D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAc;IAA0B;GACtE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAS;IAAqB;GAC5D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAS;IAAqB;GAC5D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAY;IAAwB;GAClE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAW;IAAuB;GAChE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAS;IAAmB;GAC1D,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAY;IAAwB;GAClE,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;IAAY;cACvC;IACW;GACd,oBAAC,OAAO,MAAR;IAAa,OAAO,UAAU;cAAO;IAAmB;GACzC,IACV"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../../utils/cn.mjs";
|
|
4
|
+
import { ButtonColor, ButtonVariant } from "../../Button/Button.mjs";
|
|
4
5
|
import { useAuth } from "../../../hooks/useAuth/useAuth.mjs";
|
|
5
6
|
import { useDeleteDictionary, usePushDictionaries, useWriteDictionary } from "../../../hooks/reactQuery.mjs";
|
|
6
|
-
import { ButtonColor, ButtonVariant } from "../../Button/Button.mjs";
|
|
7
7
|
import { Modal, ModalSize } from "../../Modal/Modal.mjs";
|
|
8
8
|
import { Form } from "../../Form/Form.mjs";
|
|
9
9
|
import { useState } from "react";
|
|
10
10
|
import { ArrowUpFromLine, Download, RotateCcw, Save, Trash } from "lucide-react";
|
|
11
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { useDictionariesRecordActions, useEditedContent } from "@intlayer/editor-react";
|
|
13
12
|
import { useIntlayer } from "react-intlayer";
|
|
13
|
+
import { useDictionariesRecordActions, useEditedContent } from "@intlayer/editor-react";
|
|
14
14
|
|
|
15
15
|
//#region src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx
|
|
16
16
|
const SaveForm = ({ dictionary, mode, className, onDelete, onSave, ...props }) => {
|
|
@@ -91,7 +91,7 @@ const SaveForm = ({ dictionary, mode, className, onDelete, onSave, ...props }) =
|
|
|
91
91
|
})]
|
|
92
92
|
})
|
|
93
93
|
}), /* @__PURE__ */ jsxs("form", {
|
|
94
|
-
className: cn("flex justify-end gap-2
|
|
94
|
+
className: cn("flex justify-end gap-2", className),
|
|
95
95
|
...props,
|
|
96
96
|
children: [
|
|
97
97
|
mode.includes("remote") && isDistantDictionary && onDelete && isAuthenticated && /* @__PURE__ */ jsx(Form.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonVariant } from '@components/Button';\nimport { Form } from '@components/Form';\nimport { Modal, ModalSize } from '@components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '@hooks/index';\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { cn } from '@utils/cn';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n onSave?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n onSave,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { mutate: deleteDictionary, isPending: isDeleting } =\n useDeleteDictionary();\n const { mutate: writeDictionary, isPending: isWriting } =\n useWriteDictionary();\n const { mutate: pushDictionaries, isPending: isPushing } =\n usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useIntlayer('save-dictionary-details');\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.localId!];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as unknown as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.localId!]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n writeDictionary(\n {\n dictionary: updatedDictionary,\n },\n {\n onSuccess: () => {\n setLocaleDictionary(editedContent?.[dictionary.localId!]);\n restoreEditedContent(dictionary.localId!);\n setIsFormatAlertModalOpen(false);\n onSave?.();\n },\n }\n );\n };\n\n const handlePushDictionary = () => {\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n pushDictionaries(\n { dictionaries: [updatedDictionary] },\n {\n onSuccess: (res) => {\n if (res) {\n setLocaleDictionary(updatedDictionary);\n restoreEditedContent(dictionary.localId!);\n onSave?.();\n }\n },\n }\n );\n };\n\n const handleDeleteDictionary = () => {\n if (!dictionary.id) return;\n\n deleteDictionary(\n {\n dictionaryId: dictionary.id,\n },\n {\n onSuccess: (res) => {\n if (res) {\n onDelete?.();\n }\n },\n }\n );\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size={ModalSize.MD}\n onClose={() => setIsFormatAlertModalOpen(false)}\n padding=\"md\"\n >\n <form className=\"size-full\">\n <p className=\"py-4 text-neutral text-sm\">{confirmation.message}</p>\n\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n variant={ButtonVariant.OUTLINE}\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color={ButtonColor.ERROR}\n variant={ButtonVariant.OUTLINE}\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.localId!)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color={ButtonColor.TEXT}\n variant={\n isAuthenticated ? ButtonVariant.OUTLINE : ButtonVariant.DEFAULT\n }\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAa,YAAwC,EACnD,YACA,MACA,WACA,UACA,QACA,GAAG,YACC;CACJ,MAAM,CAAC,wBAAwB,6BAA6B,SAAS,MAAM;CAC3E,MAAM,EAAE,wBAAwB,8BAA8B;CAC9D,MAAM,EAAE,QAAQ,kBAAkB,WAAW,eAC3C,qBAAqB;CACvB,MAAM,EAAE,QAAQ,iBAAiB,WAAW,cAC1C,oBAAoB;CACtB,MAAM,EAAE,QAAQ,kBAAkB,WAAW,cAC3C,qBAAqB;CACvB,MAAM,YAAY,aAAa;CAE/B,MAAM,EAAE,eAAe,yBAAyB,kBAAkB;CAClE,MAAM,EACJ,cACA,aACA,YACA,eACA,gBACA,iBACE,YAAY,0BAA0B;CAC1C,MAAM,EAAE,oBAAoB,SAAS;CAErC,MAAM,mBAAmB,gBAAgB,WAAW;CAEpD,MAAM,WACJ,oBACA,KAAK,UAAU,iBAAiB,KAAK,KAAK,UAAU,WAAW;CAEjE,MAAM,sBACJ,OAAQ,YAA6C,OAAO;CAE9D,MAAM,mCAAmC,YAAY;AACn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;YAFN;GAIG,KAAK,SAAS,SAAS,IACtB,uBACA,YACA,mBACE,oBAAC,KAAK,QAAN;IACE,OAAO,aAAa,MAAM;IAC1B,MAAM;IACN;IACA;IACA,WAAU;IACV,WAAW;IACX,SAAS;cAER,aAAa;IACF;GAEjB,YACC,oBAAC,KAAK,QAAN;IACE,OAAO,YAAY,MAAM;IACzB,UAAU,CAAC;IACX,MAAM;IACN;IACA;IACA,WAAU;IACV,eAAe,qBAAqB,WAAW,QAAS;cAEvD,YAAY;IACD;GAEf,KAAK,SAAS,QAAQ,IACrB,oBAAC,KAAK,QAAN;IACE,OAAO,eAAe,MAAM;IAC5B,UAAU,CAAC,YAAY;IACvB,MAAM;IACN;IACA,SACE;IAEF,WAAU;IACV,WAAW;IACX,eAAe,0BAA0B,KAAK;cAE7C,eAAe;IACJ;GAEf,KAAK,SAAS,SAAS,IAAI,mBAAmB,CAAC,uBAC9C,oBAAC,KAAK,QAAN;IACE,OAAO,cAAc,MAAM;IAC3B,UAAU;IACV,MAAM;IACN;IACA,WAAU;IACV,WAAW;IACX,SAAS;cAER,cAAc;IACH;GAEf,KAAK,SAAS,SAAS,IACtB,mBACA,uBACA,YACE,oBAAC,KAAK,QAAN;IACE,OAAO,WAAW,MAAM;IACxB,UAAU,CAAC,YAAY;IACvB,MAAM;IACN,OAAM;IACN,WAAU;IACV,WAAW;IACX,SAAS;cAER,WAAW;IACA;GAEb;IACN"}
|
|
1
|
+
{"version":3,"file":"SaveForm.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport { ButtonColor, ButtonVariant } from '@components/Button';\nimport { Form } from '@components/Form';\nimport { Modal, ModalSize } from '@components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '@hooks/index';\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { cn } from '@utils/cn';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useIntlayer } from 'react-intlayer';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n onSave?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n onSave,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { mutate: deleteDictionary, isPending: isDeleting } =\n useDeleteDictionary();\n const { mutate: writeDictionary, isPending: isWriting } =\n useWriteDictionary();\n const { mutate: pushDictionaries, isPending: isPushing } =\n usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useIntlayer('save-dictionary-details');\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.localId!];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as unknown as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.localId!]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n writeDictionary(\n {\n dictionary: updatedDictionary,\n },\n {\n onSuccess: () => {\n setLocaleDictionary(editedContent?.[dictionary.localId!]);\n restoreEditedContent(dictionary.localId!);\n setIsFormatAlertModalOpen(false);\n onSave?.();\n },\n }\n );\n };\n\n const handlePushDictionary = () => {\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.localId!],\n };\n\n pushDictionaries(\n { dictionaries: [updatedDictionary] },\n {\n onSuccess: (res) => {\n if (res) {\n setLocaleDictionary(updatedDictionary);\n restoreEditedContent(dictionary.localId!);\n onSave?.();\n }\n },\n }\n );\n };\n\n const handleDeleteDictionary = () => {\n if (!dictionary.id) return;\n\n deleteDictionary(\n {\n dictionaryId: dictionary.id,\n },\n {\n onSuccess: (res) => {\n if (res) {\n onDelete?.();\n }\n },\n }\n );\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size={ModalSize.MD}\n onClose={() => setIsFormatAlertModalOpen(false)}\n padding=\"md\"\n >\n <form className=\"size-full\">\n <p className=\"py-4 text-neutral text-sm\">{confirmation.message}</p>\n\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n variant={ButtonVariant.OUTLINE}\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form className={cn('flex justify-end gap-2', className)} {...props}>\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color={ButtonColor.ERROR}\n variant={ButtonVariant.OUTLINE}\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant={ButtonVariant.OUTLINE}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.localId!)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color={ButtonColor.TEXT}\n variant={\n isAuthenticated ? ButtonVariant.OUTLINE : ButtonVariant.DEFAULT\n }\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color={ButtonColor.TEXT}\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAa,YAAwC,EACnD,YACA,MACA,WACA,UACA,QACA,GAAG,YACC;CACJ,MAAM,CAAC,wBAAwB,6BAA6B,SAAS,MAAM;CAC3E,MAAM,EAAE,wBAAwB,8BAA8B;CAC9D,MAAM,EAAE,QAAQ,kBAAkB,WAAW,eAC3C,qBAAqB;CACvB,MAAM,EAAE,QAAQ,iBAAiB,WAAW,cAC1C,oBAAoB;CACtB,MAAM,EAAE,QAAQ,kBAAkB,WAAW,cAC3C,qBAAqB;CACvB,MAAM,YAAY,aAAa;CAE/B,MAAM,EAAE,eAAe,yBAA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],"sources":["../../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content, localId } = dictionary;\n\n const { editedContent } = useEditedContent();\n const initialSection =\n typeof editedContent?.[localId!]?.content === 'undefined'\n ? content\n : editedContent?.[localId!]?.content;\n\n return (\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryLocalId={localId!}\n />\n );\n};\n"],"mappings":";;;;;;;AAWA,MAAa,mBAAwC,EAAE,iBAAiB;CACtE,MAAM,EAAE,SAAS,YAAY;CAE7B,MAAM,EAAE,kBAAkB,kBAAkB;
|
|
1
|
+
{"version":3,"file":"StructureEditor.mjs","names":[],"sources":["../../../../src/components/DictionaryFieldEditor/StructureEditor.tsx"],"sourcesContent":["'use client';\n\nimport { useEditedContent } from '@intlayer/editor-react';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { FC } from 'react';\nimport { NodeView } from './StructureView/StructureView';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const StructureEditor: FC<NodeEditorProps> = ({ dictionary }) => {\n const { content, localId } = dictionary;\n\n const { editedContent } = useEditedContent();\n const initialSection =\n typeof editedContent?.[localId!]?.content === 'undefined'\n ? content\n : editedContent?.[localId!]?.content;\n\n return (\n <NodeView\n section={initialSection}\n keyPath={[]}\n dictionaryLocalId={localId!}\n />\n );\n};\n"],"mappings":";;;;;;;AAWA,MAAa,mBAAwC,EAAE,iBAAiB;CACtE,MAAM,EAAE,SAAS,YAAY;CAE7B,MAAM,EAAE,kBAAkB,kBAAkB;CAM5C,OACE,oBAAC,UAAD;EACE,SANF,OAAO,gBAAgB,UAAW,YAAY,cAC1C,UACA,gBAAgB,UAAW;EAK7B,SAAS,EAAE;EACX,mBAAmB;EACnB"}
|
|
@@ -7,8 +7,8 @@ import { EditableFieldInput } from "../../EditableField/EditableFieldInput.mjs";
|
|
|
7
7
|
import { NodeTypeSelector } from "../NodeTypeSelector.mjs";
|
|
8
8
|
import { Plus, Trash } from "lucide-react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { useConfiguration, useEditedContentActions, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
11
10
|
import { useIntlayer } from "react-intlayer";
|
|
11
|
+
import { useConfiguration, useEditedContentActions, useFocusUnmergedDictionary } from "@intlayer/editor-react";
|
|
12
12
|
import { getDefaultNode, getNodeChildren, getNodeType } from "@intlayer/core/dictionaryManipulator";
|
|
13
13
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
14
14
|
import { isSameKeyPath } from "@intlayer/core/utils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureView.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport { EditableFieldInput } from '@components/EditableField';\nimport { InputVariant } from '@components/Input';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getDefaultNode,\n getNodeChildren,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { LocalDictionaryId, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { ContentNode } from 'intlayer';\nimport { Plus, Trash } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\n\ntype NodeTypeViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryLocalId,\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 === NodeTypes.TRANSLATION ||\n nodeType === NodeTypes.CONDITION ||\n nodeType === NodeTypes.GENDER ||\n nodeType === NodeTypes.ENUMERATION ||\n nodeType === NodeTypes.PLURAL\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 dictionaryLocalId={dictionaryLocalId}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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 dictionaryLocalId={dictionaryLocalId}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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=\"mt-6 ml-10\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryLocalId={dictionaryLocalId}\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 dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryLocalId,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useIntlayer('structure-view');\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryLocalId, 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 overflow-auto px-5 py-2\"\n border\n borderColor=\"text\"\n background=\"none\"\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={InputVariant.INVISIBLE}\n />\n <Button\n label={deleteButton.label.value}\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryLocalId, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"ml-3 text-neutral text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n )}\n <NodeTypeView\n keyPath={keyPath}\n dictionaryLocalId={dictionaryLocalId}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryLocalId, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryLocalId,\n}) => {\n const { addNodeButton } = useIntlayer('structure-view');\n const { setFocusedContentKeyPath } = useFocusUnmergedDictionary();\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 overflow-y-auto\">\n <ul className=\"mr-auto flex flex-col gap-4\">\n {Object.keys(section).map((key) => (\n <li\n key={`${JSON.stringify(keyPath)}-object-${key}`}\n className=\"flex w-full\"\n >\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeTypes.OBJECT, key }]}\n dictionaryLocalId={dictionaryLocalId}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.MD}\n color={ButtonColor.TEXT}\n Icon={Plus}\n className=\"flex-1\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryLocalId, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryLocalId,\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 dictionaryLocalId={dictionaryLocalId}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryLocalId={dictionaryLocalId}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAM,gBAAuC,EAC3C,SACA,mBACA,SACA,kBAAkB,2BACd;CACJ,MAAM,UAAU,kBAAkB,EAAE,sBAAsB,WAAW,EAAE;CACvE,MAAM,WAAW,YAAY,QAAQ;CACrC,MAAM,WAAW,gBAAgB,QAAQ;CAEzC,MAAM,oBAAoB,YAA0B;AAOlD,uBAN2B,eACzB,UACA,SACA,QAGqC,CAAC;;AAG1C,KACE,aAAa,UAAU,eACvB,aAAa,UAAU,aACvB,aAAa,UAAU,UACvB,aAAa,UAAU,eACvB,aAAa,UAAU,QACvB;EACA,MAAM,WAAW,OAAO,KACrB,QAAiC,UACnC,CAAC;EACF,MAAM,kBAAkB,CACtB,GAAG,SACH;GAAE,MAAM;GAAU,KAAK;GAAU,CAClC;AAED,SACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,kBAAD;IACW;IACT,gBAAgB,aACd,qBACE,eAAe,UAAU,QAAQ,CAClC;IAEH,GAEF,oBAAC,cAAD;IACE,SAAS;I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AAM,SAAS;IACf,MAAM,aAAa,CACjB,GAAG,SACH;KAAE,MAAM,UAAU;KAAQ,KAAK;KAAQ,CACxC;AACD,qBAAiB,mBAAmB,IAAI,WAAW;AACnD,6BAAyB,WAAW;;aAGrC,cAAc;GACR,EACL;;;AAUV,MAAa,iBAAyC,EACpD,SACA,SACA,wBACI;AACJ,KACE,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,SAE5B,QACE,oBAAC,UAAD;EACE,YAAY;EACH;EACA;EACU;EACnB;AAIN,QACE,oBAAC,YAAD;EACW;EACA;EACU;EACnB"}
|
|
1
|
+
{"version":3,"file":"StructureView.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport { EditableFieldInput } from '@components/EditableField';\nimport { InputVariant } from '@components/Input';\nimport { camelCaseToSentence } from '@intlayer/config/client';\nimport {\n getDefaultNode,\n getNodeChildren,\n getNodeType,\n} from '@intlayer/core/dictionaryManipulator';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { LocalDictionaryId, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { ContentNode } from 'intlayer';\nimport { Plus, Trash } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\n\ntype NodeTypeViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryLocalId,\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 === NodeTypes.TRANSLATION ||\n nodeType === NodeTypes.CONDITION ||\n nodeType === NodeTypes.GENDER ||\n nodeType === NodeTypes.ENUMERATION ||\n nodeType === NodeTypes.PLURAL\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 dictionaryLocalId={dictionaryLocalId}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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 dictionaryLocalId={dictionaryLocalId}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeTypes.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=\"mt-6 ml-10\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryLocalId={dictionaryLocalId}\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 dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryLocalId,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useIntlayer('structure-view');\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryLocalId, 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 overflow-auto px-5 py-2\"\n border\n borderColor=\"text\"\n background=\"none\"\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={InputVariant.INVISIBLE}\n />\n <Button\n label={deleteButton.label.value}\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryLocalId, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"ml-3 text-neutral text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n )}\n <NodeTypeView\n keyPath={keyPath}\n dictionaryLocalId={dictionaryLocalId}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryLocalId, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryLocalId,\n}) => {\n const { addNodeButton } = useIntlayer('structure-view');\n const { setFocusedContentKeyPath } = useFocusUnmergedDictionary();\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 overflow-y-auto\">\n <ul className=\"mr-auto flex flex-col gap-4\">\n {Object.keys(section).map((key) => (\n <li\n key={`${JSON.stringify(keyPath)}-object-${key}`}\n className=\"flex w-full\"\n >\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeTypes.OBJECT, key }]}\n dictionaryLocalId={dictionaryLocalId}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.MD}\n color={ButtonColor.TEXT}\n Icon={Plus}\n className=\"flex-1\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeTypes.OBJECT, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryLocalId, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryLocalId: LocalDictionaryId;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryLocalId,\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 dictionaryLocalId={dictionaryLocalId}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryLocalId={dictionaryLocalId}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAM,gBAAuC,EAC3C,SACA,mBACA,SACA,kBAAkB,2BACd;CACJ,MAAM,UAAU,kBAAkB,EAAE,sBAAsB,WAAW,EAAE;CACvE,MAAM,WAAW,YAAY,QAAQ;CACrC,MAAM,WAAW,gBAAgB,QAAQ;CAEzC,MAAM,oBAAoB,YAA0B;EAOlD,qBAN2B,eACzB,UACA,SACA,QAGqC,CAAC;;CAG1C,IACE,aAAa,UAAU,eACvB,aAAa,UAAU,aACvB,aAAa,UAAU,UACvB,aAAa,UAAU,eACvB,aAAa,UAAU,QACvB;EACA,MAAM,WAAW,OAAO,KACrB,QAAiC,UACnC,CAAC;EACF,MAAM,kBAAkB,CACtB,GAAG,SACH;GAAE,MAAM;GAAU,KAAK;GAAU,CAClC;EAED,OACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,kBAAD;IACW;IACT,gBAAgB,aACd,qBACE,eAAe,UAAU,QAAQ,CAClC;IAEH,GAEF,oBAAC,cAAD;IACE,SAAS;IACT,SAAS;IACU;IACD;IAClB,EACE;;;CAIV,IAAI,aAAa,UAAU,OAAO;EAChC,MAAM,kBAAkB,CAAC,GAAG,SAAS;GAAE,MAAM;GAAU,KAAK;GAAG,CAAY;EAC3E,OACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,kBAAD;IACW;IACT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ACI;CACJ,IACE,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAE5B,OACE,oBAAC,UAAD;EACE,YAAY;EACH;EACA;EACU;EACnB;CAIN,OACE,oBAAC,YAAD;EACW;EACA;EACU;EACnB"}
|
package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionSwitcher.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport { DropDown, type PanelProps } from '@components/DropDown';\nimport { MoveVertical } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { useVersionSwitcher } from './VersionSwitcherContext';\n\nexport type VersionSwitcherProps = {\n panelProps?: Omit<PanelProps, 'identifier'>;\n};\n\nconst DROPDOWN_IDENTIFIER = 'version-switcher';\n\nexport const VersionSwitcher: FC<VersionSwitcherProps> = ({ panelProps }) => {\n const { switchTo, versionSwitcherLabel, versionListLabel } =\n useIntlayer('version-switcher');\n const { selectedVersion, versions, setSelectedVersion } =\n useVersionSwitcher();\n\n if (versions.length === 0) {\n return <></>;\n }\n\n return (\n <div\n className=\"rounded-xl border border-text text-text transition-colors\"\n aria-label={versionListLabel.value}\n >\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger identifier={DROPDOWN_IDENTIFIER}>\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"px-2\">{selectedVersion ?? 'LTS'}</div>\n <MoveVertical className=\"w-5 self-center\" />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n className=\"right-0 left-auto\"\n {...panelProps}\n >\n <Container\n className=\"max-h-[80vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n border\n roundedSize=\"2xl\"\n borderColor=\"text\"\n aria-label={versionSwitcherLabel.value}\n >\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {versions.reverse().map((version) => (\n <li className=\"px-1.5 py-1\" key={version}>\n <Button\n onClick={() => setSelectedVersion(version)}\n label={`${switchTo} v${version}`}\n isActive={selectedVersion === version}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n size={ButtonSize.SM}\n >\n <div className=\"flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1 text-neutral text-sm\">\n {version}\n </div>\n </Button>\n </li>\n ))}\n </ol>\n </Container>\n </DropDown.Panel>\n </DropDown>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,sBAAsB;AAE5B,MAAa,mBAA6C,EAAE,iBAAiB;CAC3E,MAAM,EAAE,UAAU,sBAAsB,qBACtC,YAAY,mBAAmB;CACjC,MAAM,EAAE,iBAAiB,UAAU,uBACjC,oBAAoB;
|
|
1
|
+
{"version":3,"file":"VersionSwitcher.mjs","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '@components/Button';\nimport { Container } from '@components/Container';\nimport { DropDown, type PanelProps } from '@components/DropDown';\nimport { MoveVertical } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { useVersionSwitcher } from './VersionSwitcherContext';\n\nexport type VersionSwitcherProps = {\n panelProps?: Omit<PanelProps, 'identifier'>;\n};\n\nconst DROPDOWN_IDENTIFIER = 'version-switcher';\n\nexport const VersionSwitcher: FC<VersionSwitcherProps> = ({ panelProps }) => {\n const { switchTo, versionSwitcherLabel, versionListLabel } =\n useIntlayer('version-switcher');\n const { selectedVersion, versions, setSelectedVersion } =\n useVersionSwitcher();\n\n if (versions.length === 0) {\n return <></>;\n }\n\n return (\n <div\n className=\"rounded-xl border border-text text-text transition-colors\"\n aria-label={versionListLabel.value}\n >\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger identifier={DROPDOWN_IDENTIFIER}>\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"px-2\">{selectedVersion ?? 'LTS'}</div>\n <MoveVertical className=\"w-5 self-center\" />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n className=\"right-0 left-auto\"\n {...panelProps}\n >\n <Container\n className=\"max-h-[80vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n border\n roundedSize=\"2xl\"\n borderColor=\"text\"\n aria-label={versionSwitcherLabel.value}\n >\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {versions.reverse().map((version) => (\n <li className=\"px-1.5 py-1\" key={version}>\n <Button\n onClick={() => setSelectedVersion(version)}\n label={`${switchTo} v${version}`}\n isActive={selectedVersion === version}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n size={ButtonSize.SM}\n >\n <div className=\"flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1 text-neutral text-sm\">\n {version}\n </div>\n </Button>\n </li>\n ))}\n </ol>\n </Container>\n </DropDown.Panel>\n </DropDown>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,sBAAsB;AAE5B,MAAa,mBAA6C,EAAE,iBAAiB;CAC3E,MAAM,EAAE,UAAU,sBAAsB,qBACtC,YAAY,mBAAmB;CACjC,MAAM,EAAE,iBAAiB,UAAU,uBACjC,oBAAoB;CAEtB,IAAI,SAAS,WAAW,GACtB,OAAO,gCAAK;CAGd,OACE,oBAAC,OAAD;EACE,WAAU;EACV,cAAY,iBAAiB;YAE7B,qBAAC,UAAD;GAAU,YAAY;aAAtB,CACE,oBAAC,SAAS,SAAV;IAAkB,YAAY;cAC5B,qBAAC,OAAD;KAAK,WAAU;eAAf,CACE,oBAAC,OAAD;MAAK,WAAU;gBAAQ,mBAAmB;MAAY,GACtD,oBAAC,cAAD,EAAc,WAAU,mBAAoB,EACxC;;IACW,GAEnB,oBAAC,SAAS,OAAV;IACE,YAAY;IACZ;IACA;IACA,WAAU;IACV,GAAI;cAEJ,oBAAC,WAAD;KACE,WAAU;KACV,WAAU;KACV,MAAK;KACL,cAAa;KACb;KACA,aAAY;KACZ,aAAY;KACZ,cAAY,qBAAqB;eAEjC,oBAAC,MAAD;MAAI,WAAU;gBACX,SAAS,SAAS,CAAC,KAAK,YACvB,oBAAC,MAAD;OAAI,WAAU;iBACZ,oBAAC,QAAD;QACE,eAAe,mBAAmB,QAAQ;QAC1C,OAAO,GAAG,SAAS,IAAI;QACvB,UAAU,oBAAoB;QAC9B;QACA;QACA;QACA;QACA;kBAEA,oBAAC,OAAD;SAAK,WAAU;mBACZ;SACG;QACC;OACN,EAf4B,QAe5B,CACL;MACC;KACK;IACG,EACR;;EACP"}
|