@intlayer/design-system 5.1.2 → 5.1.4

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 (98) hide show
  1. package/dist/.vite/manifest.json +12 -23
  2. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
  3. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
  4. package/dist/components/Container/index.cjs +5 -2
  5. package/dist/components/Container/index.cjs.map +1 -1
  6. package/dist/components/Container/index.d.ts +1 -1
  7. package/dist/components/Container/index.d.ts.map +1 -1
  8. package/dist/components/Container/index.mjs +5 -2
  9. package/dist/components/Container/index.mjs.map +1 -1
  10. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +27 -6
  11. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
  12. package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts +1 -0
  13. package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
  14. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +27 -6
  15. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  16. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +278 -214
  17. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  18. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +2 -0
  19. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  20. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +281 -217
  21. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  22. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +5 -3
  23. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts +5 -1
  25. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
  26. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +5 -3
  27. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
  28. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
  29. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
  30. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +1 -1
  31. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  32. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
  33. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -1
  35. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
  36. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -1
  37. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
  38. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -13
  39. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  40. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  41. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +19 -14
  42. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  43. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +64 -0
  44. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
  45. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +64 -0
  46. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
  47. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +64 -0
  48. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
  49. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +1 -1
  50. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
  51. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs +6 -16
  52. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs.map +1 -1
  53. package/dist/components/DictionaryFieldEditor/StructureEditor.d.ts.map +1 -1
  54. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs +7 -17
  55. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
  56. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +8 -7
  57. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  58. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +7 -0
  59. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  60. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +11 -10
  61. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  62. package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +2 -1
  63. package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
  64. package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
  65. package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +3 -2
  66. package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
  67. package/dist/components/MarkDownRender/index.cjs.map +1 -1
  68. package/dist/components/MarkDownRender/index.d.ts +1 -1
  69. package/dist/components/MarkDownRender/index.d.ts.map +1 -1
  70. package/dist/components/MarkDownRender/index.mjs.map +1 -1
  71. package/dist/components/MaxHeightSmoother/index.cjs +1 -1
  72. package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
  73. package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
  74. package/dist/components/MaxHeightSmoother/index.mjs +1 -1
  75. package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
  76. package/dist/hooks/intlayerAPIHooks.cjs +1 -1
  77. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  78. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  79. package/dist/hooks/intlayerAPIHooks.mjs +1 -1
  80. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  81. package/dist/index-BCuMWKyy.js.map +1 -1
  82. package/dist/{index-BKE0uywA.js → index-BTDHuTxL.js} +2 -2
  83. package/dist/index-BTDHuTxL.js.map +1 -0
  84. package/dist/index-BYzBot7l.cjs.map +1 -1
  85. package/dist/{index-CsenS2hX.cjs → index-Db5Dym4h.cjs} +2 -2
  86. package/dist/index-Db5Dym4h.cjs.map +1 -0
  87. package/dist/tailwind.css +1 -1
  88. package/dist/zod-BV4nCGJE.js.map +1 -1
  89. package/dist/zod-DSrtTSD_.cjs.map +1 -1
  90. package/package.json +19 -19
  91. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs +0 -44
  92. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs.map +0 -1
  93. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts +0 -9
  94. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts.map +0 -1
  95. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs +0 -44
  96. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs.map +0 -1
  97. package/dist/index-BKE0uywA.js.map +0 -1
  98. package/dist/index-CsenS2hX.cjs.map +0 -1
@@ -1,30 +1,30 @@
1
1
  "use client";
2
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
- import { getNodeType, NodeType, getLocaleName } from "@intlayer/core";
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { getNodeType, NodeType, getLocaleName, getEmptyNode } from "@intlayer/core";
4
4
  import { useEditedContent, useConfiguration } from "@intlayer/editor-react";
5
- import { X, Plus, WandSparkles } from "lucide-react";
5
+ import { Trash, Plus, WandSparkles } from "lucide-react";
6
+ import { Fragment as Fragment$1, useState } from "react";
6
7
  import { useDictionary, useLocale } from "react-intlayer";
7
- import "react";
8
8
  import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
9
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
10
  import { useAuditContentDeclarationField } from "../../../hooks/intlayerAPIHooks.mjs";
11
11
  import "deepmerge";
12
12
  import { renameKey } from "../../../utils/object.mjs";
13
13
  import { Button } from "../../Button/Button.mjs";
14
+ import { Container } from "../../Container/index.mjs";
14
15
  import { ContentEditorInput as ContentEditorInput$1 } from "../../ContentEditor/ContentEditorInput.mjs";
15
16
  import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
16
17
  import { Label } from "../../Label/index.mjs";
17
18
  import "@intlayer/config/client";
18
19
  import "fuse.js";
19
- import "../../Container/index.mjs";
20
20
  import "../../DropDown/index.mjs";
21
21
  import "../../Input/Input.mjs";
22
22
  import "../../Input/Checkbox.mjs";
23
23
  import { SwitchSelector } from "../../SwitchSelector/index.mjs";
24
24
  import "../../LocaleSwitcherContentDropDown/localeSwitcher.content.mjs";
25
25
  import { useLocaleSwitcherContent } from "../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
26
+ import { MarkdownRenderer } from "../../MarkDownRender/index.mjs";
26
27
  import { EnumKeyInput } from "../EnumKeyInput.mjs";
27
- import { getIsEditableSection } from "../getIsEditableSection.mjs";
28
28
  import { navigationViewContent } from "../NavigationView/navigationViewNode.content.mjs";
29
29
  const traceKeys = ["filePath", "id", "nodeType"];
30
30
  const ContentEditorTextArea = ({
@@ -119,7 +119,7 @@ const TranslationTextEditor = ({
119
119
  keyPath,
120
120
  dictionary
121
121
  }) => {
122
- const { locale } = useLocale();
122
+ const { locale, defaultLocale } = useLocale();
123
123
  const { selectedLocales, availableLocales } = useLocaleSwitcherContent();
124
124
  const sectionContent = section[NodeType.Translation];
125
125
  const sectionContentKeys = Object.keys(sectionContent);
@@ -128,20 +128,21 @@ const TranslationTextEditor = ({
128
128
  // If the translation include content in other locales, we display all of them
129
129
  [.../* @__PURE__ */ new Set([...availableLocales, ...sectionContentKeys])]
130
130
  );
131
- return /* @__PURE__ */ jsx("table", { className: "w-full gap-2", children: /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: localesList.map((translationKey) => /* @__PURE__ */ jsx("tr", { className: "w-full", lang: translationKey, children: /* @__PURE__ */ jsxs("td", { className: "flex w-full flex-col p-2", children: [
132
- selectedLocales.length > 1 && /* @__PURE__ */ jsx("span", { className: "w-full p-2 text-xs", children: getLocaleName(translationKey, locale) }),
133
- /* @__PURE__ */ jsx(
134
- TextEditor,
131
+ const content = section[NodeType.Translation];
132
+ return /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: localesList.map((translationKey) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
133
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 w-full p-2 text-xs", children: getLocaleName(translationKey, locale) }),
134
+ /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
135
+ TextEditorContainer,
135
136
  {
136
- section: section[NodeType.Translation][translationKey],
137
+ section: content[translationKey] ?? getEmptyNode(content[defaultLocale]),
137
138
  keyPath: [
138
139
  ...keyPath,
139
140
  { type: NodeType.Translation, key: translationKey }
140
141
  ],
141
142
  dictionary
142
143
  }
143
- )
144
- ] }) }, translationKey)) }) });
144
+ ) })
145
+ ] }, translationKey)) }) });
145
146
  };
146
147
  const EnumerationTextEditor = ({
147
148
  section,
@@ -149,31 +150,37 @@ const EnumerationTextEditor = ({
149
150
  dictionary
150
151
  }) => {
151
152
  const { addEditedContent } = useEditedContent();
152
- const { addNewEnumeration } = useDictionary(navigationViewContent);
153
- return /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed gap-2", children: [
154
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: Object.keys(
153
+ const { addNewEnumeration, removeEnumeration } = useDictionary(
154
+ navigationViewContent
155
+ );
156
+ const content = section[NodeType.Enumeration];
157
+ const firstKey = Object.keys(content)[0];
158
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
159
+ /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: Object.keys(
155
160
  section[NodeType.Enumeration]
156
- ).map((enumKey) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
157
- /* @__PURE__ */ jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
158
- /* @__PURE__ */ jsx(
161
+ ).map((enumKey) => {
162
+ const childrenKeyPath = [
163
+ ...keyPath,
164
+ { type: NodeType.Enumeration }
165
+ ];
166
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
167
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1", children: /* @__PURE__ */ jsx(
159
168
  Button,
160
169
  {
161
- label: "Remove",
170
+ label: removeEnumeration.label.value,
162
171
  variant: "hoverable",
163
- size: "icon-md",
164
172
  color: "text",
165
- Icon: X,
166
- className: "w-16",
167
- onClick: () => addEditedContent(dictionary.key, void 0, [
168
- ...keyPath,
169
- {
170
- type: NodeType.Enumeration,
171
- key: enumKey
172
- }
173
- ])
173
+ Icon: Trash,
174
+ className: "ml-auto",
175
+ onClick: () => addEditedContent(
176
+ dictionary.key,
177
+ void 0,
178
+ childrenKeyPath
179
+ ),
180
+ children: removeEnumeration.text
174
181
  }
175
- ),
176
- /* @__PURE__ */ jsx(
182
+ ) }) }),
183
+ /* @__PURE__ */ jsx("tr", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
177
184
  EnumKeyInput,
178
185
  {
179
186
  value: enumKey,
@@ -191,38 +198,35 @@ const EnumerationTextEditor = ({
191
198
  addEditedContent(dictionary.key, newValue, keyPath);
192
199
  }
193
200
  }
194
- )
195
- ] }) }),
196
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
197
- TextEditor,
198
- {
199
- section: section[NodeType.Enumeration][enumKey],
200
- keyPath: [
201
- ...keyPath,
202
- { type: NodeType.Enumeration, key: enumKey }
203
- ],
204
- dictionary
205
- }
206
- ) })
207
- ] }, enumKey)) }),
208
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
201
+ ) }),
202
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
203
+ TextEditor,
204
+ {
205
+ section: content[enumKey] ?? getEmptyNode(content[firstKey]),
206
+ keyPath: childrenKeyPath,
207
+ dictionary
208
+ }
209
+ ) })
210
+ ] }, enumKey);
211
+ }) }) }),
212
+ /* @__PURE__ */ jsx(
209
213
  Button,
210
214
  {
211
215
  label: addNewEnumeration.label.value,
212
216
  variant: "hoverable",
213
217
  color: "neutral",
214
218
  textAlign: "left",
219
+ isFullWidth: true,
215
220
  onClick: () => addEditedContent(
216
221
  dictionary.key,
217
- "",
218
- [...keyPath, { type: NodeType.Enumeration, key: "unknown" }],
219
- false
222
+ getEmptyNode(content[firstKey]) ?? "",
223
+ [...keyPath, { type: NodeType.Enumeration, key: "unknown" }]
220
224
  ),
221
225
  Icon: Plus,
222
226
  className: "m-2",
223
227
  children: addNewEnumeration.text
224
228
  }
225
- ) })
229
+ )
226
230
  ] });
227
231
  };
228
232
  const ConditionTextEditor = ({
@@ -230,83 +234,24 @@ const ConditionTextEditor = ({
230
234
  keyPath,
231
235
  dictionary
232
236
  }) => {
233
- const { addEditedContent } = useEditedContent();
234
- const { addNewEnumeration } = useDictionary(navigationViewContent);
235
- return /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed gap-2", children: [
236
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
237
- /* @__PURE__ */ jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
238
- /* @__PURE__ */ jsx(
239
- Button,
237
+ const content = section[NodeType.Condition];
238
+ return /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
239
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 block w-full p-2 text-xs", children: String(condKey) }, condKey),
240
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
241
+ TextEditorContainer,
242
+ {
243
+ section: content[condKey] ?? getEmptyNode(content["true"]),
244
+ keyPath: [
245
+ ...keyPath,
240
246
  {
241
- label: "Remove",
242
- variant: "hoverable",
243
- size: "icon-md",
244
- color: "text",
245
- Icon: X,
246
- className: "w-16",
247
- onClick: () => addEditedContent(dictionary.key, void 0, [
248
- ...keyPath,
249
- {
250
- type: NodeType.Condition,
251
- key: condKey
252
- }
253
- ])
247
+ type: NodeType.Condition,
248
+ key: condKey
254
249
  }
255
- ),
256
- /* @__PURE__ */ jsx(
257
- EnumKeyInput,
258
- {
259
- value: condKey,
260
- onChange: (value) => {
261
- const preValueContent = section[NodeType.Condition];
262
- const newValueContent = renameKey(
263
- preValueContent,
264
- condKey,
265
- value
266
- );
267
- const newValue = {
268
- ...section,
269
- [NodeType.Condition]: newValueContent
270
- };
271
- addEditedContent(dictionary.key, newValue, keyPath);
272
- }
273
- }
274
- )
275
- ] }) }),
276
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
277
- TextEditor,
278
- {
279
- section: section[NodeType.Enumeration][condKey],
280
- keyPath: [
281
- ...keyPath,
282
- {
283
- type: NodeType.Array,
284
- key: parseInt(condKey)
285
- }
286
- ],
287
- dictionary
288
- }
289
- ) })
290
- ] }, condKey)) }),
291
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
292
- Button,
293
- {
294
- label: addNewEnumeration.label.value,
295
- variant: "hoverable",
296
- color: "neutral",
297
- textAlign: "left",
298
- onClick: () => addEditedContent(
299
- dictionary.key,
300
- "",
301
- [...keyPath, { type: NodeType.Enumeration, key: "unknown" }],
302
- false
303
- ),
304
- Icon: Plus,
305
- className: "m-2",
306
- children: addNewEnumeration.text
250
+ ],
251
+ dictionary
307
252
  }
308
- ) })
309
- ] });
253
+ ) }, condKey)
254
+ ] }, condKey)) }) });
310
255
  };
311
256
  const ArrayTextEditor = ({
312
257
  section,
@@ -314,14 +259,38 @@ const ArrayTextEditor = ({
314
259
  dictionary
315
260
  }) => {
316
261
  const { addEditedContent } = useEditedContent();
317
- const { addNewElement } = useDictionary(navigationViewContent);
318
- return /* @__PURE__ */ jsxs("table", { className: "w-full gap-2", children: [
319
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
320
- /* @__PURE__ */ jsx("td", { className: "p-2", children: index }),
321
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
322
- TextEditor,
262
+ const { addNewElement, removeElement } = useDictionary(navigationViewContent);
263
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
264
+ /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: section.map((subSection, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
265
+ /* @__PURE__ */ jsxs("tr", { className: "mt-2 flex w-full justify-between gap-2 p-2", children: [
266
+ /* @__PURE__ */ jsx("span", { className: "text-xs", children: String(index) }),
267
+ /* @__PURE__ */ jsx(
268
+ Button,
269
+ {
270
+ label: removeElement.label.value,
271
+ variant: "hoverable",
272
+ color: "neutral",
273
+ className: "ml-auto",
274
+ textAlign: "left",
275
+ onClick: () => {
276
+ const newKeyPath = [
277
+ ...keyPath,
278
+ {
279
+ type: NodeType.Array,
280
+ key: section.length
281
+ }
282
+ ];
283
+ addEditedContent(dictionary.key, void 0, newKeyPath);
284
+ },
285
+ Icon: Trash,
286
+ children: removeElement.text
287
+ }
288
+ )
289
+ ] }),
290
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
291
+ TextEditorContainer,
323
292
  {
324
- section: subSection,
293
+ section: subSection ?? getEmptyNode(section[0]),
325
294
  keyPath: [
326
295
  ...keyPath,
327
296
  {
@@ -332,14 +301,15 @@ const ArrayTextEditor = ({
332
301
  dictionary
333
302
  }
334
303
  ) })
335
- ] }, JSON.stringify(subSection))) }),
336
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
304
+ ] }, JSON.stringify(subSection))) }) }),
305
+ /* @__PURE__ */ jsx(
337
306
  Button,
338
307
  {
339
308
  label: addNewElement.label.value,
340
309
  variant: "hoverable",
341
310
  color: "neutral",
342
311
  textAlign: "left",
312
+ isFullWidth: true,
343
313
  onClick: () => {
344
314
  const newKeyPath = [
345
315
  ...keyPath,
@@ -348,29 +318,101 @@ const ArrayTextEditor = ({
348
318
  key: section.length
349
319
  }
350
320
  ];
351
- addEditedContent(dictionary.key, "", newKeyPath, false);
321
+ addEditedContent(
322
+ dictionary.key,
323
+ getEmptyNode(section[0]) ?? "",
324
+ newKeyPath,
325
+ false
326
+ );
352
327
  },
353
328
  Icon: Plus,
354
329
  children: addNewElement.text
355
330
  }
356
- ) })
331
+ )
357
332
  ] });
358
333
  };
359
- const MarkdownTextEditor = ({
334
+ const ObjectTextEditor = ({
360
335
  section,
361
336
  keyPath,
362
337
  dictionary
338
+ }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex flex-col gap-2", children: Object.keys(section).map(
339
+ (key) => {
340
+ const childKeyPath = [
341
+ ...keyPath,
342
+ { type: NodeType.Object, key }
343
+ ];
344
+ const typedSection = section;
345
+ const firstKey = Object.keys(
346
+ typedSection
347
+ )[0];
348
+ const subSection = typedSection[key] ?? getEmptyNode(typedSection[firstKey]);
349
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
350
+ /* @__PURE__ */ jsx(
351
+ "tr",
352
+ {
353
+ className: "mt-2 p-2 text-xs",
354
+ children: String(key)
355
+ },
356
+ JSON.stringify(subSection)
357
+ ),
358
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
359
+ TextEditor,
360
+ {
361
+ section: subSection,
362
+ keyPath: childKeyPath,
363
+ dictionary
364
+ }
365
+ ) }, JSON.stringify(subSection))
366
+ ] }, key);
367
+ }
368
+ ) }) }) });
369
+ const MarkdownTextEditor = ({
370
+ section,
371
+ keyPath,
372
+ dictionary,
373
+ isDarkMode
363
374
  }) => {
364
- return /* @__PURE__ */ jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
365
- ContentEditorTextArea,
375
+ const [mode, setMode] = useState(
376
+ 0
377
+ /* Edit */
378
+ );
379
+ const toggleContent2 = [
366
380
  {
367
- variant: "default",
368
- "aria-label": "Edit field",
369
- keyPath: [...keyPath, { type: NodeType.Markdown }],
370
- dictionary,
371
- children: section[NodeType.Markdown]
381
+ content: "Edit",
382
+ value: 0
383
+ /* Edit */
384
+ },
385
+ {
386
+ content: "Preview",
387
+ value: 1
388
+ /* Preview */
372
389
  }
373
- ) });
390
+ ];
391
+ const content = section[NodeType.Markdown];
392
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col justify-center gap-6 p-2", children: [
393
+ /* @__PURE__ */ jsx(
394
+ SwitchSelector,
395
+ {
396
+ choices: toggleContent2,
397
+ value: mode,
398
+ onChange: setMode,
399
+ color: "text",
400
+ size: "sm",
401
+ className: "ml-auto"
402
+ }
403
+ ),
404
+ mode === 0 && /* @__PURE__ */ jsx(
405
+ ContentEditorTextArea,
406
+ {
407
+ variant: "default",
408
+ "aria-label": "Edit field",
409
+ keyPath: [...keyPath, { type: NodeType.Markdown }],
410
+ dictionary,
411
+ children: content
412
+ }
413
+ ),
414
+ mode === 1 && /* @__PURE__ */ jsx(MarkdownRenderer, { isDarkMode, children: content })
415
+ ] });
374
416
  };
375
417
  const NestedTextEditor = ({
376
418
  keyPath,
@@ -429,79 +471,87 @@ const NestedTextEditor = ({
429
471
  const TextEditor = ({
430
472
  section,
431
473
  keyPath,
432
- dictionary
474
+ dictionary,
475
+ isDarkMode
433
476
  }) => {
434
477
  const { tsxNotEditable } = useDictionary(navigationViewContent);
435
478
  const nodeType = getNodeType(section);
436
- const isEditableSection = getIsEditableSection(section);
437
- if (!isEditableSection) return /* @__PURE__ */ jsx(Fragment, {});
438
- if (typeof section === "object") {
439
- if (nodeType === NodeType.ReactNode) {
440
- return /* @__PURE__ */ jsxs(Fragment, { children: [
441
- /* @__PURE__ */ jsx("span", { children: "[React Node]" }),
442
- /* @__PURE__ */ jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
443
- ] });
444
- }
445
- if (nodeType === NodeType.Nested) {
446
- return /* @__PURE__ */ jsx(
447
- NestedTextEditor,
448
- {
449
- dictionary,
450
- keyPath,
451
- section
452
- }
453
- );
454
- }
455
- if (nodeType === NodeType.Translation) {
456
- return /* @__PURE__ */ jsx(
457
- TranslationTextEditor,
458
- {
459
- dictionary,
460
- keyPath,
461
- section
462
- }
463
- );
464
- }
465
- if (nodeType === NodeType.Enumeration) {
466
- return /* @__PURE__ */ jsx(
467
- EnumerationTextEditor,
468
- {
469
- dictionary,
470
- keyPath,
471
- section
472
- }
473
- );
474
- }
475
- if (nodeType === NodeType.Condition) {
476
- return /* @__PURE__ */ jsx(
477
- ConditionTextEditor,
478
- {
479
- dictionary,
480
- keyPath,
481
- section
482
- }
483
- );
484
- }
485
- if (nodeType === NodeType.Markdown) {
486
- return /* @__PURE__ */ jsx(
487
- MarkdownTextEditor,
488
- {
489
- dictionary,
490
- keyPath,
491
- section
492
- }
493
- );
494
- }
495
- if (nodeType === NodeType.Array) {
496
- return /* @__PURE__ */ jsx(
497
- ArrayTextEditor,
498
- {
499
- dictionary,
500
- keyPath,
501
- section
502
- }
503
- );
504
- }
479
+ if (nodeType === NodeType.ReactNode) {
480
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
481
+ /* @__PURE__ */ jsx("span", { children: "[React Node]" }),
482
+ /* @__PURE__ */ jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
483
+ ] });
484
+ }
485
+ if (nodeType === NodeType.Nested) {
486
+ return /* @__PURE__ */ jsx(
487
+ NestedTextEditor,
488
+ {
489
+ dictionary,
490
+ keyPath,
491
+ section
492
+ }
493
+ );
494
+ }
495
+ if (nodeType === NodeType.Translation) {
496
+ return /* @__PURE__ */ jsx(
497
+ TranslationTextEditor,
498
+ {
499
+ dictionary,
500
+ keyPath,
501
+ section
502
+ }
503
+ );
504
+ }
505
+ if (nodeType === NodeType.Enumeration) {
506
+ return /* @__PURE__ */ jsx(
507
+ EnumerationTextEditor,
508
+ {
509
+ dictionary,
510
+ keyPath,
511
+ section
512
+ }
513
+ );
514
+ }
515
+ if (nodeType === NodeType.Condition) {
516
+ return /* @__PURE__ */ jsx(
517
+ ConditionTextEditor,
518
+ {
519
+ dictionary,
520
+ keyPath,
521
+ section
522
+ }
523
+ );
524
+ }
525
+ if (nodeType === NodeType.Markdown) {
526
+ return /* @__PURE__ */ jsx(
527
+ MarkdownTextEditor,
528
+ {
529
+ dictionary,
530
+ keyPath,
531
+ section,
532
+ isDarkMode
533
+ }
534
+ );
535
+ }
536
+ if (nodeType === NodeType.Array) {
537
+ return /* @__PURE__ */ jsx(
538
+ ArrayTextEditor,
539
+ {
540
+ dictionary,
541
+ keyPath,
542
+ section
543
+ }
544
+ );
545
+ }
546
+ if (nodeType === NodeType.Object) {
547
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
548
+ ObjectTextEditor,
549
+ {
550
+ dictionary,
551
+ keyPath,
552
+ section
553
+ }
554
+ ) });
505
555
  }
506
556
  if (nodeType === NodeType.Number) {
507
557
  return /* @__PURE__ */ jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
@@ -539,11 +589,25 @@ const TextEditor = ({
539
589
  }
540
590
  return /* @__PURE__ */ jsxs("div", { className: "w-full p-2", children: [
541
591
  "Error. Format not supported.",
542
- JSON.stringify(section)
592
+ JSON.stringify(section, null, 2),
593
+ JSON.stringify(keyPath, null, 2),
594
+ "NodeType : ",
595
+ nodeType
543
596
  ] });
544
597
  };
598
+ const TextEditorContainer = (props) => /* @__PURE__ */ jsx(
599
+ Container,
600
+ {
601
+ border: true,
602
+ background: "none",
603
+ className: "top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky",
604
+ roundedSize: "xl",
605
+ children: /* @__PURE__ */ jsx(TextEditor, { ...props })
606
+ }
607
+ );
545
608
  export {
546
609
  TextEditor,
610
+ TextEditorContainer,
547
611
  traceKeys
548
612
  };
549
613
  //# sourceMappingURL=TextEditor.mjs.map