@intlayer/design-system 5.5.9 → 5.5.11

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.
Files changed (140) hide show
  1. package/README.md +42 -9
  2. package/dist/.vite/manifest.json +91 -68
  3. package/dist/components/Auth/AuthModal/index.cjs +2 -2
  4. package/dist/components/Auth/AuthModal/index.mjs +2 -2
  5. package/dist/components/Auth/ChangePasswordForm/useChangePasswordSchema.cjs +1 -1
  6. package/dist/components/Auth/ChangePasswordForm/useChangePasswordSchema.mjs +1 -1
  7. package/dist/components/Auth/DefineNewPasswordForm/useDefineNewPasswordSchema.cjs +1 -1
  8. package/dist/components/Auth/DefineNewPasswordForm/useDefineNewPasswordSchema.mjs +1 -1
  9. package/dist/components/Auth/ResetPasswordForm/useResetPasswordSchema.cjs +1 -1
  10. package/dist/components/Auth/ResetPasswordForm/useResetPasswordSchema.mjs +1 -1
  11. package/dist/components/Auth/SignInForm/useSignInSchema.cjs +1 -1
  12. package/dist/components/Auth/SignInForm/useSignInSchema.mjs +1 -1
  13. package/dist/components/Auth/SignUpForm/useSignUpSchema.cjs +1 -1
  14. package/dist/components/Auth/SignUpForm/useSignUpSchema.mjs +1 -1
  15. package/dist/components/Auth/VerifyEmailForm/VerifyEmailSchema.cjs +1 -1
  16. package/dist/components/Auth/VerifyEmailForm/VerifyEmailSchema.mjs +1 -1
  17. package/dist/components/Auth/useUser/index.cjs +2 -2
  18. package/dist/components/Auth/useUser/index.mjs +2 -2
  19. package/dist/components/Command/index.d.ts +83 -0
  20. package/dist/components/Command/index.d.ts.map +1 -0
  21. package/dist/components/ContentEditor/ContentEditorTextArea.cjs +2 -2
  22. package/dist/components/ContentEditor/ContentEditorTextArea.mjs +2 -2
  23. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +2 -2
  24. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +2 -2
  25. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
  26. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
  27. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.cjs +1 -1
  28. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs +1 -1
  29. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +2 -2
  30. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +2 -2
  31. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +1 -1
  32. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +1 -1
  33. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +2 -2
  34. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +2 -2
  35. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +2 -2
  36. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +2 -2
  37. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +3 -3
  38. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  39. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +1 -1
  40. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  41. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +3 -3
  42. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  43. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +2 -2
  44. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +2 -2
  45. package/dist/components/DropDown/index.cjs +1 -13
  46. package/dist/components/DropDown/index.cjs.map +1 -1
  47. package/dist/components/DropDown/index.d.ts.map +1 -1
  48. package/dist/components/DropDown/index.mjs +1 -13
  49. package/dist/components/DropDown/index.mjs.map +1 -1
  50. package/dist/components/EditableField/EditableFieldTextArea.cjs +2 -2
  51. package/dist/components/EditableField/EditableFieldTextArea.mjs +2 -2
  52. package/dist/components/Form/FormBase.cjs +2 -2
  53. package/dist/components/Form/FormBase.mjs +2 -2
  54. package/dist/components/Form/elements/FormElementWrapper.cjs +3 -3
  55. package/dist/components/Form/elements/FormElementWrapper.mjs +3 -3
  56. package/dist/components/IDE/CodeContext.cjs +2 -2
  57. package/dist/components/IDE/CodeContext.mjs +2 -2
  58. package/dist/components/IDE/FileList.cjs +1 -1
  59. package/dist/components/IDE/FileList.cjs.map +1 -1
  60. package/dist/components/IDE/FileList.d.ts +1 -1
  61. package/dist/components/IDE/FileList.d.ts.map +1 -1
  62. package/dist/components/IDE/FileList.mjs +1 -1
  63. package/dist/components/IDE/FileList.mjs.map +1 -1
  64. package/dist/components/KeyboardScreenAdapter/index.cjs +1 -1
  65. package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -1
  66. package/dist/components/KeyboardScreenAdapter/index.mjs +1 -1
  67. package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -1
  68. package/dist/components/Link/Link.cjs.map +1 -1
  69. package/dist/components/Link/Link.d.ts.map +1 -1
  70. package/dist/components/Link/Link.mjs.map +1 -1
  71. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -2
  72. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -2
  73. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +2 -2
  74. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +2 -2
  75. package/dist/components/MarkDownRender/index.cjs +28 -2
  76. package/dist/components/MarkDownRender/index.cjs.map +1 -1
  77. package/dist/components/MarkDownRender/index.d.ts +2 -2
  78. package/dist/components/MarkDownRender/index.d.ts.map +1 -1
  79. package/dist/components/MarkDownRender/index.mjs +28 -2
  80. package/dist/components/MarkDownRender/index.mjs.map +1 -1
  81. package/dist/components/Modal/Modal.cjs +4 -4
  82. package/dist/components/Modal/Modal.mjs +4 -4
  83. package/dist/components/Navbar/MobileNavbar.cjs +3 -3
  84. package/dist/components/Navbar/MobileNavbar.mjs +3 -3
  85. package/dist/components/Navbar/index.cjs +5 -5
  86. package/dist/components/Navbar/index.mjs +5 -5
  87. package/dist/components/SwitchSelector/index.cjs +3 -3
  88. package/dist/components/SwitchSelector/index.mjs +3 -3
  89. package/dist/components/TabSelector/TabSelector.cjs +3 -3
  90. package/dist/components/TabSelector/TabSelector.mjs +3 -3
  91. package/dist/components/TextArea/AutoSizeTextArea.cjs +1 -1
  92. package/dist/components/TextArea/AutoSizeTextArea.cjs.map +1 -1
  93. package/dist/components/TextArea/AutoSizeTextArea.mjs +1 -1
  94. package/dist/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
  95. package/dist/components/TextArea/AutocompleteTextArea.cjs +2 -2
  96. package/dist/components/TextArea/AutocompleteTextArea.mjs +2 -2
  97. package/dist/hooks/index.cjs +25 -23
  98. package/dist/hooks/index.cjs.map +1 -1
  99. package/dist/hooks/index.d.ts +8 -7
  100. package/dist/hooks/index.d.ts.map +1 -1
  101. package/dist/hooks/index.mjs +10 -8
  102. package/dist/hooks/index.mjs.map +1 -1
  103. package/dist/hooks/useAsync/useAsync.cjs +10 -11
  104. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  105. package/dist/hooks/useAsync/useAsync.mjs +10 -11
  106. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  107. package/dist/hooks/useIntlayerAPI.cjs +5 -4
  108. package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
  109. package/dist/hooks/useIntlayerAPI.d.ts +1 -0
  110. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  111. package/dist/hooks/useIntlayerAPI.mjs +5 -4
  112. package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
  113. package/dist/hooks/useScreenWidth.cjs +18 -0
  114. package/dist/hooks/useScreenWidth.cjs.map +1 -0
  115. package/dist/hooks/useScreenWidth.d.ts +4 -0
  116. package/dist/hooks/useScreenWidth.d.ts.map +1 -0
  117. package/dist/hooks/useScreenWidth.mjs +18 -0
  118. package/dist/hooks/useScreenWidth.mjs.map +1 -0
  119. package/dist/index-BCuMWKyy.js.map +1 -1
  120. package/dist/index-BYzBot7l.cjs.map +1 -1
  121. package/dist/parse-BJVwmz92.cjs +511 -0
  122. package/dist/parse-BJVwmz92.cjs.map +1 -0
  123. package/dist/parse-pnJgclyf.js +512 -0
  124. package/dist/parse-pnJgclyf.js.map +1 -0
  125. package/dist/{schemas-DJhUvjsx.cjs → schemas-DlCjM5d_.cjs} +260 -726
  126. package/dist/schemas-DlCjM5d_.cjs.map +1 -0
  127. package/dist/{schemas-7jC6hy_u.js → schemas-itjzX6bG.js} +21 -487
  128. package/dist/schemas-itjzX6bG.js.map +1 -0
  129. package/dist/tailwind.css +2 -2
  130. package/dist/zod-D4WapgbL.js +92 -0
  131. package/dist/zod-D4WapgbL.js.map +1 -0
  132. package/dist/zod-K7y5gPX4.cjs +91 -0
  133. package/dist/zod-K7y5gPX4.cjs.map +1 -0
  134. package/package.json +16 -16
  135. package/dist/schemas-7jC6hy_u.js.map +0 -1
  136. package/dist/schemas-DJhUvjsx.cjs.map +0 -1
  137. package/dist/zod-DIGMabE8.js +0 -48
  138. package/dist/zod-DIGMabE8.js.map +0 -1
  139. package/dist/zod-DpajDxlG.cjs +0 -47
  140. package/dist/zod-DpajDxlG.cjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  "use client";
2
+ import { useLogout } from "../../../hooks/intlayerAPIHooks.mjs";
2
3
  import "react";
3
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
4
4
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
5
- import { useLogout } from "../../../hooks/intlayerAPIHooks.mjs";
6
5
  import "@intlayer/editor-react";
7
6
  import "deepmerge";
7
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
8
8
  import { useAuth } from "../useAuth/index.mjs";
9
9
  const useUser = () => {
10
10
  const { session, revalidateSession, setSession } = useAuth();
@@ -0,0 +1,83 @@
1
+ import { DialogProps } from '@radix-ui/react-dialog';
2
+ import { Command as CommandPrimitive } from 'cmdk';
3
+ import { ComponentProps, FC, HTMLAttributes } from 'react';
4
+ export declare const CommandRoot: FC<ComponentProps<typeof CommandPrimitive>>;
5
+ /**
6
+ * Usage example:
7
+ * ```jsx
8
+ * <Command>
9
+ * <Command.Trigger>
10
+ * <Command.Input placeholder="Search..." />
11
+ * </Command.Trigger>
12
+ * <Command.Dialog>
13
+ * <Command.List>
14
+ * <Command.Item>Item 1</Command.Item>
15
+ * <Command.Item>Item 2</Command.Item>
16
+ * <Command.Item>Item 3</Command.Item>
17
+ * </Command.List>
18
+ * </Command.Dialog>
19
+ * </Command>
20
+ * ```
21
+ */
22
+ export declare const Command: {
23
+ Dialog: FC<DialogProps>;
24
+ Input: FC<Omit<Pick<Pick<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof import('react').InputHTMLAttributes<HTMLInputElement>> & {
25
+ ref?: React.Ref<HTMLInputElement>;
26
+ } & {
27
+ asChild?: boolean;
28
+ }, "key" | "asChild" | keyof import('react').InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
29
+ value?: string;
30
+ onValueChange?: (search: string) => void;
31
+ } & import('react').RefAttributes<HTMLInputElement>>;
32
+ List: FC<{
33
+ children?: React.ReactNode;
34
+ } & Pick<Pick<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & {
35
+ ref?: React.Ref<HTMLDivElement>;
36
+ } & {
37
+ asChild?: boolean;
38
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>> & {
39
+ label?: string;
40
+ } & import('react').RefAttributes<HTMLDivElement>>;
41
+ Empty: FC<{
42
+ children?: React.ReactNode;
43
+ } & Pick<Pick<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & {
44
+ ref?: React.Ref<HTMLDivElement>;
45
+ } & {
46
+ asChild?: boolean;
47
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>> & import('react').RefAttributes<HTMLDivElement>>;
48
+ Group: FC<{
49
+ children?: React.ReactNode;
50
+ } & Omit<Pick<Pick<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & {
51
+ ref?: React.Ref<HTMLDivElement>;
52
+ } & {
53
+ asChild?: boolean;
54
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
55
+ heading?: React.ReactNode;
56
+ value?: string;
57
+ forceMount?: boolean;
58
+ } & import('react').RefAttributes<HTMLDivElement>>;
59
+ Separator: FC<Pick<Pick<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & {
60
+ ref?: React.Ref<HTMLDivElement>;
61
+ } & {
62
+ asChild?: boolean;
63
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>> & {
64
+ alwaysRender?: boolean;
65
+ } & import('react').RefAttributes<HTMLDivElement>>;
66
+ Item: FC<{
67
+ children?: React.ReactNode;
68
+ } & Omit<Pick<Pick<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & {
69
+ ref?: React.Ref<HTMLDivElement>;
70
+ } & {
71
+ asChild?: boolean;
72
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>>, "onSelect" | "disabled" | "value"> & {
73
+ disabled?: boolean;
74
+ onSelect?: (value: string) => void;
75
+ value?: string;
76
+ keywords?: string[];
77
+ forceMount?: boolean;
78
+ } & import('react').RefAttributes<HTMLDivElement>>;
79
+ Shortcut: ({ className, ...props }: HTMLAttributes<HTMLSpanElement>) => import("react/jsx-runtime").JSX.Element;
80
+ propTypes?: any;
81
+ displayName?: string | undefined;
82
+ };
83
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Command/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAG1E,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAWnE,CAAC;AA8FF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA7BjB,cAAc,CAAC,eAAe,CAAC;;;CAuCjC,CAAC"}
@@ -26,12 +26,12 @@ require("../Auth/ChangePasswordForm/changePasswordForm.content.cjs");
26
26
  require("../Auth/ChangePasswordForm/useChangePasswordSchema.content.cjs");
27
27
  require("../Auth/ResetPasswordForm/resetPasswordContent.content.cjs");
28
28
  require("../Auth/ResetPasswordForm/useResetPasswordSchema.content.cjs");
29
- require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
30
- require("../../hooks/useAsync/useAsyncStateStore.cjs");
31
29
  require("@intlayer/editor-react");
32
30
  require("@intlayer/config/built");
31
+ require("../../hooks/useAsync/useAsyncStateStore.cjs");
33
32
  require("../Toaster/Toast.cjs");
34
33
  require("deepmerge");
34
+ require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
35
35
  require("../Modal/Modal.cjs");
36
36
  require("../Auth/VerifyEmailForm/index.content.cjs");
37
37
  require("../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.cjs");
@@ -24,12 +24,12 @@ import "../Auth/ChangePasswordForm/changePasswordForm.content.mjs";
24
24
  import "../Auth/ChangePasswordForm/useChangePasswordSchema.content.mjs";
25
25
  import "../Auth/ResetPasswordForm/resetPasswordContent.content.mjs";
26
26
  import "../Auth/ResetPasswordForm/useResetPasswordSchema.content.mjs";
27
- import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
28
- import "../../hooks/useAsync/useAsyncStateStore.mjs";
29
27
  import "@intlayer/editor-react";
30
28
  import "@intlayer/config/built";
29
+ import "../../hooks/useAsync/useAsyncStateStore.mjs";
31
30
  import "../Toaster/Toast.mjs";
32
31
  import "deepmerge";
32
+ import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
33
33
  import "../Modal/Modal.mjs";
34
34
  import "../Auth/VerifyEmailForm/index.content.mjs";
35
35
  import "../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.mjs";
@@ -7,10 +7,10 @@ const editorReact = require("@intlayer/editor-react");
7
7
  const lucideReact = require("lucide-react");
8
8
  const ReactExports = require("react");
9
9
  const reactIntlayer = require("react-intlayer");
10
- require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
11
- require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
10
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
11
+ require("../../../hooks/useAsync/useAsyncStateStore.cjs");
13
12
  require("deepmerge");
13
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
14
14
  const utils_object = require("../../../utils/object.cjs");
15
15
  const components_Button_Button = require("../../Button/Button.cjs");
16
16
  const components_Container_index = require("../../Container/index.cjs");
@@ -5,10 +5,10 @@ import { useEditedContent, useConfiguration } from "@intlayer/editor-react";
5
5
  import { Trash, Plus, WandSparkles } from "lucide-react";
6
6
  import { Fragment as Fragment$1, useState } from "react";
7
7
  import { useDictionary, useLocale } from "react-intlayer";
8
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
8
  import { useAuditContentDeclarationField } from "../../../hooks/intlayerAPIHooks.mjs";
9
+ import "../../../hooks/useAsync/useAsyncStateStore.mjs";
11
10
  import "deepmerge";
11
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
12
12
  import { renameKey } from "../../../utils/object.mjs";
13
13
  import { Button } from "../../Button/Button.mjs";
14
14
  import { Container } from "../../Container/index.mjs";
@@ -6,10 +6,10 @@ const reactIntlayer = require("react-intlayer");
6
6
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
7
7
  require("react");
8
8
  require("../../Button/Button.cjs");
9
- require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
10
9
  require("../../../hooks/useAsync/useAsyncStateStore.cjs");
11
10
  require("@intlayer/editor-react");
12
11
  require("deepmerge");
12
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
13
13
  const components_Auth_useAuth_index = require("../../Auth/useAuth/index.cjs");
14
14
  require("../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs");
15
15
  require("@intlayer/api");
@@ -4,10 +4,10 @@ import { useDictionary } from "react-intlayer";
4
4
  import { useAddDictionary, useGetProjects } from "../../../hooks/intlayerAPIHooks.mjs";
5
5
  import "react";
6
6
  import "../../Button/Button.mjs";
7
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
8
7
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
9
8
  import "@intlayer/editor-react";
10
9
  import "deepmerge";
10
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
11
11
  import { useAuth } from "../../Auth/useAuth/index.mjs";
12
12
  import "../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs";
13
13
  import "@intlayer/api";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactIntlayer = require("react-intlayer");
4
4
  const components_DictionaryFieldEditor_DictionaryCreationForm_useDictionaryFormSchema_content = require("./useDictionaryFormSchema.content.cjs");
5
- const schemas = require("../../../schemas-DJhUvjsx.cjs");
5
+ const schemas = require("../../../schemas-DlCjM5d_.cjs");
6
6
  const useDictionarySchema = (projectId) => {
7
7
  const {
8
8
  requiredErrorName,
@@ -1,6 +1,6 @@
1
1
  import { useDictionary } from "react-intlayer";
2
2
  import { dictionaryFormSchemaContent } from "./useDictionaryFormSchema.content.mjs";
3
- import { o as object, a as array, s as string } from "../../../schemas-7jC6hy_u.js";
3
+ import { o as object, a as array, s as string } from "../../../schemas-itjzX6bG.js";
4
4
  const useDictionarySchema = (projectId) => {
5
5
  const {
6
6
  requiredErrorName,
@@ -6,10 +6,10 @@ const editorReact = require("@intlayer/editor-react");
6
6
  const lucideReact = require("lucide-react");
7
7
  const ReactExports = require("react");
8
8
  const reactIntlayer = require("react-intlayer");
9
- require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
10
- require("../../../hooks/useAsync/useAsyncStateStore.cjs");
11
9
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
10
+ require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
11
  require("deepmerge");
12
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
13
13
  require("../../Button/Button.cjs");
14
14
  const components_Auth_useAuth_index = require("../../Auth/useAuth/index.cjs");
15
15
  require("../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs");
@@ -4,10 +4,10 @@ import { useEditedContent } from "@intlayer/editor-react";
4
4
  import { WandSparkles } from "lucide-react";
5
5
  import { useEffect } from "react";
6
6
  import { useDictionary } from "react-intlayer";
7
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
8
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
9
7
  import { useGetProjects, useGetTags, useAuditContentDeclarationMetadata } from "../../../hooks/intlayerAPIHooks.mjs";
8
+ import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
9
  import "deepmerge";
10
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
11
11
  import "../../Button/Button.mjs";
12
12
  import { useAuth } from "../../Auth/useAuth/index.mjs";
13
13
  import "../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactIntlayer = require("react-intlayer");
4
4
  const components_DictionaryFieldEditor_DictionaryDetails_useDictionaryDetailsSchema_content = require("./useDictionaryDetailsSchema.content.cjs");
5
- const schemas = require("../../../schemas-DJhUvjsx.cjs");
5
+ const schemas = require("../../../schemas-DlCjM5d_.cjs");
6
6
  const useDictionaryDetailsSchema = (projectId) => {
7
7
  const {
8
8
  titleRequiredError,
@@ -1,6 +1,6 @@
1
1
  import { useDictionary } from "react-intlayer";
2
2
  import { useDictionaryDetailsSchemaContent } from "./useDictionaryDetailsSchema.content.mjs";
3
- import { o as object, a as array, s as string } from "../../../schemas-7jC6hy_u.js";
3
+ import { o as object, a as array, s as string } from "../../../schemas-itjzX6bG.js";
4
4
  const useDictionaryDetailsSchema = (projectId) => {
5
5
  const {
6
6
  titleRequiredError,
@@ -10,12 +10,12 @@ 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("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
14
- require("../../hooks/useAsync/useAsyncStateStore.cjs");
15
13
  require("@intlayer/api");
16
14
  require("@intlayer/config/built");
15
+ require("../../hooks/useAsync/useAsyncStateStore.cjs");
17
16
  require("../Toaster/Toast.cjs");
18
17
  require("deepmerge");
18
+ require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
19
19
  require("../Container/index.cjs");
20
20
  require("../DropDown/index.cjs");
21
21
  require("../Input/Input.cjs");
@@ -8,12 +8,12 @@ import { Button } from "../Button/Button.mjs";
8
8
  import "@intlayer/config/client";
9
9
  import "@intlayer/core";
10
10
  import "fuse.js";
11
- import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
12
- import "../../hooks/useAsync/useAsyncStateStore.mjs";
13
11
  import "@intlayer/api";
14
12
  import "@intlayer/config/built";
13
+ import "../../hooks/useAsync/useAsyncStateStore.mjs";
15
14
  import "../Toaster/Toast.mjs";
16
15
  import "deepmerge";
16
+ import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
17
17
  import "../Container/index.mjs";
18
18
  import "../DropDown/index.mjs";
19
19
  import "../Input/Input.mjs";
@@ -7,10 +7,10 @@ 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("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
11
- require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
10
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
11
+ require("../../../hooks/useAsync/useAsyncStateStore.cjs");
13
12
  require("deepmerge");
13
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
14
14
  const utils_cn = require("../../../utils/cn.cjs");
15
15
  require("../../Button/Button.cjs");
16
16
  const components_Auth_useAuth_index = require("../../Auth/useAuth/index.cjs");
@@ -5,10 +5,10 @@ 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 "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
8
  import { useDeleteDictionary, useWriteDictionary, usePushDictionaries } from "../../../hooks/intlayerAPIHooks.mjs";
9
+ import "../../../hooks/useAsync/useAsyncStateStore.mjs";
11
10
  import "deepmerge";
11
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
12
12
  import { cn } from "../../../utils/cn.mjs";
13
13
  import "../../Button/Button.mjs";
14
14
  import { useAuth } from "../../Auth/useAuth/index.mjs";
@@ -15,12 +15,12 @@ require("clsx");
15
15
  require("tailwind-merge");
16
16
  require("../../Input/Input.cjs");
17
17
  require("../../Input/Checkbox.cjs");
18
- require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
19
- require("../../../hooks/useAsync/useAsyncStateStore.cjs");
20
18
  require("@intlayer/api");
21
19
  require("@intlayer/config/built");
20
+ require("../../../hooks/useAsync/useAsyncStateStore.cjs");
22
21
  require("../../Toaster/Toast.cjs");
23
22
  require("deepmerge");
23
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
24
24
  const components_DictionaryFieldEditor_NodeTypeSelector = require("../NodeTypeSelector.cjs");
25
25
  const components_DictionaryFieldEditor_StructureView_structureView_content = require("./structureView.content.cjs");
26
26
  const NodeTypeView = ({
@@ -214,7 +214,7 @@ const ObjectView = ({
214
214
  if (!section || typeof section !== "object") {
215
215
  return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Not an object" });
216
216
  }
217
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 overflow-y-scroll", children: [
217
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 overflow-y-auto", children: [
218
218
  /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mr-auto flex flex-col gap-4", children: Object.keys(section).map((key) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
219
219
  NodeView,
220
220
  {
@@ -1 +1 @@
1
- {"version":3,"file":"StructureView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyPath,\n type TypedNode,\n type ContentNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n NodeType,\n getDefaultNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration()?.internationalization.locales ?? [];\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey?: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\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-scroll\">\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,EACz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,aAAa,UAC5B;AAEE,WAAAE,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;;"}
1
+ {"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":";;;;;;;;;;;;;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,SAAS;AACf,gBAAM,aAAa;AAAA,YACjB,GAAG;AAAA,YACH,EAAE,MAAMjB,KAAAA,SAAS,QAAQ,KAAK,OAAO;AAAA,UACvC;AACiB,2BAAA,eAAe,IAAI,UAAU;AAC9C,mCAAyB,UAAU;AAAA,QACrC;AAAA,QAEC,UAAc,cAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAQO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,MAAA,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAC5B;AAEE,WAAAE,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;;"}
@@ -1,4 +1,4 @@
1
- import { KeyPath, ContentNode } from '@intlayer/core';
1
+ import { ContentNode, KeyPath } from '@intlayer/core';
2
2
  import { FC } from 'react';
3
3
  type NodeWrapperProps = {
4
4
  sectionKey?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"StructureView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,WAAW,EAMjB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AA6HhC,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CA6EzC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgD1C,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA2BhD,CAAC"}
1
+ {"version":3,"file":"StructureView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAKhB,KAAK,OAAO,EAGb,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AA6HhC,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CA6EzC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgD1C,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA2BhD,CAAC"}
@@ -13,12 +13,12 @@ import "clsx";
13
13
  import "tailwind-merge";
14
14
  import "../../Input/Input.mjs";
15
15
  import "../../Input/Checkbox.mjs";
16
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
17
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
18
16
  import "@intlayer/api";
19
17
  import "@intlayer/config/built";
18
+ import "../../../hooks/useAsync/useAsyncStateStore.mjs";
20
19
  import "../../Toaster/Toast.mjs";
21
20
  import "deepmerge";
21
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
22
22
  import { NodeTypeSelector } from "../NodeTypeSelector.mjs";
23
23
  import { structureViewContent } from "./structureView.content.mjs";
24
24
  const NodeTypeView = ({
@@ -212,7 +212,7 @@ const ObjectView = ({
212
212
  if (!section || typeof section !== "object") {
213
213
  return /* @__PURE__ */ jsx("div", { children: "Not an object" });
214
214
  }
215
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 overflow-y-scroll", children: [
215
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 overflow-y-auto", children: [
216
216
  /* @__PURE__ */ jsx("ul", { className: "mr-auto flex flex-col gap-4", children: Object.keys(section).map((key) => /* @__PURE__ */ jsx("li", { className: "flex w-full", children: /* @__PURE__ */ jsx(
217
217
  NodeView,
218
218
  {
@@ -1 +1 @@
1
- {"version":3,"file":"StructureView.mjs","sources":["../../../../src/components/DictionaryFieldEditor/StructureView/StructureView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyPath,\n type TypedNode,\n type ContentNode,\n getNodeChildren,\n getNodeType,\n isSameKeyPath,\n NodeType,\n getDefaultNode,\n} from '@intlayer/core';\nimport {\n useConfiguration,\n useEditedContentActions,\n useFocusDictionary,\n useFocusDictionaryActions,\n} from '@intlayer/editor-react';\nimport { Plus, Trash } from 'lucide-react';\nimport { type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { Container } from '../../Container';\nimport { EditableFieldInput } from '../../EditableField';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { structureViewContent } from './structureView.content';\n\ntype NodeTypeViewProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n onNodeTypeChange: (content?: ContentNode) => void;\n};\n\nconst NodeTypeView: FC<NodeTypeViewProps> = ({\n section,\n dictionaryKey,\n keyPath,\n onNodeTypeChange: onNodeTypeChangeProp,\n}) => {\n const locales = useConfiguration()?.internationalization.locales ?? [];\n const nodeType = getNodeType(section);\n const children = getNodeChildren(section);\n\n const onNodeTypeChange = (content?: ContentNode) => {\n const transformedContent = getDefaultNode(\n nodeType,\n locales,\n content\n ) as ContentNode;\n\n onNodeTypeChangeProp(transformedContent);\n };\n\n if (\n nodeType === NodeType.Translation ||\n nodeType === NodeType.Condition ||\n nodeType === NodeType.Enumeration\n ) {\n const firstKey = Object.keys(\n (section as unknown as TypedNode)[nodeType as keyof typeof section]\n )[0];\n const childrenKeyPath = [\n ...keyPath,\n { type: nodeType, key: firstKey },\n ] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n const childrenKeyPath = [...keyPath, { type: nodeType, key: 0 } as KeyPath];\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n\n <NodeTypeView\n section={children}\n keyPath={childrenKeyPath}\n dictionaryKey={dictionaryKey}\n onNodeTypeChange={onNodeTypeChange}\n />\n </div>\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <>\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(\n getDefaultNode(nodeType, locales) as ContentNode\n )\n }\n />\n <div className=\"ml-10 mt-6\">\n <StructureView\n keyPath={keyPath}\n section={section}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </>\n );\n }\n\n return (\n <NodeTypeSelector\n section={section}\n onValueChange={(nodeType) =>\n onNodeTypeChangeProp(getDefaultNode(nodeType, locales) as ContentNode)\n }\n />\n );\n};\n\ntype NodeWrapperProps = {\n sectionKey?: string;\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: ContentNode;\n};\n\nexport const NodeView: FC<NodeWrapperProps> = ({\n sectionKey,\n section,\n keyPath,\n dictionaryKey,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const { renameEditedContent, addEditedContent } = useEditedContentActions();\n\n const { titleInput, deleteButton } = useDictionary(structureViewContent);\n\n const handleRenameNodeKey = (keyName: string) => {\n renameEditedContent(dictionaryKey, keyName, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: keyName } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <Container\n transparency=\"xl\"\n roundedSize=\"xl\"\n className=\"w-full min-w-80 gap-2 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-scroll\">\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":["nodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,MAAM;AACJ,QAAM,UAAU,iBAAA,GAAoB,qBAAqB,WAAW,CAAC;AAC/D,QAAA,WAAW,YAAY,OAAO;AAC9B,QAAA,WAAW,gBAAgB,OAAO;AAElC,QAAA,mBAAmB,CAAC,YAA0B;AAClD,UAAM,qBAAqB;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,yBAAqB,kBAAkB;AAAA,EACzC;AAGE,MAAA,aAAa,SAAS,eACtB,aAAa,SAAS,aACtB,aAAa,SAAS,aACtB;AACA,UAAM,WAAW,OAAO;AAAA,MACrB,QAAiC,QAAgC;AAAA,MAClE,CAAC;AACH,UAAM,kBAAkB;AAAA,MACtB,GAAG;AAAA,MACH,EAAE,MAAM,UAAU,KAAK,SAAS;AAAA,IAClC;AAGE,WAAA,qBAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,eAAe,CAACA,cACd;AAAA,YACE,eAAeA,WAAU,OAAO;AAAA,UAAA;AAAA,QAClC;AAAA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ACR,MAAK;AAAA,QACL,OAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAU;AAAA,QACV,SAAS,MAAM;AACb,gBAAM,SAAS;AACf,gBAAM,aAAa;AAAA,YACjB,GAAG;AAAA,YACH,EAAE,MAAM,SAAS,QAAQ,KAAK,OAAO;AAAA,UACvC;AACiB,2BAAA,eAAe,IAAI,UAAU;AAC9C,mCAAyB,UAAU;AAAA,QACrC;AAAA,QAEC,UAAc,cAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAQO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,MAAA,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAC5B;AAEE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"StructureView.mjs","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":["nodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,MAAM;AACJ,QAAM,UAAU,iBAAA,GAAoB,qBAAqB,WAAW,CAAC;AAC/D,QAAA,WAAW,YAAY,OAAO;AAC9B,QAAA,WAAW,gBAAgB,OAAO;AAElC,QAAA,mBAAmB,CAAC,YAA0B;AAClD,UAAM,qBAAqB;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,yBAAqB,kBAAkB;AAAA,EACzC;AAGE,MAAA,aAAa,SAAS,eACtB,aAAa,SAAS,aACtB,aAAa,SAAS,aACtB;AACA,UAAM,WAAW,OAAO;AAAA,MACrB,QAAiC,QAAgC;AAAA,MAClE,CAAC;AACH,UAAM,kBAAkB;AAAA,MACtB,GAAG;AAAA,MACH,EAAE,MAAM,UAAU,KAAK,SAAS;AAAA,IAClC;AAGE,WAAA,qBAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,eAAe,CAACA,cACd;AAAA,YACE,eAAeA,WAAU,OAAO;AAAA,UAAA;AAAA,QAClC;AAAA,MAEJ;AAAA,MAEA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SAAS;AAAA,UACT,SAAS;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,GACF;AAAA,EAAA;AAIA,MAAA,aAAa,SAAS,OAAO;AACzB,UAAA,kBAAkB,C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2BAAA,eAAe,IAAI,UAAU;AAC9C,mCAAyB,UAAU;AAAA,QACrC;AAAA,QAEC,UAAc,cAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAQO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,MAAA,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,aAAa,UAC5B;AAEE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -3,14 +3,14 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const ReactExports = require("react");
6
- require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
7
- require("../../../hooks/useAsync/useAsyncStateStore.cjs");
8
6
  require("@intlayer/editor-react");
9
7
  require("@intlayer/api");
10
8
  require("@intlayer/config/built");
9
+ require("../../../hooks/useAsync/useAsyncStateStore.cjs");
11
10
  require("../../Toaster/Toast.cjs");
12
11
  require("deepmerge");
13
12
  const hooks_usePersistedStore = require("../../../hooks/usePersistedStore.cjs");
13
+ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
14
14
  const VersionSwitcherContext = ReactExports.createContext({
15
15
  availableVersions: [],
16
16
  selectedVersion: null,
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext } from "react";
4
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
5
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
6
4
  import "@intlayer/editor-react";
7
5
  import "@intlayer/api";
8
6
  import "@intlayer/config/built";
7
+ import "../../../hooks/useAsync/useAsyncStateStore.mjs";
9
8
  import "../../Toaster/Toast.mjs";
10
9
  import "deepmerge";
11
10
  import { usePersistedStore } from "../../../hooks/usePersistedStore.mjs";
11
+ import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
12
12
  const VersionSwitcherContext = createContext({
13
13
  availableVersions: [],
14
14
  selectedVersion: null,
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const hooks_useDevice = require("../../hooks/useDevice.cjs");
5
- require("react");
6
- require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
7
- require("../../hooks/useAsync/useAsyncStateStore.cjs");
8
- require("@intlayer/editor-react");
9
- require("@intlayer/api");
10
- require("@intlayer/config/built");
11
- require("../Toaster/Toast.cjs");
12
- require("deepmerge");
13
4
  const utils_cn = require("../../utils/cn.cjs");
14
5
  const components_MaxHeightSmoother_index = require("../MaxHeightSmoother/index.cjs");
15
6
  const DropDown = ({
@@ -39,10 +30,7 @@ const Trigger = ({
39
30
  className: utils_cn.cn("w-full cursor-pointer", className),
40
31
  "aria-label": `Open panel ${identifier}`,
41
32
  onClick: (e) => {
42
- const isIOS = hooks_useDevice.checkIsIphoneOrSafariDevice();
43
- if (isIOS) {
44
- e.currentTarget.focus({ preventScroll: true });
45
- }
33
+ e.currentTarget.focus();
46
34
  },
47
35
  onBlur: (e) => e.currentTarget.blur(),
48
36
  ...props,