@intlayer/design-system 5.7.2-canary.3 → 5.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +39 -0
- package/dist/better-auth.8zoxzg-F-BEBqzpjz.cjs +40 -0
- package/dist/better-auth.8zoxzg-F-BEBqzpjz.cjs.map +1 -0
- package/dist/better-auth.8zoxzg-F-D8e0X4ys.js +41 -0
- package/dist/better-auth.8zoxzg-F-D8e0X4ys.js.map +1 -0
- package/dist/components/Breadcrumb/index.cjs +1 -0
- package/dist/components/Breadcrumb/index.cjs.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts +1 -1
- package/dist/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/components/Breadcrumb/index.mjs +1 -0
- package/dist/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +7 -4
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +2 -2
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +7 -4
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -0
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -0
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +2 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +2 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +5 -2
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +5 -2
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +2 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +2 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs +2 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs +2 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/Flags/Flag.cjs +23 -1
- package/dist/components/Flags/Flag.cjs.map +1 -1
- package/dist/components/Flags/Flag.d.ts.map +1 -1
- package/dist/components/Flags/Flag.mjs +23 -1
- package/dist/components/Flags/Flag.mjs.map +1 -1
- package/dist/components/Form/FormBase.cjs.map +1 -1
- package/dist/components/Form/FormBase.mjs.map +1 -1
- package/dist/components/IDE/CodeContext.cjs +2 -1
- package/dist/components/IDE/CodeContext.cjs.map +1 -1
- package/dist/components/IDE/CodeContext.mjs +2 -1
- package/dist/components/IDE/CodeContext.mjs.map +1 -1
- package/dist/components/Link/Link.cjs +2 -2
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.mjs +2 -2
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +2 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +2 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +2 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.mjs +2 -1
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +2 -1
- package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs +2 -1
- package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/components/Navbar/index.cjs +2 -1
- package/dist/components/Navbar/index.cjs.map +1 -1
- package/dist/components/Navbar/index.mjs +2 -1
- package/dist/components/Navbar/index.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs +2 -1
- package/dist/components/SwitchSelector/index.cjs.map +1 -1
- package/dist/components/SwitchSelector/index.mjs +2 -1
- package/dist/components/SwitchSelector/index.mjs.map +1 -1
- package/dist/components/TabSelector/TabSelector.cjs +2 -1
- package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
- package/dist/components/TabSelector/TabSelector.mjs +2 -1
- package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.cjs +5 -4
- package/dist/components/TextArea/AutocompleteTextArea.cjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.mjs +5 -4
- package/dist/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
- package/dist/hooks/auth.cjs +1783 -0
- package/dist/hooks/auth.cjs.map +1 -0
- package/dist/hooks/auth.d.ts +32 -0
- package/dist/hooks/auth.d.ts.map +1 -0
- package/dist/hooks/auth.mjs +1783 -0
- package/dist/hooks/auth.mjs.map +1 -0
- package/dist/hooks/index.cjs +2 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.cjs +58 -61
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +679 -9
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +59 -62
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAuth/useAuth.cjs.map +1 -1
- package/dist/hooks/useAuth/useAuth.d.ts +1 -2
- package/dist/hooks/useAuth/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth/useAuth.mjs.map +1 -1
- package/dist/hooks/useAuth/useOAuth2.cjs +3 -3
- package/dist/hooks/useAuth/useOAuth2.cjs.map +1 -1
- package/dist/hooks/useAuth/useOAuth2.mjs +3 -3
- package/dist/hooks/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/hooks/useAuth/useSession.cjs +5 -5
- package/dist/hooks/useAuth/useSession.cjs.map +1 -1
- package/dist/hooks/useAuth/useSession.d.ts.map +1 -1
- package/dist/hooks/useAuth/useSession.mjs +5 -5
- package/dist/hooks/useAuth/useSession.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.cjs +7 -1
- package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +11 -0
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -0
- package/dist/hooks/useIntlayerAPI.mjs +8 -2
- package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
- package/dist/hooks/useUser/index.cjs +2 -1
- package/dist/hooks/useUser/index.cjs.map +1 -1
- package/dist/hooks/useUser/index.d.ts +2 -2
- package/dist/hooks/useUser/index.mjs +2 -1
- package/dist/hooks/useUser/index.mjs.map +1 -1
- package/package.json +18 -17
- package/dist/tailwind.css +0 -2
package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryDetailsForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '../../../hooks';\nimport { useAuth } from '../../../hooks/useAuth';\nimport { Container } from '../../Container';\nimport { Form, useForm } from '../../Form';\nimport { Loader } from '../../Loader';\nimport { MultiSelect } from '../../Select';\nimport { dictionaryDetailsContent } from './dictionaryDetails.content';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n}) => {\n const { session } = useAuth();\n const { project } = session ?? {};\n const { data: projects, isLoading: isLoadingProjects } = useGetProjects();\n const { data: tags } = useGetTags();\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: dictionary,\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n\n projectInput,\n tagsSelect,\n auditButton,\n } = useDictionary(dictionaryDetailsContent);\n const { auditContentDeclaration, isLoading: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary = editedContent?.[dictionary.key];\n\n useEffect(() => {\n form.reset(dictionary);\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset(dictionary);\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = async () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n await auditContentDeclaration({\n fileContent: JSON.stringify(dictionaryToAudit),\n }).then((response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = JSON.parse(response.data.fileContent) as\n | Partial<Dictionary>\n | undefined;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n });\n };\n\n return (\n <Container\n background=\"none\"\n border\n roundedSize=\"2xl\"\n className=\"w-full px-5 pb-3 pt-5\"\n >\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n onChange={(data) =>\n setEditedDictionary((prev) => ({\n ...prev,\n ...data,\n }))\n }\n >\n <div className=\"flex w-full flex-1 gap-8 max-md:flex-col\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"flex size-full flex-1 gap-8 max-md:flex-col\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description.value}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description.value}\n onValueChange={(value) => {\n form.setValue('tags', [value].flat());\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: [value].flat(),\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {tags?.data?.map((tag) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n >\n {auditButton.text}\n </Form.Button>\n </div>\n </Form>\n </Container>\n );\n};\n"],"names":["project"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,wBAAoD,CAAC;AAAA,EAChE;AACF,MAAM;AACE,QAAA,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,EAAE,YAAY,WAAW,CAAC;AAChC,QAAM,EAAE,MAAM,UAAU,WAAW,kBAAA,IAAsB,eAAe;AACxE,QAAM,EAAE,MAAM,KAAK,IAA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gBACN,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,UAAU,gBAAgB;AAAA,gBAC1B,WAAW;AAAA,gBAEV,UAAY,YAAA;AAAA,cAAA;AAAA,YAAA,EAEjB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DictionaryDetailsForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { WandSparkles } from 'lucide-react';\nimport { type FC, useEffect } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport {\n useAuditContentDeclarationMetadata,\n useGetProjects,\n useGetTags,\n} from '../../../hooks';\nimport { useAuth } from '../../../hooks/useAuth';\nimport { Container } from '../../Container';\nimport { Form, useForm } from '../../Form';\nimport { Loader } from '../../Loader';\nimport { MultiSelect } from '../../Select';\nimport { dictionaryDetailsContent } from './dictionaryDetails.content';\nimport { useDictionaryDetailsSchema } from './useDictionaryDetailsSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n};\n\nexport const DictionaryDetailsForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n}) => {\n const { session } = useAuth();\n const { project } = session ?? {};\n const { data: projects, isLoading: isLoadingProjects } = useGetProjects();\n const { data: tags } = useGetTags();\n\n const DictionaryDetailsSchema = useDictionaryDetailsSchema(\n String(project?.id)\n );\n const { form, isSubmitting } = useForm(DictionaryDetailsSchema, {\n defaultValues: dictionary,\n });\n const { editedContent, setEditedDictionary } = useEditedContent();\n const {\n titleInput,\n keyInput,\n descriptionInput,\n\n projectInput,\n tagsSelect,\n auditButton,\n } = useDictionary(dictionaryDetailsContent);\n const { auditContentDeclaration, isLoading: isAuditing } =\n useAuditContentDeclarationMetadata();\n const updatedDictionary = editedContent?.[dictionary.key];\n\n useEffect(() => {\n form.reset(dictionary);\n }, [dictionary, form?.reset]);\n\n useEffect(() => {\n if (typeof updatedDictionary === 'undefined') {\n form.reset(dictionary);\n }\n }, [updatedDictionary]);\n\n const handleOnAuditFile = async () => {\n const dictionaryToAudit = {\n ...dictionary,\n ...updatedDictionary,\n };\n\n await auditContentDeclaration({\n fileContent: JSON.stringify(dictionaryToAudit),\n }).then((response) => {\n if (!response?.data) return;\n\n try {\n const auditedDictionary = JSON.parse(response.data.fileContent) as\n | Partial<Dictionary>\n | undefined;\n\n setEditedDictionary((prev) => ({\n ...prev,\n ...dictionaryToAudit,\n ...auditedDictionary,\n }));\n form.reset({\n ...dictionaryToAudit,\n ...auditedDictionary,\n });\n } catch (error) {\n console.error(error);\n }\n });\n };\n\n return (\n <Container\n background=\"none\"\n border\n roundedSize=\"2xl\"\n className=\"w-full px-5 pb-3 pt-5\"\n >\n <Form\n className=\"flex w-full flex-col gap-8\"\n {...form}\n schema={DictionaryDetailsSchema}\n onChange={(data) =>\n setEditedDictionary((prev) => ({\n ...prev,\n ...data,\n }))\n }\n >\n <div className=\"flex w-full flex-1 gap-8 max-md:flex-col\">\n <Form.EditableFieldInput\n name=\"key\"\n label={keyInput.label}\n placeholder={keyInput.label.value}\n description={keyInput.description}\n disabled={isSubmitting}\n isRequired\n onSave={(value) => {\n form.setValue('key', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n key: value,\n }));\n }}\n />\n <Form.EditableFieldInput\n name=\"title\"\n label={titleInput.label}\n placeholder={titleInput.placeholder.value}\n description={titleInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('title', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n title: value,\n }));\n }}\n />\n </div>\n <Form.EditableFieldTextArea\n name=\"description\"\n label={descriptionInput.label}\n placeholder={descriptionInput.placeholder.value}\n description={descriptionInput.description}\n disabled={isSubmitting}\n onSave={(value) => {\n form.setValue('description', value);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n description: value,\n }));\n }}\n />\n <div className=\"flex size-full flex-1 gap-8 max-md:flex-col\">\n <Form.MultiSelect\n name=\"projectIds\"\n label={projectInput.label.value}\n description={projectInput.description.value}\n onValueChange={(value) => {\n const valueArray = [value].flat();\n form.setValue('projectIds', valueArray);\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n projectIds: valueArray,\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={projectInput.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {projects?.data?.map((project) => (\n <MultiSelect.Item\n key={String(project.id)}\n value={String(project.id)}\n >\n {project.name}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n\n <Form.MultiSelect\n name=\"tags\"\n label={tagsSelect.label.value}\n description={tagsSelect.description.value}\n onValueChange={(value) => {\n form.setValue('tags', [value].flat());\n setEditedDictionary((prev) => ({\n ...dictionary,\n ...(prev ?? {}),\n tags: [value].flat(),\n }));\n }}\n >\n <MultiSelect.Trigger\n getBadgeValue={(value) =>\n projects?.data?.find((project) => String(project.id) === value)\n ?.name ?? value\n }\n >\n <MultiSelect.Input placeholder={tagsSelect.placeholder.value} />\n </MultiSelect.Trigger>\n <MultiSelect.Content>\n <Loader isLoading={isLoadingProjects}>\n <MultiSelect.List>\n {tags?.data?.map((tag) => (\n <MultiSelect.Item\n key={String(tag.key)}\n value={String(tag.key)}\n >\n {tag.name ?? tag.key}\n </MultiSelect.Item>\n ))}\n </MultiSelect.List>\n </Loader>\n </MultiSelect.Content>\n </Form.MultiSelect>\n </div>\n\n <div className=\"flex flex-wrap items-center justify-end gap-2 max-md:flex-col\">\n <Form.Button\n type=\"button\"\n label={auditButton.label.value}\n Icon={WandSparkles}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={handleOnAuditFile}\n disabled={isSubmitting || isAuditing}\n isLoading={isAuditing}\n >\n {auditButton.text}\n </Form.Button>\n </div>\n </Form>\n </Container>\n );\n};\n"],"names":["project"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,wBAAoD,CAAC;AAAA,EAChE;AACF,MAAM;AACE,QAAA,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,EAAE,YAAY,WAAW,CAAC;AAChC,QAAM,EAAE,MAAM,UAAU,WAAW,kBAAA,IAAsB,eAAe;AACxE,QAAM,EAAE,MAAM,KAAK,IAAI,WAAW;AAElC,QAAM,0BAA0B;AAAA,IAC9B,OAAO,SAAS,EAAE;AAAA,EACpB;AACA,QAAM,EAAE,MAAM,iBAAiB,QAAQ,yBAAyB;AAAA,IAC9D,eAAe;AAAA,EAAA,CAChB;AACD,QAAM,EAAE,eAAe,oBAAoB,IAAI,iBAAiB;AAC1D,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,wBAAwB;AAC1C,QAAM,EAAE,yBAAyB,WAAW,WAAA,IAC1C,mCAAmC;AAC/B,QAAA,oBAAoB,gBAAgB,WAAW,GAAG;AAExD,YAAU,MAAM;AACd,SAAK,MAAM,UAAU;AAAA,EACpB,GAAA,CAAC,YAAY,MAAM,KAAK,CAAC;AAE5B,YAAU,MAAM;AACV,QAAA,OAAO,sBAAsB,aAAa;AAC5C,WAAK,MAAM,UAAU;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,iBAAiB,CAAC;AAEtB,QAAM,oBAAoB,YAAY;AACpC,UAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,UAAM,wBAAwB;AAAA,MAC5B,aAA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AAA,YAAY,MAAZ,EACE,UAAA,MAAM,MAAM,IAAI,CAAC,QAChB;AAAA,sBAAC,YAAY;AAAA,sBAAZ;AAAA,wBAEC,OAAO,OAAO,IAAI,GAAG;AAAA,wBAEpB,UAAA,IAAI,QAAQ,IAAI;AAAA,sBAAA;AAAA,sBAHZ,OAAO,IAAI,GAAG;AAAA,oBAAA,CAKtB,EACH,CAAA,EAAA,CACF,EACF,CAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YACF,GACF;AAAA,YAEA,oBAAC,OAAI,EAAA,WAAU,iEACb,UAAA;AAAA,cAAC,KAAK;AAAA,cAAL;AAAA,gBACC,MAAK;AAAA,gBACL,OAAO,YAAY,MAAM;AAAA,gBACzB,MAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,UAAU,gBAAgB;AAAA,gBAC1B,WAAW;AAAA,gBAEV,UAAY,YAAA;AAAA,cAAA;AAAA,YAAA,EAEjB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;"}
|
|
@@ -10,10 +10,11 @@ const components_Button_Button = require("../Button/Button.cjs");
|
|
|
10
10
|
require("@intlayer/config/client");
|
|
11
11
|
require("@intlayer/core");
|
|
12
12
|
require("fuse.js");
|
|
13
|
+
require("@intlayer/config/built");
|
|
14
|
+
require("../../better-auth.8zoxzg-F-BEBqzpjz.cjs");
|
|
13
15
|
require("../Toaster/Toast.cjs");
|
|
14
16
|
require("../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
15
17
|
require("@intlayer/api");
|
|
16
|
-
require("@intlayer/config/built");
|
|
17
18
|
require("deepmerge");
|
|
18
19
|
require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
19
20
|
require("../Container/index.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-col gap-6 px-2\">\n <Button\n onClick={onClickDictionaryList}\n variant=\"hoverable\"\n className=\"z-10 ml-5 mr-auto\"\n color=\"text\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(\n !mode.includes('remote') &&\n value === EditorViewType.DetailsEditor\n )\n )}\n />\n\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n />\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":["useConfiguration","useState","useDictionary","dictionaryFieldEditorContent","useFocusDictionaryActions","useDictionariesRecordActions","useEffect","jsx","LocaleSwitcherContentProvider","jsxs","Button","ArrowLeft","SwitchSelector","DictionaryDetailsForm","StructureEditor","ContentEditor","JSONEditor","SaveForm"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-col gap-6 px-2\">\n <Button\n onClick={onClickDictionaryList}\n variant=\"hoverable\"\n className=\"z-10 ml-5 mr-auto\"\n color=\"text\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(\n !mode.includes('remote') &&\n value === EditorViewType.DetailsEditor\n )\n )}\n />\n\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n />\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":["useConfiguration","useState","useDictionary","dictionaryFieldEditorContent","useFocusDictionaryActions","useDictionariesRecordActions","useEffect","jsx","LocaleSwitcherContentProvider","jsxs","Button","ArrowLeft","SwitchSelector","DictionaryDetailsForm","StructureEditor","ContentEditor","JSONEditor","SaveForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAASA,YAAAA,iBAAiB;AAC1B,QAAA,CAAC,YAAY,aAAa,IAAIC,aAAA;AAAA,IAClC;AAAA;AAAA,EACF;AACM,QAAA,EAAE,2BAA2BC,cAAA;AAAA,IACjCC,+DAAAA;AA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AK,SAAS,QAAQ,KACvB,UAAU;AAAA,YAAA;AAAA,UAEhB;AAAA,QACF;AAAA,QAEC,eAAe,KACbL,2BAAAA,IAAAM,yEAAAA,uBAAA,EAAsB,WAAwB,CAAA;AAAA,QAEhD,eAAe,KACbN,2BAAAA,IAAAO,iDAAAA,iBAAA,EAAgB,WAAwB,CAAA;AAAA,QAE1C,eAAe,KACbP,2BAAA,IAAAQ,+CAAA,eAAA,EAAc,YAAwB,YAAwB;AAAA,QAEhE,eAAe,KACbR,2BAAA,IAAAS,4CAAA,YAAA,EAAW,YAAwB,YAAwB;AAAA,QAG9DT,2BAAA;AAAA,UAACU,mDAAA;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA,UAAU,MAAM;AACd,gCAAkB,IAAI;AACX,yBAAA;AAAA,YAAA;AAAA,UACb;AAAA,QAAA;AAAA,MACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
|
|
@@ -8,10 +8,11 @@ import { Button } from "../Button/Button.mjs";
|
|
|
8
8
|
import "@intlayer/config/client";
|
|
9
9
|
import "@intlayer/core";
|
|
10
10
|
import "fuse.js";
|
|
11
|
+
import "@intlayer/config/built";
|
|
12
|
+
import "../../better-auth.8zoxzg-F-D8e0X4ys.js";
|
|
11
13
|
import "../Toaster/Toast.mjs";
|
|
12
14
|
import "../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
13
15
|
import "@intlayer/api";
|
|
14
|
-
import "@intlayer/config/built";
|
|
15
16
|
import "deepmerge";
|
|
16
17
|
import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
17
18
|
import "../Container/index.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryFieldEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-col gap-6 px-2\">\n <Button\n onClick={onClickDictionaryList}\n variant=\"hoverable\"\n className=\"z-10 ml-5 mr-auto\"\n color=\"text\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(\n !mode.includes('remote') &&\n value === EditorViewType.DetailsEditor\n )\n )}\n />\n\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n />\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DictionaryFieldEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/DictionaryFieldEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useConfiguration,\n useDictionariesRecordActions,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { ArrowLeft } from 'lucide-react';\nimport { useEffect, useState, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Button } from '../Button';\nimport { LocaleSwitcherContentProvider } from '../LocaleSwitcherContentDropDown';\nimport { SwitchSelector } from '../SwitchSelector';\nimport { ContentEditor } from './ContentEditor';\nimport { DictionaryDetailsForm } from './DictionaryDetails/DictionaryDetailsForm';\nimport { dictionaryFieldEditorContent } from './dictionaryFieldEditor.content';\nimport { JSONEditor } from './JSONEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\nimport { StructureEditor } from './StructureEditor';\n\ntype DictionaryFieldEditorProps = {\n dictionary: Dictionary;\n onClickDictionaryList?: () => void;\n onDelete?: () => void;\n isDarkMode?: boolean;\n mode: ('local' | 'remote')[];\n};\n\nenum EditorViewType {\n DetailsEditor,\n ContentEditor,\n StructureEditor,\n JSONEditor,\n}\n\nexport const DictionaryFieldEditor: FC<DictionaryFieldEditorProps> = ({\n dictionary,\n onClickDictionaryList,\n isDarkMode,\n mode,\n onDelete,\n}) => {\n const config = useConfiguration();\n const [editorView, setEditorView] = useState<EditorViewType>(\n EditorViewType.ContentEditor\n );\n const { returnToDictionaryList } = useDictionary(\n dictionaryFieldEditorContent\n );\n const { setFocusedContent } = useFocusDictionaryActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n // Focus the dictionary if not focused\n setFocusedContent((prev) => ({\n ...(prev ?? {}),\n dictionaryKey: dictionary.key,\n }));\n setLocaleDictionaries((prev) => ({\n ...prev,\n [dictionary.key]: dictionary,\n }));\n }, []);\n\n return (\n <LocaleSwitcherContentProvider\n availableLocales={config?.internationalization.locales ?? []}\n >\n <div className=\"flex size-full flex-col gap-6 px-2\">\n <Button\n onClick={onClickDictionaryList}\n variant=\"hoverable\"\n className=\"z-10 ml-5 mr-auto\"\n color=\"text\"\n Icon={ArrowLeft}\n label={returnToDictionaryList.label.value}\n >\n {returnToDictionaryList.text}\n </Button>\n\n <SwitchSelector\n defaultValue={editorView}\n onChange={(value) => setEditorView(value)}\n color=\"text\"\n size=\"sm\"\n className=\"m-auto w-full max-w-xl\"\n choices={[\n {\n content: 'Details',\n value: EditorViewType.DetailsEditor,\n },\n {\n content: 'Structure',\n value: EditorViewType.StructureEditor,\n },\n {\n content: 'Content',\n value: EditorViewType.ContentEditor,\n },\n {\n content: 'JSON',\n value: EditorViewType.JSONEditor,\n },\n ].filter(\n ({ value }) =>\n !(\n !mode.includes('remote') &&\n value === EditorViewType.DetailsEditor\n )\n )}\n />\n\n {editorView === EditorViewType.DetailsEditor && (\n <DictionaryDetailsForm dictionary={dictionary} />\n )}\n {editorView === EditorViewType.StructureEditor && (\n <StructureEditor dictionary={dictionary} />\n )}\n {editorView === EditorViewType.ContentEditor && (\n <ContentEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n {editorView === EditorViewType.JSONEditor && (\n <JSONEditor dictionary={dictionary} isDarkMode={isDarkMode} />\n )}\n\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n />\n </div>\n </LocaleSwitcherContentProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,SAAS,iBAAiB;AAC1B,QAAA,CAAC,YAAY,aAAa,IAAI;AAAA,IAClC;AAAA;AAAA,EACF;AACM,QAAA,EAAE,2BAA2B;AAAA,IACjC;AAAA,EACF;AACM,QAAA,EAAE,kBAAkB,IAAI,0BAA0B;AAClD,QAAA,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AAEd,sBAAkB,CAAC,UAAU;AAAA,MAC3B,GAAI,QAAQ,CAAC;AAAA,MACb,eAAe,WAAW;AAAA,IAAA,EAC1B;AACF,0BAAsB,CAAC,UAAU;AAAA,MAC/B,GAAG;AAAA,MACH,CAAC,WAAW,GAAG,GAAG;AAAA,IAAA,EAClB;AAAA,EACJ,GAAG,EAAE;AAGH,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,kBAAkB,QAAQ,qBAAqB,WAAW,CAAC;AAAA,MAE3D,UAAA,qBAAC,OAAI,EAAA,WAAU,sCACb,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YAC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"Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const configuration = require("@intlayer/config/built");
|
|
5
5
|
const core = require("@intlayer/core");
|
|
6
6
|
const editorReact = require("@intlayer/editor-react");
|
|
7
7
|
const lucideReact = require("lucide-react");
|
|
@@ -17,7 +17,7 @@ const NavigationViewNode = ({
|
|
|
17
17
|
keyPath,
|
|
18
18
|
dictionaryKey
|
|
19
19
|
}) => {
|
|
20
|
-
const { locales } =
|
|
20
|
+
const { locales } = configuration?.internationalization;
|
|
21
21
|
const section = core.getContentNodeByKeyPath(sectionProp, keyPath);
|
|
22
22
|
const { addEditedContent } = editorReact.useEditedContentActions();
|
|
23
23
|
const { setFocusedContentKeyPath, focusedContent } = editorReact.useFocusDictionary();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","getIsEditableSection","jsx","Fragment","Button","ChevronRight","NodeType","jsxs","sectionArray","getEmptyNode","Plus","isEditableSubSection","Accordion","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAUC,KAAAA,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAIC,+BAAmB;AACxE,QAAM,EAAE,eAAe,cAAcC,cAAAA,cAAcC,2EAAAA,qBAAqB;AAClE,QAAA,WAAWC,iBAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzCC,KAAAA,cAAcD,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAChD,QAAA,uBAAuBE,2EAAqB,OAAO;AAErD,MAAA,CAAC,QAAS,QAASC,+BAAAC,WAAAA,UAAA,CAAA,CAAA;AAEvB,MAAI,sBAAsB;AAEtB,WAAAD,2BAAA;AAAA,MAACE,yBAAA;AAAA,MAAA;AAAA,QACC,OAAO,UAAU,MAAM;AAAA,QACvB,SAAQ;AAAA,QACR,OAAM;AAAA,QACN,WAAU;AAAA,Q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igationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","getIsEditableSection","jsx","Fragment","Button","ChevronRight","NodeType","jsxs","sectionArray","getEmptyNode","Plus","isEditableSubSection","Accordion","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,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,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQC,oCAAoB,GAAG;AAAA,UAE/B,yCAAC,OAAI,EAAA,WAAU,+BACb,UAACX,2BAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACIK,2BAAA,KAAAJ,qBAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import configuration from "@intlayer/config/built";
|
|
3
3
|
import { getContentNodeByKeyPath, getNodeType, NodeType, getEmptyNode, isSameKeyPath } from "@intlayer/core";
|
|
4
4
|
import { useEditedContentActions, useFocusDictionary } from "@intlayer/editor-react";
|
|
5
5
|
import { ChevronRight, Plus } from "lucide-react";
|
|
@@ -15,7 +15,7 @@ const NavigationViewNode = ({
|
|
|
15
15
|
keyPath,
|
|
16
16
|
dictionaryKey
|
|
17
17
|
}) => {
|
|
18
|
-
const { locales } =
|
|
18
|
+
const { locales } = configuration?.internationalization;
|
|
19
19
|
const section = getContentNodeByKeyPath(sectionProp, keyPath);
|
|
20
20
|
const { addEditedContent } = useEditedContentActions();
|
|
21
21
|
const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["configuration","keyPath","sectionArray","isEditableSubSection"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBA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;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n\n return (\n <NavigationViewNode\n key={translationKey}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n key={key}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n key={JSON.stringify(childKeyPath)}\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label.value} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","sectionArray","isEditableSubSection"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C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AA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
@@ -7,11 +7,12 @@ const lucideReact = require("lucide-react");
|
|
|
7
7
|
const ReactExports = require("react");
|
|
8
8
|
const reactIntlayer = require("react-intlayer");
|
|
9
9
|
const components_Modal_Modal = require("../../Modal/Modal.cjs");
|
|
10
|
+
require("@intlayer/config/built");
|
|
11
|
+
require("../../../better-auth.8zoxzg-F-BEBqzpjz.cjs");
|
|
10
12
|
const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
|
|
11
13
|
require("../../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
12
14
|
const hooks_useAuth_useAuth = require("../../../hooks/useAuth/useAuth.cjs");
|
|
13
15
|
require("@intlayer/api");
|
|
14
|
-
require("@intlayer/config/built");
|
|
15
16
|
require("deepmerge");
|
|
16
17
|
require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
17
18
|
const utils_cn = require("../../../utils/cn.cjs");
|
|
@@ -53,7 +54,9 @@ const SaveForm = ({
|
|
|
53
54
|
...dictionary,
|
|
54
55
|
...editedContent?.[dictionary.key]
|
|
55
56
|
};
|
|
56
|
-
await writeDictionary(
|
|
57
|
+
await writeDictionary({
|
|
58
|
+
dictionary: updatedDictionary
|
|
59
|
+
}).then(() => {
|
|
57
60
|
setLocaleDictionary(editedContent?.[dictionary.key]);
|
|
58
61
|
restoreEditedContent(dictionary.key);
|
|
59
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Modal } from '../../../components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { deleteDictionary, isLoading: isDeleting } = useDeleteDictionary();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n const handleDeleteDictionary = async () => {\n if (!(dictionary as DistantDictionary).id) return;\n\n await deleteDictionary(\n (dictionary as DistantDictionary).id.toString()\n ).then((res) => {\n if (res) {\n onDelete?.();\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color=\"error\"\n variant=\"outline\"\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":["useState","useDictionariesRecordActions","useDeleteDictionary","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","jsxs","Fragment","jsx","Modal","Form","Save","cn","Trash","RotateCcw","Download","ArrowUpFromLine"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCO,MAAM,WAAuC,CA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cACX,SAAS,MAAM,0BAA0B,IAAI;AAAA,cAE5C,UAAe,eAAA;AAAA,YAAA;AAAA,UAClB;AAAA,UAED,KAAK,SAAS,QAAQ,KAAK,mBAAmB,CAAC,uBAC9CP,2BAAA;AAAA,YAACE,sCAAAA,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,cAAc,MAAM;AAAA,cAC3B,UAAU;AAAA,cACV,MAAMM,YAAA;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAc,cAAA;AAAA,YAAA;AAAA,UACjB;AAAA,UAED,KAAK,SAAS,QAAQ,KACrB,mBACA,uBACA,YACER,2BAAA;AAAA,YAACE,sCAAAA,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,WAAW,MAAM;AAAA,cACxB,UAAU,CAAC,YAAY;AAAA,cACvB,MAAMC,YAAA;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAW,WAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Modal } from '../../../components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { deleteDictionary, isLoading: isDeleting } = useDeleteDictionary();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary({\n dictionary: updatedDictionary,\n }).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n const handleDeleteDictionary = async () => {\n if (!(dictionary as DistantDictionary).id) return;\n\n await deleteDictionary(\n (dictionary as DistantDictionary).id.toString()\n ).then((res) => {\n if (res) {\n onDelete?.();\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color=\"error\"\n variant=\"outline\"\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":["useState","useDictionariesRecordActions","useDeleteDictionary","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","jsxs","Fragment","jsx","Modal","Form","Save","cn","Trash","RotateCcw","Download","ArrowUpFromLine"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,CAAC,wBAAwB,yBAAyB,IAAIA,aAAAA,SAAS,KAAK;AACpE,QAAA,EAAE,oBAAoB,IAAIC,yCAA6B;AAC7D,QAAM,EAAE,kBAAkB,WAAW,WAAA,IAAeC,uBAAAA,oBAAoB;AACxE,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAcC,uBAAAA,oBAAoB;AACvE,QAAM,YAAY,aAAa;AACzB,QAAA,eACJ,KAAK,SAAS,OAAO,KAAK,WAAW,UAAU,SAAS,OAAO;AAEjE,QAAM,EAAE,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,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,WAAW,MAAM;AAAA,cACxB,UAAU,CAAC,YAAY;AAAA,cACvB,MAAMC,YAAA;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAW,WAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAYjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,EAAE,EACP,KAAK,kBAAkB,EAExB,MAAM,OAAO,CAAC;AAaf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAYjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,EAAE,EACP,KAAK,kBAAkB,EAExB,MAAM,OAAO,CAAC;AAaf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CAuM/C,CAAC"}
|
|
@@ -5,11 +5,12 @@ import { Save, Trash, RotateCcw, Download, ArrowUpFromLine } from "lucide-react"
|
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { useDictionary } from "react-intlayer";
|
|
7
7
|
import { Modal } from "../../Modal/Modal.mjs";
|
|
8
|
+
import "@intlayer/config/built";
|
|
9
|
+
import "../../../better-auth.8zoxzg-F-D8e0X4ys.js";
|
|
8
10
|
import { useDeleteDictionary, useWriteDictionary, usePushDictionaries } from "../../../hooks/intlayerAPIHooks.mjs";
|
|
9
11
|
import "../../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
10
12
|
import { useAuth } from "../../../hooks/useAuth/useAuth.mjs";
|
|
11
13
|
import "@intlayer/api";
|
|
12
|
-
import "@intlayer/config/built";
|
|
13
14
|
import "deepmerge";
|
|
14
15
|
import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
15
16
|
import { cn } from "../../../utils/cn.mjs";
|
|
@@ -51,7 +52,9 @@ const SaveForm = ({
|
|
|
51
52
|
...dictionary,
|
|
52
53
|
...editedContent?.[dictionary.key]
|
|
53
54
|
};
|
|
54
|
-
await writeDictionary(
|
|
55
|
+
await writeDictionary({
|
|
56
|
+
dictionary: updatedDictionary
|
|
57
|
+
}).then(() => {
|
|
55
58
|
setLocaleDictionary(editedContent?.[dictionary.key]);
|
|
56
59
|
restoreEditedContent(dictionary.key);
|
|
57
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Modal } from '../../../components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { deleteDictionary, isLoading: isDeleting } = useDeleteDictionary();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n const handleDeleteDictionary = async () => {\n if (!(dictionary as DistantDictionary).id) return;\n\n await deleteDictionary(\n (dictionary as DistantDictionary).id.toString()\n ).then((res) => {\n if (res) {\n onDelete?.();\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color=\"error\"\n variant=\"outline\"\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,SAAS,KAAK;AACpE,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AAC7D,QAAM,EAAE,kBAAkB,WAAW,WAAA,IAAe,oBAAoB;AACxE,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAc,mBAAmB;A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;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAW,WAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n Trash,\n} from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FC,\n type FormHTMLAttributes,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { Modal } from '../../../components/Modal';\nimport {\n useAuth,\n useDeleteDictionary,\n usePushDictionaries,\n useWriteDictionary,\n} from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n onDelete,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { deleteDictionary, isLoading: isDeleting } = useDeleteDictionary();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n deleteButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isDistantDictionary =\n typeof (dictionary as DistantDictionary)?.id !== 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary({\n dictionary: updatedDictionary,\n }).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n const handleDeleteDictionary = async () => {\n if (!(dictionary as DistantDictionary).id) return;\n\n await deleteDictionary(\n (dictionary as DistantDictionary).id.toString()\n ).then((res) => {\n if (res) {\n onDelete?.();\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {mode.includes('remote') &&\n isDistantDictionary &&\n onDelete &&\n isAuthenticated && (\n <Form.Button\n label={deleteButton.label.value}\n Icon={Trash}\n color=\"error\"\n variant=\"outline\"\n className=\"max-md:w-full\"\n isLoading={isDeleting}\n onClick={handleDeleteDictionary}\n >\n {deleteButton.text}\n </Form.Button>\n )}\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && !isDistantDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n isDistantDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;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c,MAAM;AAAA,cAC3B,UAAU;AAAA,cACV,MAAM;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAc,cAAA;AAAA,YAAA;AAAA,UACjB;AAAA,UAED,KAAK,SAAS,QAAQ,KACrB,mBACA,uBACA,YACE;AAAA,YAAC,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,WAAW,MAAM;AAAA,cACxB,UAAU,CAAC,YAAY;AAAA,cACvB,MAAM;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAW,WAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;"}
|
|
@@ -15,10 +15,11 @@ require("clsx");
|
|
|
15
15
|
require("tailwind-merge");
|
|
16
16
|
require("../../Input/Input.cjs");
|
|
17
17
|
require("../../Input/Checkbox.cjs");
|
|
18
|
+
require("@intlayer/config/built");
|
|
19
|
+
require("../../../better-auth.8zoxzg-F-BEBqzpjz.cjs");
|
|
18
20
|
require("../../Toaster/Toast.cjs");
|
|
19
21
|
require("../../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
20
22
|
require("@intlayer/api");
|
|
21
|
-
require("@intlayer/config/built");
|
|
22
23
|
require("deepmerge");
|
|
23
24
|
require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
24
25
|
const components_DictionaryFieldEditor_NodeTypeSelector = require("../NodeTypeSelector.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructureView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ContentNode,\n getDefaultNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n type KeyPath,\n NodeType,\n type TypedNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration()?.internationalization.locales ?? [];\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey?: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useDictionary(structureViewContent);\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryKey, keyName, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: keyName } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <Container\n transparency=\"xl\"\n roundedSize=\"xl\"\n className=\"w-full min-w-80 gap-2 overflow-auto px-5 py-2\"\n border\n borderColor=\"text\"\n background=\"none\"\n aria-selected={isSameKeyPath(keyPath, focusedContent?.keyPath ?? [])}\n onClick={() => setFocusedContentKeyPath(keyPath)}\n >\n <div className=\"flex w-full flex-col items-start justify-between gap-3\">\n {typeof sectionKey === 'string' && (\n <div className=\"w-full\">\n <div className=\"flex w-full items-center justify-between gap-10\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n placeholder={titleInput.placeholder.value}\n defaultValue={sectionKey}\n onSave={(value) => handleRenameNodeKey(value)}\n variant=\"invisible\"\n />\n <Button\n label={deleteButton.label.value}\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"text-neutral ml-3 text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n )}\n <NodeTypeView\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryKey, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { addNodeButton } = useDictionary(structureViewContent);\n const { setFocusedContentKeyPath } = useFocusDictionaryActions();\n const { addEditedContent } = useEditedContentActions();\n\n if (!section || typeof section !== 'object') {\n return <div>Not an object</div>;\n }\n\n return (\n <div className=\"flex flex-col gap-2 overflow-y-auto\">\n <ul className=\"mr-auto flex flex-col gap-4\">\n {Object.keys(section).map((key) => (\n <li key={key} className=\"flex w-full\">\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeType.Object, key }]}\n dictionaryKey={dictionaryKey}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant=\"hoverable\"\n size=\"md\"\n color=\"text\"\n Icon={Plus}\n className=\"flex-1\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeType.Object, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryKey, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n if (\n !section ||\n typeof section !== 'object' ||\n typeof section.nodeType === 'string'\n ) {\n return (\n <NodeView\n sectionKey={'content'}\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n};\n"],"names":["useConfiguration","getNodeType","getNodeChildren","getDefaultNode","NodeType","jsxs","jsx","NodeTypeSelector","nodeType","Fragment","useFocusDictionary","useEditedContentActions","useDictionary","structureViewContent","Container","isSameKeyPath","EditableFieldInput","Button","Trash","camelCaseToSentence","useFocusDictionaryActions","Plus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,MAAM;AACJ,QAAM,UAAUA,YAAA,iBAAA,GAAoB,qBAAqB,WAAW,CAAC;AAC/D,QAAA,WAAWC,iBAAY,OAAO;AAC9B,QAAA,WAAWC,qBAAgB,OAAO;AAElC,QAAA,mBAAmB,CAAC,YAA0B;AAClD,UAAM,qBAAqBC,KAAA;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,yBAAqB,kBAAkB;AAAA,EACzC;AAGE,MAAA,aAAaC,cAAS,eACtB,aAAaA,cAAS,aACtB,aAAaA,cAAS,aACtB;AACA,UAAM,WAAW,OAAO;AAAA,MACrB,QAAiC,Q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MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"StructureView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ContentNode,\n getDefaultNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n type KeyPath,\n NodeType,\n type TypedNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration()?.internationalization.locales ?? [];\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey?: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useDictionary(structureViewContent);\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryKey, keyName, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: keyName } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <Container\n transparency=\"xl\"\n roundedSize=\"xl\"\n className=\"w-full min-w-80 gap-2 overflow-auto px-5 py-2\"\n border\n borderColor=\"text\"\n background=\"none\"\n aria-selected={isSameKeyPath(keyPath, focusedContent?.keyPath ?? [])}\n onClick={() => setFocusedContentKeyPath(keyPath)}\n >\n <div className=\"flex w-full flex-col items-start justify-between gap-3\">\n {typeof sectionKey === 'string' && (\n <div className=\"w-full\">\n <div className=\"flex w-full items-center justify-between gap-10\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n placeholder={titleInput.placeholder.value}\n defaultValue={sectionKey}\n onSave={(value) => handleRenameNodeKey(value)}\n variant=\"invisible\"\n />\n <Button\n label={deleteButton.label.value}\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"translate-x-2\"\n Icon={Trash}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n />\n </div>\n\n <span className=\"text-neutral ml-3 text-sm\">\n ( {camelCaseToSentence(sectionKey)} )\n </span>\n </div>\n )}\n <NodeTypeView\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n onNodeTypeChange={(content) => {\n addEditedContent(dictionaryKey, content, keyPath);\n }}\n />\n </div>\n </Container>\n );\n};\n\ntype ObjectViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const ObjectView: FC<ObjectViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { addNodeButton } = useDictionary(structureViewContent);\n const { setFocusedContentKeyPath } = useFocusDictionaryActions();\n const { addEditedContent } = useEditedContentActions();\n\n if (!section || typeof section !== 'object') {\n return <div>Not an object</div>;\n }\n\n return (\n <div className=\"flex flex-col gap-2 overflow-y-auto\">\n <ul className=\"mr-auto flex flex-col gap-4\">\n {Object.keys(section).map((key) => (\n <li key={key} className=\"flex w-full\">\n <NodeView\n sectionKey={key}\n section={section?.[key as keyof typeof section]}\n keyPath={[...keyPath, { type: NodeType.Object, key }]}\n dictionaryKey={dictionaryKey}\n />\n </li>\n ))}\n </ul>\n <Button\n label={addNodeButton.label.value}\n variant=\"hoverable\"\n size=\"md\"\n color=\"text\"\n Icon={Plus}\n className=\"flex-1\"\n onClick={() => {\n const newKey = 'newKey';\n const newKeyPath = [\n ...keyPath,\n { type: NodeType.Object, key: newKey },\n ] as KeyPath[];\n addEditedContent(dictionaryKey, '', newKeyPath);\n setFocusedContentKeyPath(newKeyPath);\n }}\n >\n {addNodeButton.text}\n </Button>\n </div>\n );\n};\n\ntype StructureViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const StructureView: FC<StructureViewProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}) => {\n if (\n !section ||\n typeof section !== 'object' ||\n typeof section.nodeType === 'string'\n ) {\n return (\n <NodeView\n sectionKey={'content'}\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n }\n\n return (\n <ObjectView\n section={section}\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n />\n );\n};\n"],"names":["useConfiguration","getNodeType","getNodeChildren","getDefaultNode","NodeType","jsxs","jsx","NodeTypeSelector","nodeType","Fragment","useFocusDictionary","useEditedContentActions","useDictionary","structureViewContent","Container","isSameKeyPath","EditableFieldInput","Button","Trash","camelCaseToSentence","useFocusDictionaryActions","Plus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,MAAM;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