@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
@@ -5,28 +5,28 @@ const jsxRuntime = require("react/jsx-runtime");
5
5
  const core = require("@intlayer/core");
6
6
  const editorReact = require("@intlayer/editor-react");
7
7
  const lucideReact = require("lucide-react");
8
+ const ReactExports = require("react");
8
9
  const reactIntlayer = require("react-intlayer");
9
- require("react");
10
10
  require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
11
11
  require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
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");
25
25
  const components_SwitchSelector_index = require("../../SwitchSelector/index.cjs");
26
26
  require("../../LocaleSwitcherContentDropDown/localeSwitcher.content.cjs");
27
27
  const components_LocaleSwitcherContentDropDown_LocaleSwitcherContentContext = require("../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs");
28
+ const components_MarkDownRender_index = require("../../MarkDownRender/index.cjs");
28
29
  const components_DictionaryFieldEditor_EnumKeyInput = require("../EnumKeyInput.cjs");
29
- const components_DictionaryFieldEditor_getIsEditableSection = require("../getIsEditableSection.cjs");
30
30
  const components_DictionaryFieldEditor_NavigationView_navigationViewNode_content = require("../NavigationView/navigationViewNode.content.cjs");
31
31
  const traceKeys = ["filePath", "id", "nodeType"];
32
32
  const ContentEditorTextArea = ({
@@ -121,7 +121,7 @@ const TranslationTextEditor = ({
121
121
  keyPath,
122
122
  dictionary
123
123
  }) => {
124
- const { locale } = reactIntlayer.useLocale();
124
+ const { locale, defaultLocale } = reactIntlayer.useLocale();
125
125
  const { selectedLocales, availableLocales } = components_LocaleSwitcherContentDropDown_LocaleSwitcherContentContext.useLocaleSwitcherContent();
126
126
  const sectionContent = section[core.NodeType.Translation];
127
127
  const sectionContentKeys = Object.keys(sectionContent);
@@ -130,20 +130,21 @@ const TranslationTextEditor = ({
130
130
  // If the translation include content in other locales, we display all of them
131
131
  [.../* @__PURE__ */ new Set([...availableLocales, ...sectionContentKeys])]
132
132
  );
133
- 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: [
134
- selectedLocales.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-full p-2 text-xs", children: core.getLocaleName(translationKey, locale) }),
135
- /* @__PURE__ */ jsxRuntime.jsx(
136
- 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,
137
138
  {
138
- section: section[core.NodeType.Translation][translationKey],
139
+ section: content[translationKey] ?? core.getEmptyNode(content[defaultLocale]),
139
140
  keyPath: [
140
141
  ...keyPath,
141
142
  { type: core.NodeType.Translation, key: translationKey }
142
143
  ],
143
144
  dictionary
144
145
  }
145
- )
146
- ] }) }, translationKey)) }) });
146
+ ) })
147
+ ] }, translationKey)) }) });
147
148
  };
148
149
  const EnumerationTextEditor = ({
149
150
  section,
@@ -151,31 +152,37 @@ const EnumerationTextEditor = ({
151
152
  dictionary
152
153
  }) => {
153
154
  const { addEditedContent } = editorReact.useEditedContent();
154
- const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
155
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed gap-2", children: [
156
- /* @__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(
157
162
  section[core.NodeType.Enumeration]
158
- ).map((enumKey) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
159
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
160
- /* @__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(
161
170
  components_Button_Button.Button,
162
171
  {
163
- label: "Remove",
172
+ label: removeEnumeration.label.value,
164
173
  variant: "hoverable",
165
- size: "icon-md",
166
174
  color: "text",
167
- Icon: lucideReact.X,
168
- className: "w-16",
169
- onClick: () => addEditedContent(dictionary.key, void 0, [
170
- ...keyPath,
171
- {
172
- type: core.NodeType.Enumeration,
173
- key: enumKey
174
- }
175
- ])
175
+ Icon: lucideReact.Trash,
176
+ className: "ml-auto",
177
+ onClick: () => addEditedContent(
178
+ dictionary.key,
179
+ void 0,
180
+ childrenKeyPath
181
+ ),
182
+ children: removeEnumeration.text
176
183
  }
177
- ),
178
- /* @__PURE__ */ jsxRuntime.jsx(
184
+ ) }) }),
185
+ /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
179
186
  components_DictionaryFieldEditor_EnumKeyInput.EnumKeyInput,
180
187
  {
181
188
  value: enumKey,
@@ -193,38 +200,35 @@ const EnumerationTextEditor = ({
193
200
  addEditedContent(dictionary.key, newValue, keyPath);
194
201
  }
195
202
  }
196
- )
197
- ] }) }),
198
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
199
- TextEditor,
200
- {
201
- section: section[core.NodeType.Enumeration][enumKey],
202
- keyPath: [
203
- ...keyPath,
204
- { type: core.NodeType.Enumeration, key: enumKey }
205
- ],
206
- dictionary
207
- }
208
- ) })
209
- ] }, enumKey)) }),
210
- /* @__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(
211
215
  components_Button_Button.Button,
212
216
  {
213
217
  label: addNewEnumeration.label.value,
214
218
  variant: "hoverable",
215
219
  color: "neutral",
216
220
  textAlign: "left",
221
+ isFullWidth: true,
217
222
  onClick: () => addEditedContent(
218
223
  dictionary.key,
219
- "",
220
- [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }],
221
- false
224
+ core.getEmptyNode(content[firstKey]) ?? "",
225
+ [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }]
222
226
  ),
223
227
  Icon: lucideReact.Plus,
224
228
  className: "m-2",
225
229
  children: addNewEnumeration.text
226
230
  }
227
- ) })
231
+ )
228
232
  ] });
229
233
  };
230
234
  const ConditionTextEditor = ({
@@ -232,83 +236,24 @@ const ConditionTextEditor = ({
232
236
  keyPath,
233
237
  dictionary
234
238
  }) => {
235
- const { addEditedContent } = editorReact.useEditedContent();
236
- const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
237
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed gap-2", children: [
238
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
239
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
240
- /* @__PURE__ */ jsxRuntime.jsx(
241
- 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,
242
248
  {
243
- label: "Remove",
244
- variant: "hoverable",
245
- size: "icon-md",
246
- color: "text",
247
- Icon: lucideReact.X,
248
- className: "w-16",
249
- onClick: () => addEditedContent(dictionary.key, void 0, [
250
- ...keyPath,
251
- {
252
- type: core.NodeType.Condition,
253
- key: condKey
254
- }
255
- ])
249
+ type: core.NodeType.Condition,
250
+ key: condKey
256
251
  }
257
- ),
258
- /* @__PURE__ */ jsxRuntime.jsx(
259
- components_DictionaryFieldEditor_EnumKeyInput.EnumKeyInput,
260
- {
261
- value: condKey,
262
- onChange: (value) => {
263
- const preValueContent = section[core.NodeType.Condition];
264
- const newValueContent = utils_object.renameKey(
265
- preValueContent,
266
- condKey,
267
- value
268
- );
269
- const newValue = {
270
- ...section,
271
- [core.NodeType.Condition]: newValueContent
272
- };
273
- addEditedContent(dictionary.key, newValue, keyPath);
274
- }
275
- }
276
- )
277
- ] }) }),
278
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
279
- TextEditor,
280
- {
281
- section: section[core.NodeType.Enumeration][condKey],
282
- keyPath: [
283
- ...keyPath,
284
- {
285
- type: core.NodeType.Array,
286
- key: parseInt(condKey)
287
- }
288
- ],
289
- dictionary
290
- }
291
- ) })
292
- ] }, condKey)) }),
293
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsx(
294
- components_Button_Button.Button,
295
- {
296
- label: addNewEnumeration.label.value,
297
- variant: "hoverable",
298
- color: "neutral",
299
- textAlign: "left",
300
- onClick: () => addEditedContent(
301
- dictionary.key,
302
- "",
303
- [...keyPath, { type: core.NodeType.Enumeration, key: "unknown" }],
304
- false
305
- ),
306
- Icon: lucideReact.Plus,
307
- className: "m-2",
308
- children: addNewEnumeration.text
252
+ ],
253
+ dictionary
309
254
  }
310
- ) })
311
- ] });
255
+ ) }, condKey)
256
+ ] }, condKey)) }) });
312
257
  };
313
258
  const ArrayTextEditor = ({
314
259
  section,
@@ -316,14 +261,38 @@ const ArrayTextEditor = ({
316
261
  dictionary
317
262
  }) => {
318
263
  const { addEditedContent } = editorReact.useEditedContent();
319
- const { addNewElement } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
320
- return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full gap-2", children: [
321
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "w-full", children: [
322
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-2", children: index }),
323
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
324
- 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,
325
294
  {
326
- section: subSection,
295
+ section: subSection ?? core.getEmptyNode(section[0]),
327
296
  keyPath: [
328
297
  ...keyPath,
329
298
  {
@@ -334,14 +303,15 @@ const ArrayTextEditor = ({
334
303
  dictionary
335
304
  }
336
305
  ) })
337
- ] }, JSON.stringify(subSection))) }),
338
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsx(
306
+ ] }, JSON.stringify(subSection))) }) }),
307
+ /* @__PURE__ */ jsxRuntime.jsx(
339
308
  components_Button_Button.Button,
340
309
  {
341
310
  label: addNewElement.label.value,
342
311
  variant: "hoverable",
343
312
  color: "neutral",
344
313
  textAlign: "left",
314
+ isFullWidth: true,
345
315
  onClick: () => {
346
316
  const newKeyPath = [
347
317
  ...keyPath,
@@ -350,29 +320,101 @@ const ArrayTextEditor = ({
350
320
  key: section.length
351
321
  }
352
322
  ];
353
- addEditedContent(dictionary.key, "", newKeyPath, false);
323
+ addEditedContent(
324
+ dictionary.key,
325
+ core.getEmptyNode(section[0]) ?? "",
326
+ newKeyPath,
327
+ false
328
+ );
354
329
  },
355
330
  Icon: lucideReact.Plus,
356
331
  children: addNewElement.text
357
332
  }
358
- ) })
333
+ )
359
334
  ] });
360
335
  };
361
- const MarkdownTextEditor = ({
336
+ const ObjectTextEditor = ({
362
337
  section,
363
338
  keyPath,
364
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
+ ) }) }) });
371
+ const MarkdownTextEditor = ({
372
+ section,
373
+ keyPath,
374
+ dictionary,
375
+ isDarkMode
365
376
  }) => {
366
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
367
- ContentEditorTextArea,
377
+ const [mode, setMode] = ReactExports.useState(
378
+ 0
379
+ /* Edit */
380
+ );
381
+ const toggleContent2 = [
368
382
  {
369
- variant: "default",
370
- "aria-label": "Edit field",
371
- keyPath: [...keyPath, { type: core.NodeType.Markdown }],
372
- dictionary,
373
- children: section[core.NodeType.Markdown]
383
+ content: "Edit",
384
+ value: 0
385
+ /* Edit */
386
+ },
387
+ {
388
+ content: "Preview",
389
+ value: 1
390
+ /* Preview */
374
391
  }
375
- ) });
392
+ ];
393
+ const content = section[core.NodeType.Markdown];
394
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col justify-center gap-6 p-2", children: [
395
+ /* @__PURE__ */ jsxRuntime.jsx(
396
+ components_SwitchSelector_index.SwitchSelector,
397
+ {
398
+ choices: toggleContent2,
399
+ value: mode,
400
+ onChange: setMode,
401
+ color: "text",
402
+ size: "sm",
403
+ className: "ml-auto"
404
+ }
405
+ ),
406
+ mode === 0 && /* @__PURE__ */ jsxRuntime.jsx(
407
+ ContentEditorTextArea,
408
+ {
409
+ variant: "default",
410
+ "aria-label": "Edit field",
411
+ keyPath: [...keyPath, { type: core.NodeType.Markdown }],
412
+ dictionary,
413
+ children: content
414
+ }
415
+ ),
416
+ mode === 1 && /* @__PURE__ */ jsxRuntime.jsx(components_MarkDownRender_index.MarkdownRenderer, { isDarkMode, children: content })
417
+ ] });
376
418
  };
377
419
  const NestedTextEditor = ({
378
420
  keyPath,
@@ -431,79 +473,87 @@ const NestedTextEditor = ({
431
473
  const TextEditor = ({
432
474
  section,
433
475
  keyPath,
434
- dictionary
476
+ dictionary,
477
+ isDarkMode
435
478
  }) => {
436
479
  const { tsxNotEditable } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
437
480
  const nodeType = core.getNodeType(section);
438
- const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
439
- if (!isEditableSection) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
440
- if (typeof section === "object") {
441
- if (nodeType === core.NodeType.ReactNode) {
442
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
443
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "[React Node]" }),
444
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
445
- ] });
446
- }
447
- if (nodeType === core.NodeType.Nested) {
448
- return /* @__PURE__ */ jsxRuntime.jsx(
449
- NestedTextEditor,
450
- {
451
- dictionary,
452
- keyPath,
453
- section
454
- }
455
- );
456
- }
457
- if (nodeType === core.NodeType.Translation) {
458
- return /* @__PURE__ */ jsxRuntime.jsx(
459
- TranslationTextEditor,
460
- {
461
- dictionary,
462
- keyPath,
463
- section
464
- }
465
- );
466
- }
467
- if (nodeType === core.NodeType.Enumeration) {
468
- return /* @__PURE__ */ jsxRuntime.jsx(
469
- EnumerationTextEditor,
470
- {
471
- dictionary,
472
- keyPath,
473
- section
474
- }
475
- );
476
- }
477
- if (nodeType === core.NodeType.Condition) {
478
- return /* @__PURE__ */ jsxRuntime.jsx(
479
- ConditionTextEditor,
480
- {
481
- dictionary,
482
- keyPath,
483
- section
484
- }
485
- );
486
- }
487
- if (nodeType === core.NodeType.Markdown) {
488
- return /* @__PURE__ */ jsxRuntime.jsx(
489
- MarkdownTextEditor,
490
- {
491
- dictionary,
492
- keyPath,
493
- section
494
- }
495
- );
496
- }
497
- if (nodeType === core.NodeType.Array) {
498
- return /* @__PURE__ */ jsxRuntime.jsx(
499
- ArrayTextEditor,
500
- {
501
- dictionary,
502
- keyPath,
503
- section
504
- }
505
- );
506
- }
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
+ ) });
507
557
  }
508
558
  if (nodeType === core.NodeType.Number) {
509
559
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -541,9 +591,23 @@ const TextEditor = ({
541
591
  }
542
592
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full p-2", children: [
543
593
  "Error. Format not supported.",
544
- JSON.stringify(section)
594
+ JSON.stringify(section, null, 2),
595
+ JSON.stringify(keyPath, null, 2),
596
+ "NodeType : ",
597
+ nodeType
545
598
  ] });
546
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
+ );
547
610
  exports.TextEditor = TextEditor;
611
+ exports.TextEditorContainer = TextEditorContainer;
548
612
  exports.traceKeys = traceKeys;
549
613
  //# sourceMappingURL=TextEditor.cjs.map