@intlayer/design-system 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +521 -395
- package/dist/Form-2XHQV7F_.cjs +295 -0
- package/dist/Form-2XHQV7F_.cjs.map +1 -0
- package/dist/Form-BO0i3nT9.js +300 -0
- package/dist/Form-BO0i3nT9.js.map +1 -0
- package/dist/Form-BaHDK0RZ.cjs +298 -0
- package/dist/Form-BaHDK0RZ.cjs.map +1 -0
- package/dist/Form-BfZMqK2D.js +300 -0
- package/dist/Form-BfZMqK2D.js.map +1 -0
- package/dist/Form-C13KWSZs.cjs +299 -0
- package/dist/Form-C13KWSZs.cjs.map +1 -0
- package/dist/Form-C8K2f8ph.js +300 -0
- package/dist/Form-C8K2f8ph.js.map +1 -0
- package/dist/Form-CKvCgz8c.cjs +299 -0
- package/dist/Form-CKvCgz8c.cjs.map +1 -0
- package/dist/Form-Cbk5Lhpd.js +299 -0
- package/dist/Form-Cbk5Lhpd.js.map +1 -0
- package/dist/Form-CiAgFAPb.cjs +300 -0
- package/dist/Form-CiAgFAPb.cjs.map +1 -0
- package/dist/Form-CnBKDneQ.js +296 -0
- package/dist/Form-CnBKDneQ.js.map +1 -0
- package/dist/Form-DERuauvB.cjs +300 -0
- package/dist/Form-DERuauvB.cjs.map +1 -0
- package/dist/Form-DhlDf3ML.cjs +299 -0
- package/dist/Form-DhlDf3ML.cjs.map +1 -0
- package/dist/Form-DkAZ0Jdf.cjs +299 -0
- package/dist/Form-DkAZ0Jdf.cjs.map +1 -0
- package/dist/Form-DqnNP4DA.js +300 -0
- package/dist/Form-DqnNP4DA.js.map +1 -0
- package/dist/Form-DyFBmVya.js +301 -0
- package/dist/Form-DyFBmVya.js.map +1 -0
- package/dist/Form-FW4Odjfm.js +301 -0
- package/dist/Form-FW4Odjfm.js.map +1 -0
- package/dist/components/Accordion/Accordion.d.ts +0 -1
- package/dist/components/Auth/AuthModal/index.d.ts +0 -1
- package/dist/components/Auth/AuthProvider/index.cjs +5 -21
- package/dist/components/Auth/AuthProvider/index.cjs.map +1 -1
- package/dist/components/Auth/AuthProvider/index.d.ts +4 -3
- package/dist/components/Auth/AuthProvider/index.d.ts.map +1 -1
- package/dist/components/Auth/AuthProvider/index.mjs +6 -22
- package/dist/components/Auth/AuthProvider/index.mjs.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.cjs +7 -3
- package/dist/components/Auth/AuthProvider/useSession.cjs.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.d.ts +0 -1
- package/dist/components/Auth/AuthProvider/useSession.d.ts.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.mjs +7 -3
- package/dist/components/Auth/AuthProvider/useSession.mjs.map +1 -1
- package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/accessValidation.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/index.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.mjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/index.content.d.ts +10 -10
- package/dist/components/Auth/ChangePasswordForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/assets/GithubLogo.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/assets/GoogleLogo.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.d.ts +5 -5
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.d.ts +0 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.d.ts +0 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/index.content.d.ts +7 -7
- package/dist/components/Auth/ResetPasswordForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.d.ts +0 -1
- package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
- package/dist/components/Auth/SignInForm/SignInSchema.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/SignInSchema.d.ts +0 -1
- package/dist/components/Auth/SignInForm/SignInSchema.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/index.content.d.ts +13 -13
- package/dist/components/Auth/SignInForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.d.ts +0 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.cjs.map +1 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.d.ts +0 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.mjs.map +1 -1
- package/dist/components/Auth/SignUpForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/SignUpForm/index.content.d.ts +11 -11
- package/dist/components/Auth/SignUpForm/index.content.mjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +0 -1
- package/dist/components/Badge/index.d.ts +1 -2
- package/dist/components/Breadcrumb/index.d.ts +0 -1
- package/dist/components/Button/Button.cjs +1 -0
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +2 -3
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.mjs +1 -0
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Command/index.d.ts +9 -10
- package/dist/components/Command/index.d.ts.map +1 -1
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +16 -3
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +0 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts +0 -1
- package/dist/components/ContentSelector/ContentSelector.d.ts +0 -1
- package/dist/components/CopyToClipboard/index.d.ts +0 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +30 -24
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +0 -7
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +30 -24
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.cjs +1 -0
- package/dist/components/DictionaryEditor/ItemLayout.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.d.ts +0 -1
- package/dist/components/DictionaryEditor/ItemLayout.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.mjs +1 -0
- package/dist/components/DictionaryEditor/ItemLayout.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +7 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +7 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +0 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +111 -19
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts +1 -5
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +112 -20
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.cjs +18 -20
- package/dist/components/DictionaryEditor/useEditedContentStore.cjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts +0 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.mjs +19 -21
- package/dist/components/DictionaryEditor/useEditedContentStore.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditionPanelStore.d.ts +0 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs +67 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts +27 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs +67 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.cjs +8 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.cjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.d.ts +4 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.mjs +8 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +8 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +8 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.d.ts +2 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.d.ts +2 -3
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +37 -13
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +37 -13
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +21 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +21 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +29 -14
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +29 -14
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -0
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -0
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +18 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +18 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +18 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +14 -15
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +14 -15
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveFormSchema.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +12 -12
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +12 -12
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts +0 -1
- package/dist/components/DropDown/index.d.ts +0 -1
- package/dist/components/DropDown/types.d.ts +0 -1
- package/dist/components/EditableField/EditableFieldInput.cjs +12 -5
- package/dist/components/EditableField/EditableFieldInput.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.d.ts +2 -4
- package/dist/components/EditableField/EditableFieldInput.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.mjs +13 -6
- package/dist/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts +0 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs +17 -4
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.d.ts +6 -3
- package/dist/components/EditableField/EditableFieldTextArea.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs +18 -5
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/Flags/Flag.d.ts +0 -1
- package/dist/components/Footer/index.d.ts +0 -1
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.d.ts +2 -1
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Form/Form.mjs +1 -1
- package/dist/components/Form/FormBase.d.ts +0 -1
- package/dist/components/Form/FormBase.d.ts.map +1 -1
- package/dist/components/Form/FormDescription.d.ts +0 -1
- package/dist/components/Form/FormField.d.ts +0 -1
- package/dist/components/Form/FormItem.d.ts +0 -1
- package/dist/components/Form/FormMessage.d.ts +0 -1
- package/dist/components/Form/elements/CheckboxElement.cjs +10 -0
- package/dist/components/Form/elements/CheckboxElement.cjs.map +1 -0
- package/dist/components/Form/elements/CheckboxElement.d.ts +10 -0
- package/dist/components/Form/elements/CheckboxElement.d.ts.map +1 -0
- package/dist/components/Form/elements/CheckboxElement.mjs +10 -0
- package/dist/components/Form/elements/CheckboxElement.mjs.map +1 -0
- package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +0 -1
- package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +0 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/FormElement.cjs +1 -1
- package/dist/components/Form/elements/FormElement.d.ts +0 -1
- package/dist/components/Form/elements/FormElement.mjs +1 -1
- package/dist/components/Form/elements/FormElementWrapper.d.ts +0 -1
- package/dist/components/Form/elements/InputElement.cjs +2 -1
- package/dist/components/Form/elements/InputElement.cjs.map +1 -1
- package/dist/components/Form/elements/InputElement.d.ts +2 -3
- package/dist/components/Form/elements/InputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputElement.mjs +2 -1
- package/dist/components/Form/elements/InputElement.mjs.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs +2 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.d.ts +2 -3
- package/dist/components/Form/elements/InputPasswordElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs +2 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs.map +1 -1
- package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.d.ts +0 -1
- package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
- package/dist/components/Form/elements/SelectElement.cjs +1 -1
- package/dist/components/Form/elements/SelectElement.d.ts +0 -1
- package/dist/components/Form/elements/SelectElement.mjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.d.ts +0 -1
- package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.d.ts +0 -1
- package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/index.cjs +1 -1
- package/dist/components/Form/elements/index.mjs +1 -1
- package/dist/components/Form/index.cjs +1 -1
- package/dist/components/Form/index.mjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.d.ts +1 -2
- package/dist/components/Form/layout/FormItemLayout.d.ts.map +1 -1
- package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
- package/dist/components/Form/layout/FormLabelLayout.d.ts +0 -1
- package/dist/components/Form/layout/RequiredStar.d.ts +0 -1
- package/dist/components/Form/layout/index.cjs +1 -1
- package/dist/components/Form/layout/index.mjs +1 -1
- package/dist/components/Headers/index.d.ts +0 -1
- package/dist/components/IDE/CodeRender.cjs.map +1 -1
- package/dist/components/IDE/CodeRender.d.ts +0 -1
- package/dist/components/IDE/CodeRender.mjs.map +1 -1
- package/dist/components/IDE/FileList.d.ts +0 -1
- package/dist/components/IDE/FileTree.d.ts +0 -1
- package/dist/components/IDE/IDE.d.ts +0 -1
- package/dist/components/IDE/MarkDownRender.d.ts +0 -1
- package/dist/components/InformationTag/index.d.ts +0 -1
- package/dist/components/Input/Checkbox.cjs +80 -0
- package/dist/components/Input/Checkbox.cjs.map +1 -0
- package/dist/components/Input/Checkbox.d.ts +14 -0
- package/dist/components/Input/Checkbox.d.ts.map +1 -0
- package/dist/components/Input/Checkbox.mjs +80 -0
- package/dist/components/Input/Checkbox.mjs.map +1 -0
- package/dist/components/Input/Input.d.ts +0 -1
- package/dist/components/Input/InputPassword.d.ts +0 -1
- package/dist/components/Input/index.cjs +3 -0
- package/dist/components/Input/index.cjs.map +1 -1
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.mjs +3 -0
- package/dist/components/Input/index.mjs.map +1 -1
- package/dist/components/Label/index.d.ts +0 -1
- package/dist/components/Link/Link.cjs +7 -2
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.d.ts +3 -3
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Link/Link.mjs +7 -2
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/index.d.ts +0 -1
- package/dist/components/Loader/spinner.d.ts +0 -1
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts +0 -1
- package/dist/components/Logo/LogoCircle.d.ts +0 -1
- package/dist/components/Logo/LogoNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoSquare.d.ts +0 -1
- package/dist/components/Logo/LogoSquircle.d.ts +0 -1
- package/dist/components/Logo/LogoTextOnly.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowCircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowSquircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextCircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextSquircle.d.ts +0 -1
- package/dist/components/Logo/index.d.ts +0 -1
- package/dist/components/MarkDownRender/index.d.ts +0 -1
- package/dist/components/MaxHeightSmoother/index.d.ts +0 -1
- package/dist/components/MaxWidthSmoother/index.d.ts +0 -1
- package/dist/components/Modal/Modal.cjs +19 -15
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +3 -3
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +19 -15
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/Burger.d.ts +0 -1
- package/dist/components/Navbar/DesktopNavbar.cjs +10 -26
- package/dist/components/Navbar/DesktopNavbar.cjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.d.ts +6 -6
- package/dist/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.mjs +10 -26
- package/dist/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +3 -57
- package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.d.ts +6 -7
- package/dist/components/Navbar/MobileNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs +3 -57
- package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/components/Navbar/index.cjs +4 -2
- package/dist/components/Navbar/index.cjs.map +1 -1
- package/dist/components/Navbar/index.d.ts +9 -15
- package/dist/components/Navbar/index.d.ts.map +1 -1
- package/dist/components/Navbar/index.mjs +4 -2
- package/dist/components/Navbar/index.mjs.map +1 -1
- package/dist/components/Pattern/DotPattern.d.ts +0 -1
- package/dist/components/Pattern/GridPattern.d.ts +0 -1
- package/dist/components/Pattern/SpotLight.d.ts +0 -1
- package/dist/components/Popover/index.d.ts +0 -1
- package/dist/components/PressableSpan/PressableSpan.d.ts +0 -1
- package/dist/components/ProfileDropDown/index.d.ts +0 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts +0 -1
- package/dist/components/Select/Multiselect.d.ts +2 -3
- package/dist/components/Select/Multiselect.d.ts.map +1 -1
- package/dist/components/SwitchSelector/index.d.ts +1 -2
- package/dist/components/TabSelector/TabSelector.cjs +2 -0
- package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
- package/dist/components/TabSelector/TabSelector.d.ts +2 -3
- package/dist/components/TabSelector/TabSelector.d.ts.map +1 -1
- package/dist/components/TabSelector/TabSelector.mjs +2 -0
- package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.d.ts +0 -1
- package/dist/components/TextArea/TextArea.cjs +1 -0
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +0 -1
- package/dist/components/TextArea/TextArea.mjs +1 -0
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.d.ts +0 -1
- package/dist/components/ThemeSwitcherDropDown/MobileThemeSwitcher.d.ts +0 -1
- package/dist/components/Toaster/Toast.d.ts +1 -1
- package/dist/components/Toaster/useToast.d.ts +0 -1
- package/dist/components/WithResizer/index.d.ts +0 -1
- package/dist/components/index.cjs +4 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +4 -3
- package/dist/hooks/intlayerAPIHooks.cjs +16 -3
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +0 -1
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +16 -3
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.cjs +1 -5
- package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsync.mjs +1 -5
- package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncWrapper.d.ts +0 -1
- package/dist/hooks/useGetAllDictionaries.d.ts +0 -1
- package/dist/hooks/useItemSelector.d.ts +0 -1
- package/dist/index-BUDsCMdX.cjs +204 -0
- package/dist/index-BUDsCMdX.cjs.map +1 -0
- package/dist/index-C09rI9kw.js +205 -0
- package/dist/index-C09rI9kw.js.map +1 -0
- package/dist/libs/intlayer-api/auth.d.ts +0 -1
- package/dist/libs/intlayer-api/dictionary.d.ts +0 -1
- package/dist/libs/intlayer-api/fetcher.cjs +1 -6
- package/dist/libs/intlayer-api/fetcher.cjs.map +1 -1
- package/dist/libs/intlayer-api/fetcher.d.ts.map +1 -1
- package/dist/libs/intlayer-api/fetcher.mjs +1 -6
- package/dist/libs/intlayer-api/fetcher.mjs.map +1 -1
- package/dist/libs/intlayer-api/index.d.ts +0 -1
- package/dist/libs/intlayer-api/organization.d.ts +0 -1
- package/dist/libs/intlayer-api/project.d.ts +0 -1
- package/dist/libs/intlayer-api/user.d.ts +0 -1
- package/dist/tailwind.css +1 -1
- package/dist/utils/cn.d.ts +0 -1
- package/dist/utils/dictionary.cjs +37 -1
- package/dist/utils/dictionary.cjs.map +1 -1
- package/dist/utils/dictionary.d.ts +1 -1
- package/dist/utils/dictionary.d.ts.map +1 -1
- package/dist/utils/dictionary.mjs +38 -2
- package/dist/utils/dictionary.mjs.map +1 -1
- package/dist/validDictionaryChangeButtons.content-BK9QaXPm.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-BK9QaXPm.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-CAAscqJI.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-CAAscqJI.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-D7AvoBdl.js +67 -0
- package/dist/validDictionaryChangeButtons.content-D7AvoBdl.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-DQwoUNCC.cjs +45 -0
- package/dist/validDictionaryChangeButtons.content-DQwoUNCC.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-DQxPoIe6.js +67 -0
- package/dist/validDictionaryChangeButtons.content-DQxPoIe6.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-JUcjGdBx.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-JUcjGdBx.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-ejY3-sbG.js +67 -0
- package/dist/validDictionaryChangeButtons.content-ejY3-sbG.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-iyT0lKy7.js +46 -0
- package/dist/validDictionaryChangeButtons.content-iyT0lKy7.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-u4qShrQh.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-u4qShrQh.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-y4up9NU8.js +67 -0
- package/dist/validDictionaryChangeButtons.content-y4up9NU8.js.map +1 -0
- package/dist/zod-BV4nCGJE.js.map +1 -1
- package/dist/zod-DSrtTSD_.cjs.map +1 -1
- package/package.json +81 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n type RecursiveDictionaryValue,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n\n return (\n <table className=\"w-full gap-2\">\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full border-y-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionaryKey, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionaryKey, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n <Button\n label={addNewEnumeration.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const setFocusedContentKeyPath = useEditionPanelStore(\n (s) => s.setFocusedContentKeyPath\n );\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","jsxs","jsx","F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AAA,EAEJ;AAEA,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
|
|
1
|
+
{"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody>\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full border-y-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionaryKey, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionaryKey, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","jsx","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;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AChB,iBAAiB,eAAe,UAAU,OAAO;AAAA,QAGlD,UAAA;AAAA,MAAA;AAAA,IAEL,EAAA,CAAA;AAAA,EAEJ;AAEA,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("../../jsx-runtime-DvCoRj5u.cjs");
|
|
|
5
5
|
const require$$0 = require("react");
|
|
6
6
|
const components_Input_Input = require("../Input/Input.cjs");
|
|
7
7
|
require("../Input/InputPassword.cjs");
|
|
8
|
+
require("../Input/Checkbox.cjs");
|
|
8
9
|
require("../Select/Multiselect.cjs");
|
|
9
10
|
const components_Select_Select = require("../Select/Select.cjs");
|
|
10
11
|
const extractInitialState = (value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumKeyInput.cjs","sources":["../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useMemo, useState, type FC } 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;\n let numberValue;\n\n if (typeof value === '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 defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"w-full\"\n />\n </div>\n );\n};\n"],"names":["useMemo","useState","useEffect","jsxs","Select","jsx","Input"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumKeyInput.cjs","sources":["../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useMemo, useState, type FC } 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;\n let numberValue;\n\n if (typeof value === '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 defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"w-full\"\n />\n </div>\n );\n};\n"],"names":["useMemo","useState","useEffect","jsxs","Select","jsx","Input"],"mappings":";;;;;;;;;;AAMA,MAAM,sBAAsB,CAC1B,UACwE;AACpE,MAAA;AACA,MAAA;AAEA,MAAA,OAAO,UAAU,YAAY,CAAC,MAAM,OAAO,KAAK,CAAC,GAAG;A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AAA,QAAAC,iDAACD,yBAAAA,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,yDAC3BA,yBAAAA,OAAO,MAAP,EAAY,OAAM,MAAM,UAAK,MAAA;AAAA,yDAC7BA,yBAAAA,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,yDAC3BA,yBAAAA,OAAO,MAAP,EAAY,OAAM,MAAM,UAAK,MAAA;AAAA,yDAC7BA,yBAAAA,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,MAAA,GAC9B;AAAA,IAAA,GACF;AAAA,IACAC,2BAAA,kBAAA;AAAA,MAACC,uBAAA;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,cAAc,eAAe;AAAA,QAC7B,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,QAC9C,WAAU;AAAA,MAAA;AAAA,IACZ;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
|
|
@@ -3,6 +3,7 @@ import { j as jsxRuntimeExports } from "../../jsx-runtime-BgSF1HG2.js";
|
|
|
3
3
|
import { useMemo, useState, useEffect } from "react";
|
|
4
4
|
import { Input } from "../Input/Input.mjs";
|
|
5
5
|
import "../Input/InputPassword.mjs";
|
|
6
|
+
import "../Input/Checkbox.mjs";
|
|
6
7
|
import "../Select/Multiselect.mjs";
|
|
7
8
|
import { Select } from "../Select/Select.mjs";
|
|
8
9
|
const extractInitialState = (value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumKeyInput.mjs","sources":["../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useMemo, useState, type FC } 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;\n let numberValue;\n\n if (typeof value === '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 defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"w-full\"\n />\n </div>\n );\n};\n"],"names":["jsxs","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumKeyInput.mjs","sources":["../../../src/components/DictionaryFieldEditor/EnumKeyInput.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useMemo, useState, type FC } 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;\n let numberValue;\n\n if (typeof value === '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 defaultValue={numberValue ?? undefined}\n onChange={(e) => setNumberValue(e.target.value)}\n className=\"w-full\"\n />\n </div>\n );\n};\n"],"names":["jsxs","jsx"],"mappings":";;;;;;;;AAMA,MAAM,sBAAsB,CAC1B,UACwE;AACpE,MAAA;AACA,MAAA;AAEA,MAAA,OAAO,UAAU,YAAY,CAAC,MAAM,OAAO,KAAK,CAAC,GAAG;AAEzC,iBAAA;AACb,kBAAc,MAAM;EAAS,WACpB,OAAO,UAAU,UAAU;AAEpC,UAAM,cAAc,CAAC,MAAM,MAAM,KAAK,KAAK,GAAG;AAE9C,UAAM,oBAAoB,YAAY;AAAA,MAAK,CAAC,SAC1C,MAAM,WAAW,IAAI;AAAA,IAAA;AAEvB,QAAI,mBAAmB;AACR,mBAAA;AACC,oBAAA,MAAM,MAAM,kBAAkB,MAAM;AAAA,IACpD;AAAA,EACF;AAEO,SAAA,EAAE,YAAY;AACvB;AAkBO,MAAM,eAAsC,CAAC,EAAE,OAAO,eAAe;AAC1E,QAAM,EAAE,YAAY,mBAAmB,aAAa,mBAAmB,IACrE,QAAQ,MAAM,oBAAoB,KAAK,GAAG,CAAC,KAAK,CAAC;AAC7C,QAAA,CAAC,YAAY,aAAa,IAAI;AAAA,IAClC,qBAAqB;AAAA,EAAA;AAEjB,QAAA,CAAC,aAAa,cAAc,IAAI;AAAA,IACpC,sBAAsB;AAAA,EAAA;AAGxB,YAAU,MAAM;AACd,QACE,cACA,gBACC,eAAe,qBAAqB,gBAAgB,qBACrD;AACA,YAAM,WAAW,GAAG,UAAU,GAAG,WAAW;AAE5C,eAAS,QAAQ;AAAA,IACnB;AAAA,EAAA,GACC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGC,SAAAA,kCAAA,KAAC,OAAI,EAAA,WAAU,cACb,UAAA;AAAA,IAAAA,kCAAA,KAAC,QAAO,EAAA,eAAe,eAAe,cAAc,mBAClD,UAAA;AAAA,MAACC,kCAAAA,IAAA,OAAO,SAAP,EAAe,WAAU,QACxB,UAACA,sCAAA,OAAO,OAAP,EAAa,aAAY,sBAAA,CAAsB,EAClD,CAAA;AAAA,MACAD,kCAAAA,KAAC,OAAO,SAAP,EACC,UAAA;AAAA,QAAAC,sCAAC,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,8CAC3B,OAAO,MAAP,EAAY,OAAM,MAAM,UAAK,MAAA;AAAA,8CAC7B,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,8CAC3B,OAAO,MAAP,EAAY,OAAM,MAAM,UAAK,MAAA;AAAA,8CAC7B,OAAO,MAAP,EAAY,OAAM,KAAK,UAAI,KAAA;AAAA,MAAA,GAC9B;AAAA,IAAA,GACF;AAAA,IACAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,cAAc,eAAe;AAAA,QAC7B,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,QAC9C,WAAU;AAAA,MAAA;AAAA,IACZ;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -14,8 +14,24 @@ const components_DictionaryEditor_useEditedContentStore = require("../../Diction
|
|
|
14
14
|
const components_DictionaryEditor_useEditionPanelStore = require("../../DictionaryEditor/useEditionPanelStore.cjs");
|
|
15
15
|
require("clsx");
|
|
16
16
|
require("tailwind-merge");
|
|
17
|
-
require("../../
|
|
18
|
-
require("../../
|
|
17
|
+
require("../../EditableField/EditableFieldInput.cjs");
|
|
18
|
+
require("../../EditableField/EditableFieldTextArea.cjs");
|
|
19
|
+
require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
20
|
+
require("../../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
21
|
+
require("../../Auth/AuthProvider/index.cjs");
|
|
22
|
+
require("../../../libs/intlayer-api/auth.cjs");
|
|
23
|
+
require("../../../libs/intlayer-api/dictionary.cjs");
|
|
24
|
+
require("../../../libs/intlayer-api/organization.cjs");
|
|
25
|
+
require("../../../libs/intlayer-api/project.cjs");
|
|
26
|
+
require("../../../libs/intlayer-api/user.cjs");
|
|
27
|
+
require("@intlayer/dictionaries-entry");
|
|
28
|
+
require("deepmerge");
|
|
29
|
+
require("../../Form/FormBase.cjs");
|
|
30
|
+
require("../../Form/FormField.cjs");
|
|
31
|
+
require("../../../Form-DERuauvB.cjs");
|
|
32
|
+
require("../../Toaster/Toast.cjs");
|
|
33
|
+
require("../../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
|
|
34
|
+
require("zod");
|
|
19
35
|
const components_DictionaryFieldEditor_getIsEditableSection = require("../getIsEditableSection.cjs");
|
|
20
36
|
const components_DictionaryFieldEditor_NavigationView_navigationViewNode_content = require("./navigationViewNode.content.cjs");
|
|
21
37
|
const traceKeys = ["filePath", "id", "nodeType"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, useMemo, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n (s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n })\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n identifier={translationKey}\n label={`${goToTranslation.label.value} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToEnumeration.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label.value} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n identifier={`${index}`}\n label={`${goToElement.label.value} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\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=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getDictionaryValueByKeyPath","useEditedContentStore","useEditionPanelStore","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,iBAAAA,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmBC,kDAAAA,sBAAsB,CAAC,MAAM,EAAE,gBAAgB;AAClE,QAAA,EAAE,0BAA0B,eAAA,IAAmBC,iDAAA;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA;AAAA,IACJ;AAAA,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AAA,QAAA;AAAA,MACf;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AAEA,SACID,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EACzB,EAAA,CAAA;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n (s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n })\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n identifier={translationKey}\n label={`${goToTranslation.label.value} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToEnumeration.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label.value} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n identifier={`${index}`}\n label={`${goToElement.label.value} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\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=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getDictionaryValueByKeyPath","useEditedContentStore","useEditionPanelStore","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,iBAAAA,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmBC,kDAAAA,sBAAsB,CAAC,MAAM,EAAE,gBAAgB;AAClE,QAAA,EAAE,0BAA0B,eAAA,IAAmBC,iDAAA;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEC,cAAAA,cAAcC,2EAAAA,qBAAqB;AACjC,QAAA,WAAWC,gCAAe,OAAO;AACjC,QAAA,oBAAoBC,2EAAqB,OAAO;AACtD,QAAM,gBAAgBC,WAAA;AAAA,IACpB,CAACC,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzCC,KAAA,cAAcD,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAAA;AAGtB,MAAA,kBAA0B,QAAAE,iDAAAC,WAAAA,kBAAAA,UAAA,EAAE,UAAC,IAAA,CAAA;AAE7B,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AM,KAAK,IAAI,GAAG;AAAA,YACtC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,QAAQG,oCAAoB,GAAG;AAAA,YAE/B,2DAAC,OAAI,EAAA,WAAU,0BACb,UAACR,2BAAA,kBAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA,kBAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT;AAAA,cAAA;AAAA,eAEJ,EACF,CAAA;AAAA,UAAA;AAAA,UAfK;AAAA,QAAA;AAAA,MAgBP,CAEH;AAAA,MAEDA,2BAAA,kBAAA;AAAA,QAACG,yBAAA;AAAA,QAAA;AAAA,UACC,OAAO,YAAY,MAAM;AAAA,UACzB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAMD,KAAS,SAAA,QAAQ,KAAK,WAAW;AAAA,YAAA;AAE3C,6BAAiB,eAAe,CAAA,GAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAMK,YAAA;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MACf;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AAEA,SACID,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EACzB,EAAA,CAAA;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAe,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAiB7C,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAoTnD,CAAC"}
|
|
@@ -12,8 +12,24 @@ import { useEditedContentStore } from "../../DictionaryEditor/useEditedContentSt
|
|
|
12
12
|
import { useEditionPanelStore } from "../../DictionaryEditor/useEditionPanelStore.mjs";
|
|
13
13
|
import "clsx";
|
|
14
14
|
import "tailwind-merge";
|
|
15
|
-
import "../../
|
|
16
|
-
import "../../
|
|
15
|
+
import "../../EditableField/EditableFieldInput.mjs";
|
|
16
|
+
import "../../EditableField/EditableFieldTextArea.mjs";
|
|
17
|
+
import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
18
|
+
import "../../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
19
|
+
import "../../Auth/AuthProvider/index.mjs";
|
|
20
|
+
import "../../../libs/intlayer-api/auth.mjs";
|
|
21
|
+
import "../../../libs/intlayer-api/dictionary.mjs";
|
|
22
|
+
import "../../../libs/intlayer-api/organization.mjs";
|
|
23
|
+
import "../../../libs/intlayer-api/project.mjs";
|
|
24
|
+
import "../../../libs/intlayer-api/user.mjs";
|
|
25
|
+
import "@intlayer/dictionaries-entry";
|
|
26
|
+
import "deepmerge";
|
|
27
|
+
import "../../Form/FormBase.mjs";
|
|
28
|
+
import "../../Form/FormField.mjs";
|
|
29
|
+
import "../../../Form-DyFBmVya.js";
|
|
30
|
+
import "../../Toaster/Toast.mjs";
|
|
31
|
+
import "../../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
|
|
32
|
+
import "zod";
|
|
17
33
|
import { getIsEditableSection } from "../getIsEditableSection.mjs";
|
|
18
34
|
import { navigationViewContent } from "./navigationViewNode.content.mjs";
|
|
19
35
|
const traceKeys = ["filePath", "id", "nodeType"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, useMemo, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n (s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n })\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n identifier={translationKey}\n label={`${goToTranslation.label.value} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToEnumeration.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label.value} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n identifier={`${index}`}\n label={`${goToElement.label.value} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\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=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;AAyBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB;AAClE,QAAA,EAAE,0BAA0B,eAAA,IAAmB;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,eAAe,OAAO;AACjC,QAAA,oBAAoB,qBAAqB,OAAO;AACtD,QAAM,gBAAgB;AAAA,IACpB,CAACA,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAAA;AAGtB,MAAA,kBAA0B,QAAAC,sCAAAC,kBAAAA,UAAA,EAAE,UAAC,IAAA,CAAA;AAE7B,MAAA,OAAO,YAAY,UAAU;AAC3B,QAAA,aAAa,SAAS,aAAa;AACrC,mDACG,OAAI,EAAA,WAAU,uCACZ,UAAQ,QAAA,IAAI,CAAC,mBAAmB;AAC/B,cAAM,eAA0B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;AAAA,UACzB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAAA;AAE3C,6BAAiB,eAAe,CAAA,GAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MACf;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AAEA,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EACzB,EAAA,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n (s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n })\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n identifier={translationKey}\n label={`${goToTranslation.label.value} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToEnumeration.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label.value} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n identifier={`${index}`}\n label={`${goToElement.label.value} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\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=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n identifier={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB;AAClE,QAAA,EAAE,0BAA0B,eAAA,IAAmB;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,eAAe,OAAO;AACjC,QAAA,oBAAoB,qBAAqB,OAAO;AACtD,QAAM,gBAAgB;AAAA,IACpB,CAACA,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAAA;AAGtB,MAAA,kBAA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AAA,gBACC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT;AAAA,cAAA;AAAA,eAEJ,EACF,CAAA;AAAA,UAAA;AAAA,UAfK;AAAA,QAAA;AAAA,MAgBP,CAEH;AAAA,MAEDA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO,YAAY,MAAM;AAAA,UACzB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAAA;AAE3C,6BAAiB,eAAe,CAAA,GAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MACf;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AAEA,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EACzB,EAAA,CAAA;AAEJ;"}
|
|
@@ -13,8 +13,24 @@ require("lucide-react");
|
|
|
13
13
|
require("clsx");
|
|
14
14
|
require("tailwind-merge");
|
|
15
15
|
require("../Button/Button.cjs");
|
|
16
|
-
require("../
|
|
17
|
-
require("../
|
|
16
|
+
require("../EditableField/EditableFieldInput.cjs");
|
|
17
|
+
require("../EditableField/EditableFieldTextArea.cjs");
|
|
18
|
+
require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
19
|
+
require("../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
20
|
+
require("../Auth/AuthProvider/index.cjs");
|
|
21
|
+
require("../../libs/intlayer-api/auth.cjs");
|
|
22
|
+
require("../../libs/intlayer-api/dictionary.cjs");
|
|
23
|
+
require("../../libs/intlayer-api/organization.cjs");
|
|
24
|
+
require("../../libs/intlayer-api/project.cjs");
|
|
25
|
+
require("../../libs/intlayer-api/user.cjs");
|
|
26
|
+
require("@intlayer/dictionaries-entry");
|
|
27
|
+
require("deepmerge");
|
|
28
|
+
require("../Form/FormBase.cjs");
|
|
29
|
+
require("../Form/FormField.cjs");
|
|
30
|
+
require("../../Form-DERuauvB.cjs");
|
|
31
|
+
require("../Toaster/Toast.cjs");
|
|
32
|
+
require("../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
|
|
33
|
+
require("zod");
|
|
18
34
|
require("../Select/Multiselect.cjs");
|
|
19
35
|
const components_Select_Select = require("../Select/Select.cjs");
|
|
20
36
|
const components_DictionaryFieldEditor_nodeTypeSelector_content = require("./nodeTypeSelector.content.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeSelector.cjs","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type DictionaryValue,\n type EnumerationContent,\n type KeyPath,\n NodeType,\n type TranslationContent,\n} from '@intlayer/core';\nimport { type FC, useEffect, useState } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../utils/dictionary';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { Select } from '../Select';\nimport { nodeTypeSelectorContent } from './nodeTypeSelector.content';\n\ntype NodeTypeSelectorProps = {\n keyPath: KeyPath[];\n dictionaryKey: string;\n section: DictionaryValue;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n keyPath,\n dictionaryKey,\n section,\n}) => {\n const {\n multilingualText,\n text,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n } = useDictionary(nodeTypeSelectorContent);\n const nodeType = getSectionType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n const { addEditedContent } = useEditedContentStore((s) => ({\n addEditedContent: s.addEditedContent,\n }));\n const { locales } = getConfiguration().internationalization;\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n\n switch (keyType) {\n case NodeType.Translation:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: '',\n }))\n ),\n } as TranslationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Enumeration:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': '',\n '>1': '',\n },\n } as EnumerationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Object:\n addEditedContent(dictionaryKey, {}, keyPath);\n break;\n case NodeType.Array:\n addEditedContent(dictionaryKey, [''], keyPath);\n break;\n case NodeType.Text:\n addEditedContent(dictionaryKey, '', keyPath);\n break;\n default:\n addEditedContent(dictionaryKey, {}, keyPath);\n }\n };\n\n useEffect(() => {\n setKeyType(nodeType);\n }, [nodeType]);\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger className=\"w-40\">\n <Select.Value placeholder={triggerPlaceHolder.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>\n {multilingualText}\n </Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"names":["useDictionary","nodeTypeSelectorContent","getSectionType","useState","useEditedContentStore","getConfiguration","keyType","NodeType","useEffect","jsxs","Select","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.cjs","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type DictionaryValue,\n type EnumerationContent,\n type KeyPath,\n NodeType,\n type TranslationContent,\n} from '@intlayer/core';\nimport { type FC, useEffect, useState } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../utils/dictionary';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { Select } from '../Select';\nimport { nodeTypeSelectorContent } from './nodeTypeSelector.content';\n\ntype NodeTypeSelectorProps = {\n keyPath: KeyPath[];\n dictionaryKey: string;\n section: DictionaryValue;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n keyPath,\n dictionaryKey,\n section,\n}) => {\n const {\n multilingualText,\n text,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n } = useDictionary(nodeTypeSelectorContent);\n const nodeType = getSectionType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n const { addEditedContent } = useEditedContentStore((s) => ({\n addEditedContent: s.addEditedContent,\n }));\n const { locales } = getConfiguration().internationalization;\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n\n switch (keyType) {\n case NodeType.Translation:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: '',\n }))\n ),\n } as TranslationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Enumeration:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': '',\n '>1': '',\n },\n } as EnumerationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Object:\n addEditedContent(dictionaryKey, {}, keyPath);\n break;\n case NodeType.Array:\n addEditedContent(dictionaryKey, [''], keyPath);\n break;\n case NodeType.Text:\n addEditedContent(dictionaryKey, '', keyPath);\n break;\n default:\n addEditedContent(dictionaryKey, {}, keyPath);\n }\n };\n\n useEffect(() => {\n setKeyType(nodeType);\n }, [nodeType]);\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger className=\"w-40\">\n <Select.Value placeholder={triggerPlaceHolder.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>\n {multilingualText}\n </Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"names":["useDictionary","nodeTypeSelectorContent","getSectionType","useState","useEditedContentStore","getConfiguration","keyType","NodeType","useEffect","jsxs","Select","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEA,cAAAA,cAAcC,0DAAAA,uBAAuB;AACnC,QAAA,WAAWC,gCAAe,OAAO;AACvC,QAAM,CAAC,SAAS,UAAU,IAAIC,oBAAmB,QAAQ;AACzD,QAAM,EAAE,iBAAA,IAAqBC,kDAAA,sBAAsB,CAAC,OAAO;AAAA,IACzD,kBAAkB,EAAE;AAAA,EACpB,EAAA;AACF,QAAM,EAAE,QAAA,IAAYC,OAAA,iBAAA,EAAmB;AAEjC,QAAA,gBAAgB,CAACC,aAAsB;AAC3C,eAAWA,QAAO;AAElB,YAAQA,UAAS;AAAA,MACf,KAAKC,KAAS,SAAA;AACZ;AAAA,UACE;AAAA,UACA;AAAA,YACE,UAAUA,KAAS,SAAA;AAAA,YACnB,CAACA,KAAA,SAAS,WAAW,GAAG,OAAO;AAAA,cAC7B,CAAC;AAAA,cACD,GAAG,QAAQ,IAAI,CAAC,YAAY;AAAA,gBAC1B,CAAC,MAAM,GAAG;AAAA,cAAA,EACV;AAAA,YACJ;AAAA,UACF;AAAA,UACA;AAAA,QAAA;AAEF;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CG,yBAAAA,OAAO,MAAP,EAAY,OAAOH,KAAAA,SAAS,aAAc,UAAY,aAAA;AAAA,IAAA,GACzD;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeSelector.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,OAAO,EAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,EAAuB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,OAAO,EAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,EAAuB,MAAM,OAAO,CAAC;AAQrD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAsFtD,CAAC"}
|
|
@@ -11,8 +11,24 @@ import "lucide-react";
|
|
|
11
11
|
import "clsx";
|
|
12
12
|
import "tailwind-merge";
|
|
13
13
|
import "../Button/Button.mjs";
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
14
|
+
import "../EditableField/EditableFieldInput.mjs";
|
|
15
|
+
import "../EditableField/EditableFieldTextArea.mjs";
|
|
16
|
+
import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
17
|
+
import "../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
18
|
+
import "../Auth/AuthProvider/index.mjs";
|
|
19
|
+
import "../../libs/intlayer-api/auth.mjs";
|
|
20
|
+
import "../../libs/intlayer-api/dictionary.mjs";
|
|
21
|
+
import "../../libs/intlayer-api/organization.mjs";
|
|
22
|
+
import "../../libs/intlayer-api/project.mjs";
|
|
23
|
+
import "../../libs/intlayer-api/user.mjs";
|
|
24
|
+
import "@intlayer/dictionaries-entry";
|
|
25
|
+
import "deepmerge";
|
|
26
|
+
import "../Form/FormBase.mjs";
|
|
27
|
+
import "../Form/FormField.mjs";
|
|
28
|
+
import "../../Form-DyFBmVya.js";
|
|
29
|
+
import "../Toaster/Toast.mjs";
|
|
30
|
+
import "../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
|
|
31
|
+
import "zod";
|
|
16
32
|
import "../Select/Multiselect.mjs";
|
|
17
33
|
import { Select } from "../Select/Select.mjs";
|
|
18
34
|
import { nodeTypeSelectorContent } from "./nodeTypeSelector.content.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeSelector.mjs","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type DictionaryValue,\n type EnumerationContent,\n type KeyPath,\n NodeType,\n type TranslationContent,\n} from '@intlayer/core';\nimport { type FC, useEffect, useState } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../utils/dictionary';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { Select } from '../Select';\nimport { nodeTypeSelectorContent } from './nodeTypeSelector.content';\n\ntype NodeTypeSelectorProps = {\n keyPath: KeyPath[];\n dictionaryKey: string;\n section: DictionaryValue;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n keyPath,\n dictionaryKey,\n section,\n}) => {\n const {\n multilingualText,\n text,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n } = useDictionary(nodeTypeSelectorContent);\n const nodeType = getSectionType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n const { addEditedContent } = useEditedContentStore((s) => ({\n addEditedContent: s.addEditedContent,\n }));\n const { locales } = getConfiguration().internationalization;\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n\n switch (keyType) {\n case NodeType.Translation:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: '',\n }))\n ),\n } as TranslationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Enumeration:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': '',\n '>1': '',\n },\n } as EnumerationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Object:\n addEditedContent(dictionaryKey, {}, keyPath);\n break;\n case NodeType.Array:\n addEditedContent(dictionaryKey, [''], keyPath);\n break;\n case NodeType.Text:\n addEditedContent(dictionaryKey, '', keyPath);\n break;\n default:\n addEditedContent(dictionaryKey, {}, keyPath);\n }\n };\n\n useEffect(() => {\n setKeyType(nodeType);\n }, [nodeType]);\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger className=\"w-40\">\n <Select.Value placeholder={triggerPlaceHolder.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>\n {multilingualText}\n </Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"names":["keyType","jsxs","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.mjs","sources":["../../../src/components/DictionaryFieldEditor/NodeTypeSelector.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport {\n type DictionaryValue,\n type EnumerationContent,\n type KeyPath,\n NodeType,\n type TranslationContent,\n} from '@intlayer/core';\nimport { type FC, useEffect, useState } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { getSectionType } from '../../utils/dictionary';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { Select } from '../Select';\nimport { nodeTypeSelectorContent } from './nodeTypeSelector.content';\n\ntype NodeTypeSelectorProps = {\n keyPath: KeyPath[];\n dictionaryKey: string;\n section: DictionaryValue;\n};\n\nexport const NodeTypeSelector: FC<NodeTypeSelectorProps> = ({\n keyPath,\n dictionaryKey,\n section,\n}) => {\n const {\n multilingualText,\n text,\n node,\n array,\n enumeration,\n triggerPlaceHolder,\n } = useDictionary(nodeTypeSelectorContent);\n const nodeType = getSectionType(section);\n const [keyType, setKeyType] = useState<NodeType>(nodeType);\n const { addEditedContent } = useEditedContentStore((s) => ({\n addEditedContent: s.addEditedContent,\n }));\n const { locales } = getConfiguration().internationalization;\n\n const onValueChange = (keyType: NodeType) => {\n setKeyType(keyType);\n\n switch (keyType) {\n case NodeType.Translation:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: '',\n }))\n ),\n } as TranslationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Enumeration:\n addEditedContent(\n dictionaryKey,\n {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': '',\n '>1': '',\n },\n } as EnumerationContent<DictionaryValue>,\n keyPath\n );\n break;\n case NodeType.Object:\n addEditedContent(dictionaryKey, {}, keyPath);\n break;\n case NodeType.Array:\n addEditedContent(dictionaryKey, [''], keyPath);\n break;\n case NodeType.Text:\n addEditedContent(dictionaryKey, '', keyPath);\n break;\n default:\n addEditedContent(dictionaryKey, {}, keyPath);\n }\n };\n\n useEffect(() => {\n setKeyType(nodeType);\n }, [nodeType]);\n\n return (\n <Select value={keyType} onValueChange={onValueChange}>\n <Select.Trigger className=\"w-40\">\n <Select.Value placeholder={triggerPlaceHolder.value} />\n </Select.Trigger>\n <Select.Content>\n <Select.Item value={NodeType.Translation}>\n {multilingualText}\n </Select.Item>\n <Select.Item value={NodeType.Text}>{text}</Select.Item>\n <Select.Item value={NodeType.Object}>{node}</Select.Item>\n <Select.Item value={NodeType.Array}>{array}</Select.Item>\n <Select.Item value={NodeType.Enumeration}>{enumeration}</Select.Item>\n </Select.Content>\n </Select>\n );\n};\n"],"names":["keyType","jsxs","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,uBAAuB;AACnC,QAAA,WAAW,eAAe,OAAO;AACvC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAmB,QAAQ;AACzD,QAAM,EAAE,iBAAA,IAAqB,sBAAsB,CAAC,OAAO;AAAA,IACzD,kBAAkB,EAAE;AAAA,EACpB,EAAA;AACF,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AAEjC,QAAA,gBAAgB,CAACA,aAAsB;AAC3C,eAAWA,QAAO;AAElB,YAAQA,UAAS;AAAA,MACf,KAAK,SAAS;AACZ;AAAA,UACE;AAAA,UACA;AAAA,YACE,UAAU,SAAS;AAAA,YACnB,CAAC,SAAS,WAAW,GAAG,OAAO;AAAA,cAC7B,CAAC;AAAA,cACD,GAAG,QAAQ,IAAI,CAAC,YAAY;AAAA,gBAC1B,CAAC,MAAM,GAAG;AAAA,cAAA,EACV;AAAA,YACJ;AAAA,UACF;AAAA,UACA;AAAA,QAAA;AAEF;AAAA,MACF,KAAK,SAAS;AACZ;AAAA,UACE;AAAA,UACA;AAAA,YACE,UAAU,SAAS;AAAA,YACnB,CAAC,SAAS,WAAW,GAAG;AAAA,cACtB,KAAK;AAAA,c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