@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.
- package/dist/.vite/manifest.json +12 -23
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
- package/dist/components/Container/index.cjs +5 -2
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +1 -1
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs +5 -2
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +27 -6
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +27 -6
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +278 -214
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +2 -0
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +281 -217
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts +5 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +5 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -13
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +19 -14
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +64 -0
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +64 -0
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +64 -0
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.cjs +6 -16
- package/dist/components/DictionaryFieldEditor/StructureEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureEditor.mjs +7 -17
- package/dist/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +8 -7
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +7 -0
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +11 -10
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +3 -2
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/components/MarkDownRender/index.cjs.map +1 -1
- package/dist/components/MarkDownRender/index.d.ts +1 -1
- package/dist/components/MarkDownRender/index.d.ts.map +1 -1
- package/dist/components/MarkDownRender/index.mjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.cjs +1 -1
- package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
- package/dist/components/MaxHeightSmoother/index.mjs +1 -1
- package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.cjs +1 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/index-BCuMWKyy.js.map +1 -1
- package/dist/{index-BKE0uywA.js → index-BTDHuTxL.js} +2 -2
- package/dist/index-BTDHuTxL.js.map +1 -0
- package/dist/index-BYzBot7l.cjs.map +1 -1
- package/dist/{index-CsenS2hX.cjs → index-Db5Dym4h.cjs} +2 -2
- package/dist/index-Db5Dym4h.cjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/dist/zod-BV4nCGJE.js.map +1 -1
- package/dist/zod-DSrtTSD_.cjs.map +1 -1
- package/package.json +19 -19
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs +0 -44
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs.map +0 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts +0 -9
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts.map +0 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs +0 -44
- package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs.map +0 -1
- package/dist/index-BKE0uywA.js.map +0 -1
- package/dist/index-CsenS2hX.cjs.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx,
|
|
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 {
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
|
|
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:
|
|
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
|
-
] }
|
|
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(
|
|
153
|
-
|
|
154
|
-
|
|
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) =>
|
|
157
|
-
|
|
158
|
-
|
|
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:
|
|
170
|
+
label: removeEnumeration.label.value,
|
|
162
171
|
variant: "hoverable",
|
|
163
|
-
size: "icon-md",
|
|
164
172
|
color: "text",
|
|
165
|
-
Icon:
|
|
166
|
-
className: "
|
|
167
|
-
onClick: () => addEditedContent(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
/* @__PURE__ */ jsx("
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
242
|
-
|
|
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
|
-
|
|
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("
|
|
319
|
-
/* @__PURE__ */ jsx("tbody", { className: "
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
|
|
322
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
-
|
|
365
|
-
|
|
375
|
+
const [mode, setMode] = useState(
|
|
376
|
+
0
|
|
377
|
+
/* Edit */
|
|
378
|
+
);
|
|
379
|
+
const toggleContent2 = [
|
|
366
380
|
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
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
|