@intlayer/design-system 5.1.3 → 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 (62) hide show
  1. package/dist/.vite/manifest.json +3 -14
  2. package/dist/components/Container/index.cjs +1 -1
  3. package/dist/components/Container/index.cjs.map +1 -1
  4. package/dist/components/Container/index.mjs +1 -1
  5. package/dist/components/Container/index.mjs.map +1 -1
  6. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +18 -7
  7. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
  8. package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
  9. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +18 -7
  10. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  11. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +233 -204
  12. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  13. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +1 -0
  14. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  15. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +237 -208
  16. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  17. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -1
  18. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
  19. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -1
  20. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
  21. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -12
  22. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  23. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +19 -13
  25. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  26. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +64 -0
  27. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
  28. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +64 -0
  29. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
  30. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +64 -0
  31. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
  32. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs +4 -4
  33. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/StructureEditor.d.ts.map +1 -1
  35. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs +4 -4
  36. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
  37. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +2 -2
  38. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  39. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +2 -2
  40. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  41. package/dist/components/MaxHeightSmoother/index.cjs +1 -1
  42. package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
  43. package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
  44. package/dist/components/MaxHeightSmoother/index.mjs +1 -1
  45. package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
  46. package/dist/hooks/intlayerAPIHooks.cjs +1 -1
  47. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  48. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  49. package/dist/hooks/intlayerAPIHooks.mjs +1 -1
  50. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  51. package/dist/index-BCuMWKyy.js.map +1 -1
  52. package/dist/index-BYzBot7l.cjs.map +1 -1
  53. package/dist/tailwind.css +1 -1
  54. package/dist/zod-BV4nCGJE.js.map +1 -1
  55. package/dist/zod-DSrtTSD_.cjs.map +1 -1
  56. package/package.json +19 -19
  57. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs +0 -49
  58. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs.map +0 -1
  59. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts +0 -10
  60. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts.map +0 -1
  61. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs +0 -49
  62. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs.map +0 -1
@@ -13,12 +13,12 @@ const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
13
13
  require("deepmerge");
14
14
  const utils_object = require("../../../utils/object.cjs");
15
15
  const components_Button_Button = require("../../Button/Button.cjs");
16
+ const components_Container_index = require("../../Container/index.cjs");
16
17
  const components_ContentEditor_ContentEditorInput = require("../../ContentEditor/ContentEditorInput.cjs");
17
18
  const components_ContentEditor_ContentEditorTextArea = require("../../ContentEditor/ContentEditorTextArea.cjs");
18
19
  const components_Label_index = require("../../Label/index.cjs");
19
20
  require("@intlayer/config/client");
20
21
  require("fuse.js");
21
- require("../../Container/index.cjs");
22
22
  require("../../DropDown/index.cjs");
23
23
  require("../../Input/Input.cjs");
24
24
  require("../../Input/Checkbox.cjs");
@@ -27,7 +27,6 @@ require("../../LocaleSwitcherContentDropDown/localeSwitcher.content.cjs");
27
27
  const components_LocaleSwitcherContentDropDown_LocaleSwitcherContentContext = require("../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs");
28
28
  const components_MarkDownRender_index = require("../../MarkDownRender/index.cjs");
29
29
  const components_DictionaryFieldEditor_EnumKeyInput = require("../EnumKeyInput.cjs");
30
- const components_DictionaryFieldEditor_getIsEditableSection = require("../getIsEditableSection.cjs");
31
30
  const components_DictionaryFieldEditor_NavigationView_navigationViewNode_content = require("../NavigationView/navigationViewNode.content.cjs");
32
31
  const traceKeys = ["filePath", "id", "nodeType"];
33
32
  const ContentEditorTextArea = ({
@@ -122,7 +121,7 @@ const TranslationTextEditor = ({
122
121
  keyPath,
123
122
  dictionary
124
123
  }) => {
125
- const { locale } = reactIntlayer.useLocale();
124
+ const { locale, defaultLocale } = reactIntlayer.useLocale();
126
125
  const { selectedLocales, availableLocales } = components_LocaleSwitcherContentDropDown_LocaleSwitcherContentContext.useLocaleSwitcherContent();
127
126
  const sectionContent = section[core.NodeType.Translation];
128
127
  const sectionContentKeys = Object.keys(sectionContent);
@@ -131,20 +130,21 @@ const TranslationTextEditor = ({
131
130
  // If the translation include content in other locales, we display all of them
132
131
  [.../* @__PURE__ */ new Set([...availableLocales, ...sectionContentKeys])]
133
132
  );
134
- return /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: localesList.map((translationKey) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "w-full", lang: translationKey, children: /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "flex w-full flex-col p-2", children: [
135
- selectedLocales.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-full p-2 text-xs", children: core.getLocaleName(translationKey, locale) }),
136
- /* @__PURE__ */ jsxRuntime.jsx(
137
- TextEditor,
133
+ const content = section[core.NodeType.Translation];
134
+ return /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "flex w-full flex-col gap-2", children: localesList.map((translationKey) => /* @__PURE__ */ jsxRuntime.jsxs(ReactExports.Fragment, { children: [
135
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "mt-2 w-full p-2 text-xs", children: core.getLocaleName(translationKey, locale) }),
136
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx(
137
+ TextEditorContainer,
138
138
  {
139
- section: section[core.NodeType.Translation][translationKey],
139
+ section: content[translationKey] ?? core.getEmptyNode(content[defaultLocale]),
140
140
  keyPath: [
141
141
  ...keyPath,
142
142
  { type: core.NodeType.Translation, key: translationKey }
143
143
  ],
144
144
  dictionary
145
145
  }
146
- )
147
- ] }) }, translationKey)) }) });
146
+ ) })
147
+ ] }, translationKey)) }) });
148
148
  };
149
149
  const EnumerationTextEditor = ({
150
150
  section,
@@ -152,31 +152,37 @@ const EnumerationTextEditor = ({
152
152
  dictionary
153
153
  }) => {
154
154
  const { addEditedContent } = editorReact.useEditedContent();
155
- const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
156
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed gap-2", children: [
157
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: Object.keys(
155
+ const { addNewEnumeration, removeEnumeration } = reactIntlayer.useDictionary(
156
+ components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent
157
+ );
158
+ const content = section[core.NodeType.Enumeration];
159
+ const firstKey = Object.keys(content)[0];
160
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
161
+ /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "flex w-full flex-col gap-2", children: Object.keys(
158
162
  section[core.NodeType.Enumeration]
159
- ).map((enumKey) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
160
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
161
- /* @__PURE__ */ jsxRuntime.jsx(
163
+ ).map((enumKey) => {
164
+ const childrenKeyPath = [
165
+ ...keyPath,
166
+ { type: core.NodeType.Enumeration }
167
+ ];
168
+ return /* @__PURE__ */ jsxRuntime.jsxs(ReactExports.Fragment, { children: [
169
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
162
170
  components_Button_Button.Button,
163
171
  {
164
- label: "Remove",
172
+ label: removeEnumeration.label.value,
165
173
  variant: "hoverable",
166
- size: "icon-md",
167
174
  color: "text",
168
- Icon: lucideReact.X,
169
- className: "w-16",
170
- onClick: () => addEditedContent(dictionary.key, void 0, [
171
- ...keyPath,
172
- {
173
- type: core.NodeType.Enumeration,
174
- key: enumKey
175
- }
176
- ])
175
+ Icon: lucideReact.Trash,
176
+ className: "ml-auto",
177
+ onClick: () => addEditedContent(
178
+ dictionary.key,
179
+ void 0,
180
+ childrenKeyPath
181
+ ),
182
+ children: removeEnumeration.text
177
183
  }
178
- ),
179
- /* @__PURE__ */ jsxRuntime.jsx(
184
+ ) }) }),
185
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
180
186
  components_DictionaryFieldEditor_EnumKeyInput.EnumKeyInput,
181
187
  {
182
188
  value: enumKey,
@@ -194,38 +200,35 @@ const EnumerationTextEditor = ({
194
200
  addEditedContent(dictionary.key, newValue, keyPath);
195
201
  }
196
202
  }
197
- )
198
- ] }) }),
199
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
200
- TextEditor,
201
- {
202
- section: section[core.NodeType.Enumeration][enumKey],
203
- keyPath: [
204
- ...keyPath,
205
- { type: core.NodeType.Enumeration, key: enumKey }
206
- ],
207
- dictionary
208
- }
209
- ) })
210
- ] }, enumKey)) }),
211
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsx(
203
+ ) }),
204
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
205
+ TextEditor,
206
+ {
207
+ section: content[enumKey] ?? core.getEmptyNode(content[firstKey]),
208
+ keyPath: childrenKeyPath,
209
+ dictionary
210
+ }
211
+ ) })
212
+ ] }, enumKey);
213
+ }) }) }),
214
+ /* @__PURE__ */ jsxRuntime.jsx(
212
215
  components_Button_Button.Button,
213
216
  {
214
217
  label: addNewEnumeration.label.value,
215
218
  variant: "hoverable",
216
219
  color: "neutral",
217
220
  textAlign: "left",
221
+ isFullWidth: true,
218
222
  onClick: () => addEditedContent(
219
223
  dictionary.key,
220
- "",
221
- [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }],
222
- false
224
+ core.getEmptyNode(content[firstKey]) ?? "",
225
+ [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }]
223
226
  ),
224
227
  Icon: lucideReact.Plus,
225
228
  className: "m-2",
226
229
  children: addNewEnumeration.text
227
230
  }
228
- ) })
231
+ )
229
232
  ] });
230
233
  };
231
234
  const ConditionTextEditor = ({
@@ -233,83 +236,24 @@ const ConditionTextEditor = ({
233
236
  keyPath,
234
237
  dictionary
235
238
  }) => {
236
- const { addEditedContent } = editorReact.useEditedContent();
237
- const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
238
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed gap-2", children: [
239
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
240
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
241
- /* @__PURE__ */ jsxRuntime.jsx(
242
- components_Button_Button.Button,
239
+ const content = section[core.NodeType.Condition];
240
+ return /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "flex w-full flex-col gap-2", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxRuntime.jsxs(ReactExports.Fragment, { children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "mt-2 block w-full p-2 text-xs", children: String(condKey) }, condKey),
242
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
243
+ TextEditorContainer,
244
+ {
245
+ section: content[condKey] ?? core.getEmptyNode(content["true"]),
246
+ keyPath: [
247
+ ...keyPath,
243
248
  {
244
- label: "Remove",
245
- variant: "hoverable",
246
- size: "icon-md",
247
- color: "text",
248
- Icon: lucideReact.X,
249
- className: "w-16",
250
- onClick: () => addEditedContent(dictionary.key, void 0, [
251
- ...keyPath,
252
- {
253
- type: core.NodeType.Condition,
254
- key: condKey
255
- }
256
- ])
249
+ type: core.NodeType.Condition,
250
+ key: condKey
257
251
  }
258
- ),
259
- /* @__PURE__ */ jsxRuntime.jsx(
260
- components_DictionaryFieldEditor_EnumKeyInput.EnumKeyInput,
261
- {
262
- value: condKey,
263
- onChange: (value) => {
264
- const preValueContent = section[core.NodeType.Condition];
265
- const newValueContent = utils_object.renameKey(
266
- preValueContent,
267
- condKey,
268
- value
269
- );
270
- const newValue = {
271
- ...section,
272
- [core.NodeType.Condition]: newValueContent
273
- };
274
- addEditedContent(dictionary.key, newValue, keyPath);
275
- }
276
- }
277
- )
278
- ] }) }),
279
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
280
- TextEditor,
281
- {
282
- section: section[core.NodeType.Enumeration][condKey],
283
- keyPath: [
284
- ...keyPath,
285
- {
286
- type: core.NodeType.Array,
287
- key: parseInt(condKey)
288
- }
289
- ],
290
- dictionary
291
- }
292
- ) })
293
- ] }, condKey)) }),
294
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsx(
295
- components_Button_Button.Button,
296
- {
297
- label: addNewEnumeration.label.value,
298
- variant: "hoverable",
299
- color: "neutral",
300
- textAlign: "left",
301
- onClick: () => addEditedContent(
302
- dictionary.key,
303
- "",
304
- [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }],
305
- false
306
- ),
307
- Icon: lucideReact.Plus,
308
- className: "m-2",
309
- children: addNewEnumeration.text
252
+ ],
253
+ dictionary
310
254
  }
311
- ) })
312
- ] });
255
+ ) }, condKey)
256
+ ] }, condKey)) }) });
313
257
  };
314
258
  const ArrayTextEditor = ({
315
259
  section,
@@ -317,14 +261,38 @@ const ArrayTextEditor = ({
317
261
  dictionary
318
262
  }) => {
319
263
  const { addEditedContent } = editorReact.useEditedContent();
320
- const { addNewElement } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
321
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full gap-2", children: [
322
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
323
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-2", children: index }),
324
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
325
- TextEditor,
264
+ const { addNewElement, removeElement } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
265
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
266
+ /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "flex w-full flex-col gap-2", children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntime.jsxs(ReactExports.Fragment, { children: [
267
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "mt-2 flex w-full justify-between gap-2 p-2", children: [
268
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: String(index) }),
269
+ /* @__PURE__ */ jsxRuntime.jsx(
270
+ components_Button_Button.Button,
271
+ {
272
+ label: removeElement.label.value,
273
+ variant: "hoverable",
274
+ color: "neutral",
275
+ className: "ml-auto",
276
+ textAlign: "left",
277
+ onClick: () => {
278
+ const newKeyPath = [
279
+ ...keyPath,
280
+ {
281
+ type: core.NodeType.Array,
282
+ key: section.length
283
+ }
284
+ ];
285
+ addEditedContent(dictionary.key, void 0, newKeyPath);
286
+ },
287
+ Icon: lucideReact.Trash,
288
+ children: removeElement.text
289
+ }
290
+ )
291
+ ] }),
292
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
293
+ TextEditorContainer,
326
294
  {
327
- section: subSection,
295
+ section: subSection ?? core.getEmptyNode(section[0]),
328
296
  keyPath: [
329
297
  ...keyPath,
330
298
  {
@@ -335,14 +303,15 @@ const ArrayTextEditor = ({
335
303
  dictionary
336
304
  }
337
305
  ) })
338
- ] }, JSON.stringify(subSection))) }),
339
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsx(
306
+ ] }, JSON.stringify(subSection))) }) }),
307
+ /* @__PURE__ */ jsxRuntime.jsx(
340
308
  components_Button_Button.Button,
341
309
  {
342
310
  label: addNewElement.label.value,
343
311
  variant: "hoverable",
344
312
  color: "neutral",
345
313
  textAlign: "left",
314
+ isFullWidth: true,
346
315
  onClick: () => {
347
316
  const newKeyPath = [
348
317
  ...keyPath,
@@ -351,14 +320,54 @@ const ArrayTextEditor = ({
351
320
  key: section.length
352
321
  }
353
322
  ];
354
- addEditedContent(dictionary.key, "", newKeyPath, false);
323
+ addEditedContent(
324
+ dictionary.key,
325
+ core.getEmptyNode(section[0]) ?? "",
326
+ newKeyPath,
327
+ false
328
+ );
355
329
  },
356
330
  Icon: lucideReact.Plus,
357
331
  children: addNewElement.text
358
332
  }
359
- ) })
333
+ )
360
334
  ] });
361
335
  };
336
+ const ObjectTextEditor = ({
337
+ section,
338
+ keyPath,
339
+ dictionary
340
+ }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx("table", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "flex flex-col gap-2", children: Object.keys(section).map(
341
+ (key) => {
342
+ const childKeyPath = [
343
+ ...keyPath,
344
+ { type: core.NodeType.Object, key }
345
+ ];
346
+ const typedSection = section;
347
+ const firstKey = Object.keys(
348
+ typedSection
349
+ )[0];
350
+ const subSection = typedSection[key] ?? core.getEmptyNode(typedSection[firstKey]);
351
+ return /* @__PURE__ */ jsxRuntime.jsxs(ReactExports.Fragment, { children: [
352
+ /* @__PURE__ */ jsxRuntime.jsx(
353
+ "tr",
354
+ {
355
+ className: "mt-2 p-2 text-xs",
356
+ children: String(key)
357
+ },
358
+ JSON.stringify(subSection)
359
+ ),
360
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
361
+ TextEditor,
362
+ {
363
+ section: subSection,
364
+ keyPath: childKeyPath,
365
+ dictionary
366
+ }
367
+ ) }, JSON.stringify(subSection))
368
+ ] }, key);
369
+ }
370
+ ) }) }) });
362
371
  const MarkdownTextEditor = ({
363
372
  section,
364
373
  keyPath,
@@ -469,76 +478,82 @@ const TextEditor = ({
469
478
  }) => {
470
479
  const { tsxNotEditable } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
471
480
  const nodeType = core.getNodeType(section);
472
- const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
473
- if (!isEditableSection) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
474
- if (typeof section === "object") {
475
- if (nodeType === core.NodeType.ReactNode) {
476
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
477
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "[React Node]" }),
478
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
479
- ] });
480
- }
481
- if (nodeType === core.NodeType.Nested) {
482
- return /* @__PURE__ */ jsxRuntime.jsx(
483
- NestedTextEditor,
484
- {
485
- dictionary,
486
- keyPath,
487
- section
488
- }
489
- );
490
- }
491
- if (nodeType === core.NodeType.Translation) {
492
- return /* @__PURE__ */ jsxRuntime.jsx(
493
- TranslationTextEditor,
494
- {
495
- dictionary,
496
- keyPath,
497
- section
498
- }
499
- );
500
- }
501
- if (nodeType === core.NodeType.Enumeration) {
502
- return /* @__PURE__ */ jsxRuntime.jsx(
503
- EnumerationTextEditor,
504
- {
505
- dictionary,
506
- keyPath,
507
- section
508
- }
509
- );
510
- }
511
- if (nodeType === core.NodeType.Condition) {
512
- return /* @__PURE__ */ jsxRuntime.jsx(
513
- ConditionTextEditor,
514
- {
515
- dictionary,
516
- keyPath,
517
- section
518
- }
519
- );
520
- }
521
- if (nodeType === core.NodeType.Markdown) {
522
- return /* @__PURE__ */ jsxRuntime.jsx(
523
- MarkdownTextEditor,
524
- {
525
- dictionary,
526
- keyPath,
527
- section,
528
- isDarkMode
529
- }
530
- );
531
- }
532
- if (nodeType === core.NodeType.Array) {
533
- return /* @__PURE__ */ jsxRuntime.jsx(
534
- ArrayTextEditor,
535
- {
536
- dictionary,
537
- keyPath,
538
- section
539
- }
540
- );
541
- }
481
+ if (nodeType === core.NodeType.ReactNode) {
482
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
483
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "[React Node]" }),
484
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
485
+ ] });
486
+ }
487
+ if (nodeType === core.NodeType.Nested) {
488
+ return /* @__PURE__ */ jsxRuntime.jsx(
489
+ NestedTextEditor,
490
+ {
491
+ dictionary,
492
+ keyPath,
493
+ section
494
+ }
495
+ );
496
+ }
497
+ if (nodeType === core.NodeType.Translation) {
498
+ return /* @__PURE__ */ jsxRuntime.jsx(
499
+ TranslationTextEditor,
500
+ {
501
+ dictionary,
502
+ keyPath,
503
+ section
504
+ }
505
+ );
506
+ }
507
+ if (nodeType === core.NodeType.Enumeration) {
508
+ return /* @__PURE__ */ jsxRuntime.jsx(
509
+ EnumerationTextEditor,
510
+ {
511
+ dictionary,
512
+ keyPath,
513
+ section
514
+ }
515
+ );
516
+ }
517
+ if (nodeType === core.NodeType.Condition) {
518
+ return /* @__PURE__ */ jsxRuntime.jsx(
519
+ ConditionTextEditor,
520
+ {
521
+ dictionary,
522
+ keyPath,
523
+ section
524
+ }
525
+ );
526
+ }
527
+ if (nodeType === core.NodeType.Markdown) {
528
+ return /* @__PURE__ */ jsxRuntime.jsx(
529
+ MarkdownTextEditor,
530
+ {
531
+ dictionary,
532
+ keyPath,
533
+ section,
534
+ isDarkMode
535
+ }
536
+ );
537
+ }
538
+ if (nodeType === core.NodeType.Array) {
539
+ return /* @__PURE__ */ jsxRuntime.jsx(
540
+ ArrayTextEditor,
541
+ {
542
+ dictionary,
543
+ keyPath,
544
+ section
545
+ }
546
+ );
547
+ }
548
+ if (nodeType === core.NodeType.Object) {
549
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
550
+ ObjectTextEditor,
551
+ {
552
+ dictionary,
553
+ keyPath,
554
+ section
555
+ }
556
+ ) });
542
557
  }
543
558
  if (nodeType === core.NodeType.Number) {
544
559
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -576,9 +591,23 @@ const TextEditor = ({
576
591
  }
577
592
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full p-2", children: [
578
593
  "Error. Format not supported.",
579
- JSON.stringify(section)
594
+ JSON.stringify(section, null, 2),
595
+ JSON.stringify(keyPath, null, 2),
596
+ "NodeType : ",
597
+ nodeType
580
598
  ] });
581
599
  };
600
+ const TextEditorContainer = (props) => /* @__PURE__ */ jsxRuntime.jsx(
601
+ components_Container_index.Container,
602
+ {
603
+ border: true,
604
+ background: "none",
605
+ className: "top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky",
606
+ roundedSize: "xl",
607
+ children: /* @__PURE__ */ jsxRuntime.jsx(TextEditor, { ...props })
608
+ }
609
+ );
582
610
  exports.TextEditor = TextEditor;
611
+ exports.TextEditorContainer = TextEditorContainer;
583
612
  exports.traceKeys = traceKeys;
584
613
  //# sourceMappingURL=TextEditor.cjs.map