@firecms/core 3.1.0-canary.9e89e98 → 3.1.0-canary.dc8ac43
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/components/EntityCollectionTable/internal/popup_field/useDraggable.d.ts +2 -2
- package/dist/components/EntityCollectionView/CollectionDataErrorBanner.d.ts +4 -0
- package/dist/components/ErrorBoundary.d.ts +4 -2
- package/dist/components/HomePage/DefaultHomePage.d.ts +0 -1
- package/dist/components/LanguageToggle.d.ts +1 -0
- package/dist/components/UnsavedChangesDialog.d.ts +1 -0
- package/dist/components/VirtualTable/VirtualTableHeader.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/core/DrawerNavigationGroup.d.ts +2 -2
- package/dist/editor/components/SlashCommandMenu.d.ts +6 -0
- package/dist/editor/components/editor-bubble-item.d.ts +8 -0
- package/dist/editor/components/editor-bubble.d.ts +8 -0
- package/dist/editor/components/image-bubble.d.ts +5 -0
- package/dist/editor/components/index.d.ts +16 -0
- package/dist/editor/components/table-bubble.d.ts +5 -0
- package/dist/editor/editor.d.ts +30 -0
- package/dist/editor/extensions/HighlightDecorationExtension.d.ts +24 -0
- package/dist/editor/extensions/Image/index.d.ts +6 -0
- package/dist/editor/extensions/Image.d.ts +6 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.d.ts +16 -0
- package/dist/editor/extensions/clipboard.d.ts +7 -0
- package/dist/editor/extensions/custom-keymap.d.ts +1 -0
- package/dist/editor/extensions/drag-and-drop.d.ts +9 -0
- package/dist/editor/hooks/useProseMirror.d.ts +13 -0
- package/dist/editor/hooks/useProseMirrorContext.d.ts +9 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/markdown.d.ts +5 -0
- package/dist/editor/nodeViews/ImageComponent.d.ts +3 -0
- package/dist/editor/nodeViews/ReactNodeView.d.ts +29 -0
- package/dist/editor/nodeViews/TaskItemComponent.d.ts +3 -0
- package/dist/editor/nodeViews/index.d.ts +6 -0
- package/dist/editor/plugins/index.d.ts +2 -0
- package/dist/editor/plugins/inputrules.d.ts +6 -0
- package/dist/editor/plugins/placeholderPlugin.d.ts +3 -0
- package/dist/editor/plugins/slashCommandPlugin.d.ts +12 -0
- package/dist/editor/schema.d.ts +2 -0
- package/dist/editor/selectors/ai-selector.d.ts +0 -0
- package/dist/editor/selectors/color-selector.d.ts +10 -0
- package/dist/editor/selectors/link-selector.d.ts +8 -0
- package/dist/editor/selectors/node-selector.d.ts +15 -0
- package/dist/editor/selectors/text-buttons.d.ts +1 -0
- package/dist/editor/types.d.ts +5 -0
- package/dist/editor/useProseMirror.d.ts +16 -0
- package/dist/editor/utils/prosemirror-utils.d.ts +6 -0
- package/dist/editor/utils/remove_classes.d.ts +1 -0
- package/dist/editor/utils/useDebouncedCallback.d.ts +1 -0
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +0 -1
- package/dist/hooks/useCollapsedGroups.d.ts +3 -3
- package/dist/hooks/useTranslation.d.ts +17 -0
- package/dist/i18n/FireCMSi18nProvider.d.ts +33 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +13009 -2312
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +12997 -2320
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useRestoreScroll.d.ts +1 -1
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/en.d.ts +10 -0
- package/dist/locales/es.d.ts +10 -0
- package/dist/locales/fr.d.ts +2 -0
- package/dist/locales/hi.d.ts +2 -0
- package/dist/locales/it.d.ts +2 -0
- package/dist/locales/pt.d.ts +7 -0
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/customization_controller.d.ts +2 -1
- package/dist/types/firecms.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +23 -0
- package/dist/types/storage.d.ts +1 -0
- package/dist/types/translations.d.ts +646 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/resolutions.d.ts +2 -2
- package/dist/util/useStorageUploadController.d.ts +10 -1
- package/package.json +49 -13
- package/src/app/Scaffold.tsx +7 -5
- package/src/components/AIIcon.tsx +3 -1
- package/src/components/ArrayContainer.tsx +6 -4
- package/src/components/ClearFilterSortButton.tsx +6 -3
- package/src/components/ConfirmationDialog.tsx +4 -2
- package/src/components/DeleteEntityDialog.tsx +10 -7
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +6 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -1
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -2
- package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +11 -11
- package/src/components/EntityCollectionView/BoardSortableList.tsx +3 -1
- package/src/components/EntityCollectionView/CollectionDataErrorBanner.tsx +43 -0
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +1 -1
- package/src/components/EntityCollectionView/EntityCard.tsx +4 -0
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +39 -46
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +17 -25
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +54 -17
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -3
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +4 -2
- package/src/components/EntityCollectionView/FiltersDialog.tsx +8 -5
- package/src/components/EntityCollectionView/ViewModeToggle.tsx +11 -8
- package/src/components/EntityView.tsx +3 -2
- package/src/components/ErrorBoundary.tsx +27 -15
- package/src/components/HomePage/DefaultHomePage.tsx +19 -13
- package/src/components/HomePage/HomePageDnD.tsx +3 -1
- package/src/components/HomePage/NavigationGroup.tsx +3 -1
- package/src/components/HomePage/RenameGroupDialog.tsx +15 -13
- package/src/components/LanguageToggle.tsx +66 -0
- package/src/components/NotFoundPage.tsx +5 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +9 -7
- package/src/components/ReferenceWidget.tsx +3 -2
- package/src/components/SearchIconsView.tsx +3 -1
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +11 -0
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +15 -2
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +11 -0
- package/src/components/UnsavedChangesDialog.tsx +6 -4
- package/src/components/VirtualTable/VirtualTable.performance.test.tsx +1 -0
- package/src/components/VirtualTable/VirtualTable.tsx +116 -113
- package/src/components/VirtualTable/VirtualTableHeader.tsx +54 -52
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +3 -3
- package/src/components/common/default_entity_actions.tsx +4 -0
- package/src/components/common/useDataSourceTableController.tsx +12 -4
- package/src/components/index.tsx +1 -0
- package/src/core/DefaultAppBar.tsx +15 -11
- package/src/core/DefaultDrawer.tsx +8 -2
- package/src/core/DrawerNavigationGroup.tsx +5 -3
- package/src/core/EntityEditView.tsx +4 -3
- package/src/core/EntityEditViewFormActions.tsx +24 -17
- package/src/core/EntitySidePanel.tsx +32 -29
- package/src/core/FireCMS.tsx +33 -6
- package/src/core/field_configs.tsx +14 -9
- package/src/editor/components/SlashCommandMenu.tsx +516 -0
- package/src/editor/components/editor-bubble-item.tsx +32 -0
- package/src/editor/components/editor-bubble.tsx +118 -0
- package/src/editor/components/image-bubble.tsx +156 -0
- package/src/editor/components/index.ts +14 -0
- package/src/editor/components/table-bubble.tsx +165 -0
- package/src/editor/editor.tsx +455 -0
- package/src/editor/extensions/HighlightDecorationExtension.ts +114 -0
- package/src/editor/extensions/Image/index.ts +133 -0
- package/src/editor/extensions/Image.ts +159 -0
- package/src/editor/extensions/TextLoadingDecorationExtension.tsx +107 -0
- package/src/editor/extensions/clipboard.ts +72 -0
- package/src/editor/extensions/custom-keymap.ts +24 -0
- package/src/editor/extensions/drag-and-drop.tsx +480 -0
- package/src/editor/hooks/useProseMirror.ts +124 -0
- package/src/editor/hooks/useProseMirrorContext.ts +15 -0
- package/src/editor/index.ts +2 -0
- package/src/editor/markdown.ts +172 -0
- package/src/editor/nodeViews/ImageComponent.tsx +20 -0
- package/src/editor/nodeViews/ReactNodeView.tsx +89 -0
- package/src/editor/nodeViews/TaskItemComponent.tsx +29 -0
- package/src/editor/nodeViews/index.ts +35 -0
- package/src/editor/plugins/index.ts +58 -0
- package/src/editor/plugins/inputrules.ts +82 -0
- package/src/editor/plugins/placeholderPlugin.ts +55 -0
- package/src/editor/plugins/slashCommandPlugin.ts +61 -0
- package/src/editor/schema.ts +240 -0
- package/src/editor/selectors/ai-selector.tsx +111 -0
- package/src/editor/selectors/color-selector.tsx +200 -0
- package/src/editor/selectors/link-selector.tsx +118 -0
- package/src/editor/selectors/node-selector.tsx +157 -0
- package/src/editor/selectors/text-buttons.tsx +86 -0
- package/src/editor/types.ts +6 -0
- package/src/editor/useProseMirror.ts +126 -0
- package/src/editor/utils/prosemirror-utils.ts +108 -0
- package/src/editor/utils/remove_classes.ts +17 -0
- package/src/editor/utils/useDebouncedCallback.ts +25 -0
- package/src/form/EntityForm.tsx +85 -63
- package/src/form/EntityFormActions.tsx +19 -12
- package/src/form/PropertyFieldBinding.tsx +6 -5
- package/src/form/components/ErrorFocus.tsx +3 -3
- package/src/form/components/LocalChangesMenu.tsx +13 -13
- package/src/form/components/StorageItemPreview.tsx +3 -2
- package/src/form/components/StorageUploadProgress.tsx +18 -3
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -4
- package/src/form/field_bindings/BlockFieldBinding.tsx +5 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +23 -18
- package/src/form/field_bindings/MapFieldBinding.tsx +4 -3
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +34 -20
- package/src/form/field_bindings/RepeatFieldBinding.tsx +3 -1
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +87 -86
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useBuildNavigationController.tsx +49 -22
- package/src/hooks/useCollapsedGroups.ts +7 -6
- package/src/hooks/useTranslation.ts +31 -0
- package/src/hooks/useValidateAuthenticator.tsx +1 -1
- package/src/i18n/FireCMSi18nProvider.tsx +160 -0
- package/src/index.ts +4 -0
- package/src/internal/useBuildDataSource.ts +1 -2
- package/src/internal/useBuildSideEntityController.tsx +22 -20
- package/src/locales/de.ts +691 -0
- package/src/locales/en.ts +703 -0
- package/src/locales/es.ts +703 -0
- package/src/locales/fr.ts +691 -0
- package/src/locales/hi.ts +691 -0
- package/src/locales/it.ts +691 -0
- package/src/locales/pt.ts +700 -0
- package/src/preview/PropertyPreview.tsx +1 -0
- package/src/preview/components/UrlComponentPreview.tsx +4 -2
- package/src/preview/components/UserPreview.tsx +3 -1
- package/src/types/analytics.ts +10 -0
- package/src/types/customization_controller.tsx +2 -1
- package/src/types/firecms.tsx +2 -1
- package/src/types/index.ts +1 -0
- package/src/types/navigation.ts +2 -2
- package/src/types/plugins.tsx +26 -0
- package/src/types/properties.ts +1 -0
- package/src/types/storage.ts +2 -1
- package/src/types/translations.ts +725 -0
- package/src/util/entities.ts +1 -1
- package/src/util/join_collections.ts +10 -8
- package/src/util/previews.ts +2 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/resolutions.ts +5 -3
- package/src/util/useStorageUploadController.tsx +23 -29
|
@@ -11,6 +11,7 @@ import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
|
11
11
|
import { cls, ExpandablePanel, paperMixin, Select, SelectItem, Typography } from "@firecms/ui";
|
|
12
12
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
13
13
|
import { ArrayContainer, ArrayEntryParams } from "../../components";
|
|
14
|
+
import { useTranslation } from "../../hooks/useTranslation";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* If the `oneOf` property is specified, this fields render each array entry as
|
|
@@ -37,6 +38,7 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
37
38
|
}: FieldProps<T>) {
|
|
38
39
|
|
|
39
40
|
const minimalistView = minimalistViewProp || property.minimalistView;
|
|
41
|
+
const { t } = useTranslation();
|
|
40
42
|
|
|
41
43
|
if (!property.oneOf)
|
|
42
44
|
throw Error("ArrayOneOfField misconfiguration. Property `oneOf` not set");
|
|
@@ -84,7 +86,7 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
84
86
|
const body = <ArrayContainer value={value}
|
|
85
87
|
className={"flex flex-col gap-3"}
|
|
86
88
|
droppableId={propertyKey}
|
|
87
|
-
addLabel={property.name ? "
|
|
89
|
+
addLabel={property.name ? t("add_to_field", { fieldName: property.name }) : t("add_entry")}
|
|
88
90
|
buildEntry={buildEntry}
|
|
89
91
|
onInternalIdAdded={setLastAddedId}
|
|
90
92
|
disabled={isSubmitting || Boolean(property.disabled)}
|
|
@@ -167,6 +169,7 @@ function BlockEntry({
|
|
|
167
169
|
const [typeInternal, setTypeInternal] = useState<string | undefined>(type ?? undefined);
|
|
168
170
|
|
|
169
171
|
const formex = useFormex();
|
|
172
|
+
const { t } = useTranslation();
|
|
170
173
|
|
|
171
174
|
useEffect(() => {
|
|
172
175
|
if (!type) {
|
|
@@ -227,7 +230,7 @@ function BlockEntry({
|
|
|
227
230
|
<Select
|
|
228
231
|
className="mb-2"
|
|
229
232
|
placeholder={<Typography variant={"caption"}
|
|
230
|
-
className={"px-4 py-2 font-medium"}>
|
|
233
|
+
className={"px-4 py-2 font-medium"}>{t("type")}</Typography>}
|
|
231
234
|
size={"medium"}
|
|
232
235
|
fullWidth={true}
|
|
233
236
|
position={"item-aligned"}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import { getDefaultValueForDataType, getIconForProperty } from "../../util";
|
|
23
23
|
import { useCustomizationController } from "../../hooks";
|
|
24
24
|
import { getIn } from "@firecms/formex";
|
|
25
|
+
import { useTranslation } from "../../hooks/useTranslation";
|
|
25
26
|
|
|
26
27
|
type MapEditViewRowState = [number, {
|
|
27
28
|
key: string,
|
|
@@ -54,6 +55,7 @@ export function KeyValueFieldBinding({
|
|
|
54
55
|
throw Error(`Your property ${propertyKey} needs to have the 'keyValue' prop in order to use this field binding`);
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
const { t } = useTranslation();
|
|
57
59
|
const initialValues = getIn(context.formex.initialValues, propertyKey);
|
|
58
60
|
|
|
59
61
|
const mapFormView = <MapEditView value={value}
|
|
@@ -103,6 +105,7 @@ function MapEditView<T extends Record<string, any>>({
|
|
|
103
105
|
fieldName,
|
|
104
106
|
disabled
|
|
105
107
|
}: MapEditViewParams<T>) {
|
|
108
|
+
const { t } = useTranslation();
|
|
106
109
|
const [internalState, setInternalState] = React.useState<MapEditViewRowState[]>(
|
|
107
110
|
Object.keys(initialValue ?? {}).map((key) => [getRandomId(), {
|
|
108
111
|
key,
|
|
@@ -230,7 +233,7 @@ function MapEditView<T extends Record<string, any>>({
|
|
|
230
233
|
}]]);
|
|
231
234
|
}
|
|
232
235
|
}>
|
|
233
|
-
{fieldName ?
|
|
236
|
+
{fieldName ? t("add_to_field", { fieldName }) : t("add_entry")}
|
|
234
237
|
</Button>
|
|
235
238
|
|
|
236
239
|
</div>;
|
|
@@ -261,12 +264,13 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
261
264
|
}) {
|
|
262
265
|
|
|
263
266
|
const { locale } = useCustomizationController();
|
|
267
|
+
const { t } = useTranslation();
|
|
264
268
|
|
|
265
269
|
function buildInput(entryValue: any, fieldKey: string, dataType: DataType) {
|
|
266
270
|
if (dataType === "string" || dataType === "number") {
|
|
267
271
|
return <TextField
|
|
268
272
|
key={dataType}
|
|
269
|
-
placeholder={"value"}
|
|
273
|
+
placeholder={t("value")}
|
|
270
274
|
value={entryValue}
|
|
271
275
|
type={dataType === "number" ? "number" : "text"}
|
|
272
276
|
size={"medium"}
|
|
@@ -325,7 +329,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
325
329
|
<ArrayContainer value={entryValue}
|
|
326
330
|
newDefaultEntry={""}
|
|
327
331
|
droppableId={rowId.toString()}
|
|
328
|
-
addLabel={fieldKey ?
|
|
332
|
+
addLabel={fieldKey ? t("add_to_field", { fieldName: fieldKey }) : t("add_entry")}
|
|
329
333
|
size={"small"}
|
|
330
334
|
disabled={disabled || !fieldKey}
|
|
331
335
|
canAddElements={true}
|
|
@@ -370,7 +374,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
370
374
|
} else {
|
|
371
375
|
return <Typography
|
|
372
376
|
variant={"caption"}>
|
|
373
|
-
{
|
|
377
|
+
{t("data_type_not_supported", { dataType })}
|
|
374
378
|
</Typography>;
|
|
375
379
|
}
|
|
376
380
|
}
|
|
@@ -386,7 +390,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
386
390
|
<div className="w-[300px] max-w-[30%]">
|
|
387
391
|
<TextField
|
|
388
392
|
value={fieldKey}
|
|
389
|
-
placeholder={"key"}
|
|
393
|
+
placeholder={t("key")}
|
|
390
394
|
disabled={disabled || (entryValue !== undefined && entryValue !== null && entryValue !== "")}
|
|
391
395
|
size={"medium"}
|
|
392
396
|
onChange={(event) => {
|
|
@@ -404,17 +408,17 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
404
408
|
</IconButton>}
|
|
405
409
|
>
|
|
406
410
|
<MenuItem dense
|
|
407
|
-
onClick={() => doUpdateDataType("string")}>string</MenuItem>
|
|
411
|
+
onClick={() => doUpdateDataType("string")}>{t("string")}</MenuItem>
|
|
408
412
|
<MenuItem dense
|
|
409
|
-
onClick={() => doUpdateDataType("number")}>number</MenuItem>
|
|
413
|
+
onClick={() => doUpdateDataType("number")}>{t("number")}</MenuItem>
|
|
410
414
|
<MenuItem dense
|
|
411
|
-
onClick={() => doUpdateDataType("boolean")}>boolean</MenuItem>
|
|
415
|
+
onClick={() => doUpdateDataType("boolean")}>{t("boolean")}</MenuItem>
|
|
412
416
|
<MenuItem dense
|
|
413
|
-
onClick={() => doUpdateDataType("date")}>date</MenuItem>
|
|
417
|
+
onClick={() => doUpdateDataType("date")}>{t("date")}</MenuItem>
|
|
414
418
|
<MenuItem dense
|
|
415
|
-
onClick={() => doUpdateDataType("map")}>map</MenuItem>
|
|
419
|
+
onClick={() => doUpdateDataType("map")}>{t("map")}</MenuItem>
|
|
416
420
|
<MenuItem dense
|
|
417
|
-
onClick={() => doUpdateDataType("array")}>array</MenuItem>
|
|
421
|
+
onClick={() => doUpdateDataType("array")}>{t("array")}</MenuItem>
|
|
418
422
|
</Menu>
|
|
419
423
|
|
|
420
424
|
<IconButton aria-label="delete"
|
|
@@ -446,6 +450,7 @@ function ArrayKeyValueRow<T>({
|
|
|
446
450
|
}) {
|
|
447
451
|
|
|
448
452
|
const { locale } = useCustomizationController();
|
|
453
|
+
const { t } = useTranslation();
|
|
449
454
|
const [selectedDataType, setSelectedDataType] = useState<DataType>(getDataType(value) ?? "string");
|
|
450
455
|
|
|
451
456
|
function doUpdateDataType(dataType: DataType) {
|
|
@@ -487,7 +492,7 @@ function ArrayKeyValueRow<T>({
|
|
|
487
492
|
}}/>;
|
|
488
493
|
} else if (dataType === "array") {
|
|
489
494
|
return <Typography variant={"caption"}>
|
|
490
|
-
|
|
495
|
+
{t("arrays_of_arrays_not_supported")}
|
|
491
496
|
</Typography>;
|
|
492
497
|
} else if (dataType === "map") {
|
|
493
498
|
return <div className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
@@ -499,7 +504,7 @@ function ArrayKeyValueRow<T>({
|
|
|
499
504
|
} else {
|
|
500
505
|
return <Typography
|
|
501
506
|
variant={"caption"}>
|
|
502
|
-
{
|
|
507
|
+
{t("data_type_not_supported", { dataType })}
|
|
503
508
|
</Typography>;
|
|
504
509
|
}
|
|
505
510
|
}
|
|
@@ -519,15 +524,15 @@ function ArrayKeyValueRow<T>({
|
|
|
519
524
|
<ArrowDropDownIcon/>
|
|
520
525
|
</IconButton>}>
|
|
521
526
|
<MenuItem dense
|
|
522
|
-
onClick={() => doUpdateDataType("string")}>string</MenuItem>
|
|
527
|
+
onClick={() => doUpdateDataType("string")}>{t("string")}</MenuItem>
|
|
523
528
|
<MenuItem dense
|
|
524
|
-
onClick={() => doUpdateDataType("number")}>number</MenuItem>
|
|
529
|
+
onClick={() => doUpdateDataType("number")}>{t("number")}</MenuItem>
|
|
525
530
|
<MenuItem dense
|
|
526
|
-
onClick={() => doUpdateDataType("boolean")}>boolean</MenuItem>
|
|
531
|
+
onClick={() => doUpdateDataType("boolean")}>{t("boolean")}</MenuItem>
|
|
527
532
|
<MenuItem dense
|
|
528
|
-
onClick={() => doUpdateDataType("map")}>map</MenuItem>
|
|
533
|
+
onClick={() => doUpdateDataType("map")}>{t("map")}</MenuItem>
|
|
529
534
|
<MenuItem dense
|
|
530
|
-
onClick={() => doUpdateDataType("date")}>date</MenuItem>
|
|
535
|
+
onClick={() => doUpdateDataType("date")}>{t("date")}</MenuItem>
|
|
531
536
|
</Menu>
|
|
532
537
|
|
|
533
538
|
</Typography>
|
|
@@ -7,6 +7,7 @@ import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
|
7
7
|
import { FormEntry } from "../components/FormEntry";
|
|
8
8
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
9
9
|
import { cls, ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
|
|
10
|
+
import { useTranslation } from "../../hooks";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Field that renders the children property fields
|
|
@@ -91,7 +92,7 @@ export function MapFieldBinding({
|
|
|
91
92
|
}
|
|
92
93
|
</div>
|
|
93
94
|
|
|
94
|
-
{/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value)}*/}
|
|
95
|
+
{/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value, t)}*/}
|
|
95
96
|
|
|
96
97
|
</>
|
|
97
98
|
;
|
|
@@ -128,7 +129,7 @@ export function MapFieldBinding({
|
|
|
128
129
|
);
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue: (value: any) => void, value: any) => {
|
|
132
|
+
const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue: (value: any) => void, value: any, t: any) => {
|
|
132
133
|
|
|
133
134
|
const keys = Object.keys(properties)
|
|
134
135
|
.filter((key) => !value || !(key in value));
|
|
@@ -143,7 +144,7 @@ const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue
|
|
|
143
144
|
if (!keys.length) return <></>;
|
|
144
145
|
|
|
145
146
|
return <div className={"m-4"}>
|
|
146
|
-
<InputLabel>
|
|
147
|
+
<InputLabel>{t("add_property")}</InputLabel>
|
|
147
148
|
<Select
|
|
148
149
|
value={""}
|
|
149
150
|
size={"large"}
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
useStorageSource
|
|
13
13
|
} from "../../index";
|
|
14
14
|
import { cls, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin } from "@firecms/ui";
|
|
15
|
-
import { FireCMSEditor, FireCMSEditorProps } from "
|
|
15
|
+
import { FireCMSEditor, FireCMSEditorProps } from "../../editor";
|
|
16
16
|
import { resolveProperty, resolveStorageFilenameString, resolveStoragePathString } from "../../util";
|
|
17
|
+
import { isImageFile, resizeImage } from "../../util/useStorageUploadController";
|
|
17
18
|
|
|
18
19
|
interface MarkdownEditorFieldProps {
|
|
19
20
|
highlight?: { from: number, to: number };
|
|
@@ -55,17 +56,17 @@ export function MarkdownEditorFieldBinding({
|
|
|
55
56
|
}
|
|
56
57
|
internalValue.current = content;
|
|
57
58
|
setValue(content);
|
|
58
|
-
}, [setValue]);
|
|
59
|
+
}, [setValue, value]);
|
|
59
60
|
|
|
60
61
|
useEffect(() => {
|
|
61
62
|
if (internalValue.current !== value) {
|
|
62
63
|
internalValue.current = value;
|
|
63
|
-
setFieldVersion(
|
|
64
|
+
setFieldVersion(v => v + 1);
|
|
64
65
|
}
|
|
65
66
|
}, [value]);
|
|
66
67
|
|
|
67
68
|
const resolvedProperty = resolveProperty({
|
|
68
|
-
propertyOrBuilder: property as PropertyOrBuilder
|
|
69
|
+
propertyOrBuilder: property as PropertyOrBuilder<string>,
|
|
69
70
|
values: entityValues,
|
|
70
71
|
authController
|
|
71
72
|
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
@@ -112,33 +113,46 @@ export function MarkdownEditorFieldBinding({
|
|
|
112
113
|
// Extract markdown config from property - can be boolean or object
|
|
113
114
|
const markdownConfig = typeof property.markdown === 'object' ? property.markdown : undefined;
|
|
114
115
|
|
|
116
|
+
const handleImageUpload = async (file: File) => {
|
|
117
|
+
const imageResize = storage?.imageResize;
|
|
118
|
+
const legacyCompression = storage?.imageCompression;
|
|
119
|
+
if ((imageResize || legacyCompression) && isImageFile(file)) {
|
|
120
|
+
file = await resizeImage(file, imageResize, legacyCompression);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const storagePath = storagePathBuilder(file);
|
|
124
|
+
const fileName = await fileNameBuilder(file);
|
|
125
|
+
const result = await storageSource.uploadFile({
|
|
126
|
+
file,
|
|
127
|
+
fileName,
|
|
128
|
+
path: storagePath,
|
|
129
|
+
});
|
|
130
|
+
const downloadConfig = await storageSource.getDownloadURL(result.path);
|
|
131
|
+
const url = downloadConfig.url;
|
|
132
|
+
if (!url) {
|
|
133
|
+
throw new Error("Error uploading image");
|
|
134
|
+
}
|
|
135
|
+
return url;
|
|
136
|
+
};
|
|
137
|
+
|
|
115
138
|
const editor = <FireCMSEditor
|
|
139
|
+
key={context.formex.version + fieldVersion}
|
|
116
140
|
content={value}
|
|
117
141
|
onMarkdownContentChange={onContentChange}
|
|
118
142
|
version={context.formex.version + fieldVersion}
|
|
119
143
|
highlight={highlight}
|
|
120
144
|
disabled={disabled}
|
|
121
145
|
markdownConfig={markdownConfig}
|
|
122
|
-
handleImageUpload={
|
|
123
|
-
const storagePath = storagePathBuilder(file);
|
|
124
|
-
const fileName = await fileNameBuilder(file);
|
|
125
|
-
const result = await storageSource.uploadFile({
|
|
126
|
-
file,
|
|
127
|
-
fileName,
|
|
128
|
-
path: storagePath,
|
|
129
|
-
});
|
|
130
|
-
const downloadConfig = await storageSource.getDownloadURL(result.path);
|
|
131
|
-
const url = downloadConfig.url;
|
|
132
|
-
if (!url) {
|
|
133
|
-
throw new Error("Error uploading image");
|
|
134
|
-
}
|
|
135
|
-
return url;
|
|
136
|
-
}}
|
|
146
|
+
handleImageUpload={handleImageUpload}
|
|
137
147
|
{...editorProps}
|
|
138
148
|
/>;
|
|
139
149
|
|
|
140
150
|
if (minimalistView)
|
|
141
|
-
return
|
|
151
|
+
return (
|
|
152
|
+
<>
|
|
153
|
+
{editor}
|
|
154
|
+
</>
|
|
155
|
+
);
|
|
142
156
|
|
|
143
157
|
return (
|
|
144
158
|
<>
|
|
@@ -7,6 +7,7 @@ import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
|
7
7
|
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
9
|
import { useAuthController } from "../../hooks";
|
|
10
|
+
import { useTranslation } from "../../hooks/useTranslation";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Generic array field that allows reordering and renders the child property
|
|
@@ -34,6 +35,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
34
35
|
|
|
35
36
|
const authController = useAuthController();
|
|
36
37
|
const minimalistView = minimalistViewProp || property.minimalistView;
|
|
38
|
+
const { t } = useTranslation();
|
|
37
39
|
|
|
38
40
|
if (!property.of)
|
|
39
41
|
throw Error("RepeatFieldBinding misconfiguration. Property `of` not set");
|
|
@@ -87,7 +89,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
87
89
|
const canAddElements = !property.disabled && !isSubmitting && !disabled && (property.canAddElements || property.canAddElements === undefined);
|
|
88
90
|
const sortable = property.sortable === undefined ? true : property.sortable;
|
|
89
91
|
const arrayContainer = <ArrayContainer droppableId={propertyKey}
|
|
90
|
-
addLabel={property.name ? "
|
|
92
|
+
addLabel={property.name ? t("add_to_field", { fieldName: property.name }) : t("add_entry")}
|
|
91
93
|
value={value}
|
|
92
94
|
buildEntry={buildEntry}
|
|
93
95
|
onInternalIdAdded={setLastAddedId}
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
Typography
|
|
42
42
|
} from "@firecms/ui";
|
|
43
43
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
44
|
+
import { useTranslation } from "../../hooks/useTranslation";
|
|
44
45
|
|
|
45
46
|
const dropZoneClasses = "box-border relative pt-[2px] items-center border border-transparent min-h-[254px] outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid";
|
|
46
47
|
const disabledClasses = fieldBackgroundDisabledMixin;
|
|
@@ -52,18 +53,18 @@ const rejectDropClasses = "transition-colors duration-200 ease-[cubic-bezier(0,0
|
|
|
52
53
|
type StorageUploadFieldProps = FieldProps<string | string[]>;
|
|
53
54
|
|
|
54
55
|
export function StorageUploadFieldBinding({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
propertyKey,
|
|
57
|
+
value,
|
|
58
|
+
setValue,
|
|
59
|
+
error,
|
|
60
|
+
showError,
|
|
61
|
+
autoFocus,
|
|
62
|
+
minimalistView,
|
|
63
|
+
property,
|
|
64
|
+
includeDescription,
|
|
65
|
+
context,
|
|
66
|
+
isSubmitting,
|
|
67
|
+
}: StorageUploadFieldProps) {
|
|
67
68
|
|
|
68
69
|
const authController = useAuthController();
|
|
69
70
|
|
|
@@ -100,7 +101,7 @@ export function StorageUploadFieldBinding({
|
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
const resolvedProperty = resolveProperty({
|
|
103
|
-
propertyOrBuilder: property as PropertyOrBuilder
|
|
104
|
+
propertyOrBuilder: property as PropertyOrBuilder<string>,
|
|
104
105
|
authController
|
|
105
106
|
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
106
107
|
|
|
@@ -114,7 +115,7 @@ export function StorageUploadFieldBinding({
|
|
|
114
115
|
icon={getIconForProperty(property, "small")}
|
|
115
116
|
required={property.validation?.required}
|
|
116
117
|
title={property.name}
|
|
117
|
-
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
|
|
118
|
+
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"} />}
|
|
118
119
|
|
|
119
120
|
<StorageUpload
|
|
120
121
|
value={internalValue}
|
|
@@ -128,14 +129,13 @@ export function StorageUploadFieldBinding({
|
|
|
128
129
|
onFileUploadComplete={onFileUploadComplete}
|
|
129
130
|
storagePathBuilder={storagePathBuilder}
|
|
130
131
|
storage={storage}
|
|
131
|
-
multipleFilesSupported={multipleFilesSupported}/>
|
|
132
|
+
multipleFilesSupported={multipleFilesSupported} />
|
|
132
133
|
|
|
133
134
|
<FieldHelperText includeDescription={includeDescription}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
showError={showError}
|
|
136
|
+
error={error}
|
|
137
|
+
disabled={disabled}
|
|
138
|
+
property={property} />
|
|
139
139
|
</>
|
|
140
140
|
);
|
|
141
141
|
}
|
|
@@ -154,15 +154,15 @@ interface SortableStorageItemProps {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
function SortableStorageItem({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
id,
|
|
158
|
+
entry,
|
|
159
|
+
property,
|
|
160
|
+
metadata,
|
|
161
|
+
storagePathBuilder,
|
|
162
|
+
onFileUploadComplete,
|
|
163
|
+
onClear,
|
|
164
|
+
disabled,
|
|
165
|
+
}: SortableStorageItemProps) {
|
|
166
166
|
|
|
167
167
|
const {
|
|
168
168
|
attributes,
|
|
@@ -201,7 +201,7 @@ function SortableStorageItem({
|
|
|
201
201
|
disabled={disabled}
|
|
202
202
|
value={entry.storagePathOrDownloadUrl}
|
|
203
203
|
onRemove={() => onClear(entry.storagePathOrDownloadUrl!)}
|
|
204
|
-
size={entry.size}/>
|
|
204
|
+
size={entry.size} />
|
|
205
205
|
);
|
|
206
206
|
} else if (entry.file) {
|
|
207
207
|
child = (
|
|
@@ -231,21 +231,21 @@ function SortableStorageItem({
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function FileDropComponent({
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
234
|
+
storage,
|
|
235
|
+
disabled,
|
|
236
|
+
onFilesAdded,
|
|
237
|
+
multipleFilesSupported,
|
|
238
|
+
autoFocus,
|
|
239
|
+
internalValue,
|
|
240
|
+
property,
|
|
241
|
+
onClear,
|
|
242
|
+
metadata,
|
|
243
|
+
storagePathBuilder,
|
|
244
|
+
onFileUploadComplete,
|
|
245
|
+
name,
|
|
246
|
+
helpText,
|
|
247
|
+
isDndItemDragging
|
|
248
|
+
}: {
|
|
249
249
|
storage: StorageConfig,
|
|
250
250
|
disabled: boolean,
|
|
251
251
|
onFilesAdded: (acceptedFiles: File[]) => Promise<void>,
|
|
@@ -271,33 +271,33 @@ function FileDropComponent({
|
|
|
271
271
|
isDragAccept,
|
|
272
272
|
isDragReject
|
|
273
273
|
} = useDropzone({
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
274
|
+
accept: storage.acceptedFiles ? storage.acceptedFiles.reduce((acc, ext) => ({
|
|
275
|
+
...acc,
|
|
276
|
+
[ext]: []
|
|
277
|
+
}), {}) : undefined,
|
|
278
|
+
disabled: disabled || isDndItemDragging,
|
|
279
|
+
noDragEventsBubbling: true,
|
|
280
|
+
maxSize: storage.maxSize,
|
|
281
|
+
onDrop: onFilesAdded,
|
|
282
|
+
onDropRejected: (fileRejections) => {
|
|
283
|
+
for (const fileRejection of fileRejections) {
|
|
284
|
+
for (const error of fileRejection.errors) {
|
|
285
|
+
console.error("Error uploading file: ", error);
|
|
286
|
+
if (error.code === "file-too-large") {
|
|
287
|
+
snackbarContext.open({
|
|
288
|
+
type: "error",
|
|
289
|
+
message: `Error uploading file: File is larger than ${storage.maxSize} bytes`
|
|
290
|
+
});
|
|
291
|
+
} else if (error.code === "file-invalid-type") {
|
|
292
|
+
snackbarContext.open({
|
|
293
|
+
type: "error",
|
|
294
|
+
message: "Error uploading file: File type is not supported"
|
|
295
|
+
});
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
298
|
}
|
|
300
299
|
}
|
|
300
|
+
}
|
|
301
301
|
);
|
|
302
302
|
|
|
303
303
|
return (
|
|
@@ -349,8 +349,8 @@ function FileDropComponent({
|
|
|
349
349
|
<div
|
|
350
350
|
className="flex-grow min-h-[38px] box-border m-2 text-center">
|
|
351
351
|
<Typography align={"center"}
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
variant={"label"}
|
|
353
|
+
className={disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : ""}>
|
|
354
354
|
{helpText}
|
|
355
355
|
</Typography>
|
|
356
356
|
</div>
|
|
@@ -374,19 +374,20 @@ export interface StorageUploadProps {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export function StorageUpload({
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
377
|
+
property,
|
|
378
|
+
name,
|
|
379
|
+
value, // This is internalValue from useStorageUploadController
|
|
380
|
+
setInternalValue,
|
|
381
|
+
onChange,
|
|
382
|
+
multipleFilesSupported,
|
|
383
|
+
onFileUploadComplete,
|
|
384
|
+
disabled,
|
|
385
|
+
onFilesAdded,
|
|
386
|
+
autoFocus,
|
|
387
|
+
storage,
|
|
388
|
+
storagePathBuilder,
|
|
389
|
+
}: StorageUploadProps) {
|
|
390
|
+
const { t } = useTranslation();
|
|
390
391
|
|
|
391
392
|
if (multipleFilesSupported) {
|
|
392
393
|
const arrayProperty = property as ResolvedArrayProperty<string[]>;
|
|
@@ -461,8 +462,8 @@ export function StorageUpload({
|
|
|
461
462
|
}, [value, multipleFilesSupported, onChange, setInternalValue]);
|
|
462
463
|
|
|
463
464
|
const helpText = multipleFilesSupported
|
|
464
|
-
? "
|
|
465
|
-
: "
|
|
465
|
+
? t("drag_drop_multiple")
|
|
466
|
+
: t("drag_drop_single");
|
|
466
467
|
|
|
467
468
|
const renderProperty: ResolvedStringProperty = multipleFilesSupported
|
|
468
469
|
? (property as ResolvedArrayProperty<string[]>).of as ResolvedStringProperty
|
|
@@ -500,6 +501,6 @@ export function StorageUpload({
|
|
|
500
501
|
);
|
|
501
502
|
} else {
|
|
502
503
|
// For single file, no D&D context is needed
|
|
503
|
-
return <FileDropComponent {...fileDropProps} isDndItemDragging={false}/>;
|
|
504
|
+
return <FileDropComponent {...fileDropProps} isDndItemDragging={false} />;
|
|
504
505
|
}
|
|
505
506
|
}
|
package/src/hooks/index.tsx
CHANGED