@firecms/core 3.0.1 → 3.1.0-canary.24c8270
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/README.md +1 -1
- package/dist/components/AIIcon.d.ts +16 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +7 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +14 -0
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +6 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +5 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +6 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/useDraggable.d.ts +2 -2
- package/dist/components/EntityCollectionView/Board.d.ts +2 -0
- package/dist/components/EntityCollectionView/BoardColumn.d.ts +42 -0
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +9 -0
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +14 -0
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +26 -0
- package/dist/components/EntityCollectionView/EntityCard.d.ts +19 -0
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +20 -0
- package/dist/components/EntityCollectionView/EntityCollectionCardView.d.ts +31 -0
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +2 -2
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +7 -3
- package/dist/components/EntityCollectionView/FiltersDialog.d.ts +14 -0
- package/dist/components/EntityCollectionView/ViewModeToggle.d.ts +44 -0
- package/dist/components/EntityCollectionView/board_types.d.ts +105 -0
- package/dist/components/EntityCollectionView/useBoardDataController.d.ts +60 -0
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +5 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableCell.d.ts +6 -0
- package/dist/components/VirtualTable/VirtualTableHeader.d.ts +3 -1
- package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +11 -0
- package/dist/components/VirtualTable/fields/VirtualTableDateField.d.ts +1 -0
- package/dist/components/VirtualTable/types.d.ts +2 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/contexts/index.d.ts +10 -0
- package/dist/core/DrawerNavigationGroup.d.ts +45 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/validation.d.ts +3 -2
- package/dist/hooks/useBreadcrumbsController.d.ts +16 -0
- package/dist/hooks/useCollapsedGroups.d.ts +4 -1
- package/dist/index.es.js +5316 -1592
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5309 -1586
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useRestoreScroll.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +5 -0
- package/dist/preview/components/DatePreview.d.ts +13 -3
- package/dist/preview/components/ImagePreview.d.ts +5 -1
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +50 -2
- package/dist/types/datasource.d.ts +0 -1
- package/dist/types/plugins.d.ts +62 -1
- package/dist/types/properties.d.ts +259 -4
- package/dist/util/__tests__/conditions.test.d.ts +1 -0
- package/dist/util/__tests__/objects.test.d.ts +1 -0
- package/dist/util/conditions.d.ts +26 -0
- package/dist/util/entities.d.ts +2 -3
- package/dist/util/index.d.ts +2 -1
- package/dist/util/property_utils.d.ts +2 -1
- package/dist/util/resolutions.d.ts +3 -3
- package/package.json +14 -11
- package/src/app/Scaffold.tsx +14 -15
- package/src/components/AIIcon.tsx +39 -0
- package/src/components/ArrayContainer.tsx +1 -4
- package/src/components/ClearFilterSortButton.tsx +19 -16
- package/src/components/ConfirmationDialog.tsx +0 -2
- package/src/components/DeleteEntityDialog.tsx +2 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +74 -41
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +130 -79
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +121 -104
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +132 -103
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +20 -42
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +90 -49
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +11 -11
- package/src/components/EntityCollectionView/Board.tsx +324 -0
- package/src/components/EntityCollectionView/BoardColumn.tsx +158 -0
- package/src/components/EntityCollectionView/BoardColumnTitle.tsx +45 -0
- package/src/components/EntityCollectionView/BoardSortableList.tsx +172 -0
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +212 -0
- package/src/components/EntityCollectionView/EntityCard.tsx +235 -0
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +733 -0
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +244 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +519 -203
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +31 -19
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +84 -15
- package/src/components/EntityCollectionView/FiltersDialog.tsx +249 -0
- package/src/components/EntityCollectionView/ViewModeToggle.tsx +199 -0
- package/src/components/EntityCollectionView/board_types.ts +113 -0
- package/src/components/EntityCollectionView/useBoardDataController.tsx +490 -0
- package/src/components/ErrorTooltip.tsx +2 -1
- package/src/components/HomePage/DefaultHomePage.tsx +47 -10
- package/src/components/HomePage/HomePageDnD.tsx +56 -41
- package/src/components/HomePage/NavigationCard.tsx +20 -18
- package/src/components/HomePage/NavigationGroup.tsx +17 -16
- package/src/components/HomePage/RenameGroupDialog.tsx +0 -2
- package/src/components/HomePage/SmallNavigationCard.tsx +10 -9
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -10
- package/src/components/ReferenceWidget.tsx +2 -4
- package/src/components/SelectableTable/SelectableTable.tsx +75 -67
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +7 -6
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +39 -40
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -38
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +49 -58
- package/src/components/UnsavedChangesDialog.tsx +0 -2
- package/src/components/UserDisplay.tsx +4 -4
- package/src/components/VirtualTable/VirtualTable.tsx +272 -118
- package/src/components/VirtualTable/VirtualTableCell.tsx +18 -2
- package/src/components/VirtualTable/VirtualTableHeader.tsx +59 -50
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +158 -42
- package/src/components/VirtualTable/VirtualTableProps.tsx +14 -1
- package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -0
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +19 -6
- package/src/components/VirtualTable/types.tsx +2 -0
- package/src/components/common/useColumnsIds.tsx +95 -3
- package/src/components/common/useDataSourceTableController.tsx +21 -4
- package/src/components/index.tsx +4 -0
- package/src/contexts/BreacrumbsContext.tsx +15 -8
- package/src/contexts/index.ts +10 -0
- package/src/core/DefaultAppBar.tsx +40 -27
- package/src/core/DefaultDrawer.tsx +42 -56
- package/src/core/DrawerNavigationGroup.tsx +118 -0
- package/src/core/DrawerNavigationItem.tsx +4 -3
- package/src/core/EntityEditView.tsx +41 -43
- package/src/core/EntitySidePanel.tsx +28 -26
- package/src/core/SideDialogs.tsx +4 -2
- package/src/core/field_configs.tsx +14 -9
- package/src/core/index.tsx +1 -0
- package/src/form/EntityForm.tsx +69 -60
- package/src/form/PropertyFieldBinding.tsx +61 -46
- package/src/form/components/ErrorFocus.tsx +3 -3
- package/src/form/components/StorageItemPreview.tsx +2 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +0 -1
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -16
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +0 -1
- package/src/form/field_bindings/MapFieldBinding.tsx +69 -67
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +22 -18
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +83 -83
- package/src/form/field_bindings/TextFieldBinding.tsx +71 -35
- package/src/form/validation.ts +245 -160
- package/src/hooks/useBreadcrumbsController.tsx +18 -0
- package/src/hooks/useBuildNavigationController.tsx +71 -28
- package/src/hooks/useCollapsedGroups.ts +12 -4
- package/src/hooks/useValidateAuthenticator.tsx +1 -1
- package/src/internal/useBuildDataSource.ts +68 -34
- package/src/internal/useBuildSideDialogsController.tsx +11 -8
- package/src/internal/useBuildSideEntityController.tsx +24 -24
- package/src/internal/useRestoreScroll.tsx +26 -14
- package/src/preview/PropertyPreview.tsx +41 -32
- package/src/preview/PropertyPreviewProps.tsx +6 -0
- package/src/preview/components/DatePreview.tsx +72 -4
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +37 -21
- package/src/preview/components/StorageThumbnail.tsx +16 -12
- package/src/preview/components/UrlComponentPreview.tsx +28 -25
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +9 -7
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +11 -9
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +26 -24
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +61 -56
- package/src/routes/CustomCMSRoute.tsx +1 -0
- package/src/routes/FireCMSRoute.tsx +26 -13
- package/src/types/analytics.ts +10 -0
- package/src/types/collections.ts +57 -3
- package/src/types/datasource.ts +54 -56
- package/src/types/plugins.tsx +69 -1
- package/src/types/properties.ts +347 -27
- package/src/util/__tests__/conditions.test.ts +506 -0
- package/src/util/__tests__/objects.test.ts +196 -0
- package/src/util/callbacks.ts +6 -3
- package/src/util/collections.ts +51 -6
- package/src/util/conditions.ts +339 -0
- package/src/util/entities.ts +29 -30
- package/src/util/entity_cache.ts +2 -1
- package/src/util/index.ts +2 -1
- package/src/util/join_collections.ts +10 -8
- package/src/util/objects.ts +31 -13
- package/src/util/{references.ts → previews.ts} +16 -2
- package/src/util/property_utils.tsx +37 -11
- package/src/util/resolutions.ts +62 -58
- /package/dist/util/{references.d.ts → previews.d.ts} +0 -0
|
@@ -4,6 +4,7 @@ import { FieldProps, MapProperty, Properties, PropertyFieldBindingProps, Resolve
|
|
|
4
4
|
import { ErrorBoundary } from "../../components";
|
|
5
5
|
import { getIconForProperty, isHidden, isReadOnly, pick } from "../../util";
|
|
6
6
|
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
|
+
import { FormEntry } from "../components/FormEntry";
|
|
7
8
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
8
9
|
import { cls, ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
|
|
9
10
|
|
|
@@ -15,19 +16,19 @@ import { cls, ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/u
|
|
|
15
16
|
* @group Form fields
|
|
16
17
|
*/
|
|
17
18
|
export function MapFieldBinding({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
propertyKey,
|
|
20
|
+
value,
|
|
21
|
+
showError,
|
|
22
|
+
error,
|
|
23
|
+
disabled,
|
|
24
|
+
property,
|
|
25
|
+
partOfArray,
|
|
26
|
+
minimalistView: minimalistViewProp,
|
|
27
|
+
includeDescription,
|
|
28
|
+
autoFocus,
|
|
29
|
+
context,
|
|
30
|
+
onPropertyChange
|
|
31
|
+
}: FieldProps<Record<string, any>>) {
|
|
31
32
|
|
|
32
33
|
const pickOnlySomeKeys = property.pickOnlySomeKeys || false;
|
|
33
34
|
const expanded = property.expanded === undefined ? true : property.expanded;
|
|
@@ -52,75 +53,76 @@ export function MapFieldBinding({
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const mapFormView = <>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
} as Partial<MapProperty>);
|
|
56
|
+
<div
|
|
57
|
+
className={cls("py-1 flex flex-wrap gap-x-4 w-full space-y-2", minimalistView && property.widthPercentage !== undefined ? "mt-8" : undefined)}>
|
|
58
|
+
{Object.entries(mapProperties)
|
|
59
|
+
.filter(([_, property]) => !isHidden(property))
|
|
60
|
+
.map(([entryKey, childProperty], index) => {
|
|
61
|
+
const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
|
|
62
|
+
const fieldBindingProps: PropertyFieldBindingProps<any> = {
|
|
63
|
+
propertyKey: `${propertyKey}.${entryKey}`,
|
|
64
|
+
disabled: disabled || thisDisabled,
|
|
65
|
+
property: childProperty,
|
|
66
|
+
includeDescription,
|
|
67
|
+
context,
|
|
68
|
+
partOfArray: false,
|
|
69
|
+
minimalistView: false,
|
|
70
|
+
autoFocus: autoFocus && index === 0,
|
|
71
|
+
onPropertyChange: function (updatedProperty) {
|
|
72
|
+
onPropertyChange?.({
|
|
73
|
+
properties: {
|
|
74
|
+
[entryKey]: updatedProperty
|
|
76
75
|
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div key={`map-${propertyKey}-${index}`} className={"relative"}>
|
|
81
|
-
<ErrorBoundary>
|
|
82
|
-
<PropertyFieldBinding
|
|
83
|
-
{...fieldBindingProps}/>
|
|
84
|
-
</ErrorBoundary>
|
|
85
|
-
</div>
|
|
86
|
-
) ;
|
|
76
|
+
} as Partial<MapProperty>);
|
|
87
77
|
}
|
|
88
|
-
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const widthPercentage = childProperty.widthPercentage ?? 100;
|
|
81
|
+
return (
|
|
82
|
+
<FormEntry propertyKey={`${propertyKey}.${entryKey}`}
|
|
83
|
+
widthPercentage={widthPercentage}
|
|
84
|
+
key={`map-${propertyKey}-${index}`}>
|
|
85
|
+
<PropertyFieldBinding
|
|
86
|
+
{...fieldBindingProps} />
|
|
87
|
+
</FormEntry>
|
|
88
|
+
);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
</div>
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
{/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value)}*/}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
</>
|
|
97
|
+
;
|
|
96
98
|
|
|
97
99
|
return (
|
|
98
100
|
<ErrorBoundary>
|
|
99
101
|
|
|
100
102
|
{!minimalistView && <ExpandablePanel initiallyExpanded={expanded}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
onExpandedChange={(expanded) => {
|
|
104
|
+
onPropertyChange?.({
|
|
105
|
+
expanded
|
|
106
|
+
});
|
|
107
|
+
}}
|
|
108
|
+
className={property.widthPercentage !== undefined ? "mt-8" : undefined}
|
|
109
|
+
innerClassName={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2 bg-white dark:bg-surface-900"}
|
|
110
|
+
title={<LabelWithIconAndTooltip
|
|
111
|
+
propertyKey={propertyKey}
|
|
112
|
+
icon={getIconForProperty(property, "small")}
|
|
113
|
+
required={property.validation?.required}
|
|
114
|
+
title={property.name}
|
|
115
|
+
className={"text-text-secondary dark:text-text-secondary-dark"} />}>
|
|
114
116
|
{mapFormView}
|
|
115
117
|
</ExpandablePanel>}
|
|
116
118
|
|
|
117
119
|
{minimalistView && mapFormView}
|
|
118
120
|
|
|
119
121
|
<FieldHelperText includeDescription={includeDescription}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
showError={showError ?? false}
|
|
123
|
+
error={error && !partOfArray ? (typeof error === "string" ? error : "A property of this map has an error") : undefined}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
property={property} />
|
|
124
126
|
|
|
125
127
|
</ErrorBoundary>
|
|
126
128
|
);
|
|
@@ -150,7 +152,7 @@ const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue
|
|
|
150
152
|
onValueChange={handleAddProperty}
|
|
151
153
|
renderValue={(key) => (properties as Properties)[key].name || key}>
|
|
152
154
|
{keys.map((key) => <SelectItem key={key}
|
|
153
|
-
|
|
155
|
+
value={key}>{(properties as Properties)[key].name || key}</SelectItem>)}
|
|
154
156
|
</Select>
|
|
155
157
|
</div>;
|
|
156
158
|
};
|
|
@@ -21,19 +21,19 @@ interface MarkdownEditorFieldProps {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function MarkdownEditorFieldBinding({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
property,
|
|
25
|
+
propertyKey,
|
|
26
|
+
value,
|
|
27
|
+
setValue,
|
|
28
|
+
includeDescription,
|
|
29
|
+
showError,
|
|
30
|
+
error,
|
|
31
|
+
minimalistView,
|
|
32
|
+
disabled: disabledProp,
|
|
33
|
+
isSubmitting,
|
|
34
|
+
context,
|
|
35
|
+
customProps,
|
|
36
|
+
}: FieldProps<string, MarkdownEditorFieldProps>) {
|
|
37
37
|
|
|
38
38
|
const authController = useAuthController();
|
|
39
39
|
const disabled = disabledProp || isSubmitting;
|
|
@@ -65,7 +65,7 @@ export function MarkdownEditorFieldBinding({
|
|
|
65
65
|
}, [value]);
|
|
66
66
|
|
|
67
67
|
const resolvedProperty = resolveProperty({
|
|
68
|
-
propertyOrBuilder: property as PropertyOrBuilder
|
|
68
|
+
propertyOrBuilder: property as PropertyOrBuilder<string>,
|
|
69
69
|
values: entityValues,
|
|
70
70
|
authController
|
|
71
71
|
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
@@ -109,12 +109,16 @@ export function MarkdownEditorFieldBinding({
|
|
|
109
109
|
}) ?? "/";
|
|
110
110
|
}, [entityId, entityValues, path, property, propertyKey, storage]);
|
|
111
111
|
|
|
112
|
+
// Extract markdown config from property - can be boolean or object
|
|
113
|
+
const markdownConfig = typeof property.markdown === 'object' ? property.markdown : undefined;
|
|
114
|
+
|
|
112
115
|
const editor = <FireCMSEditor
|
|
113
116
|
content={value}
|
|
114
117
|
onMarkdownContentChange={onContentChange}
|
|
115
118
|
version={context.formex.version + fieldVersion}
|
|
116
119
|
highlight={highlight}
|
|
117
120
|
disabled={disabled}
|
|
121
|
+
markdownConfig={markdownConfig}
|
|
118
122
|
handleImageUpload={async (file: File) => {
|
|
119
123
|
const storagePath = storagePathBuilder(file);
|
|
120
124
|
const fileName = await fileNameBuilder(file);
|
|
@@ -143,15 +147,15 @@ export function MarkdownEditorFieldBinding({
|
|
|
143
147
|
icon={getIconForProperty(property, "small")}
|
|
144
148
|
required={property.validation?.required}
|
|
145
149
|
title={property.name}
|
|
146
|
-
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
|
|
150
|
+
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"} />
|
|
147
151
|
<div
|
|
148
152
|
className={cls("rounded-md", fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin)}>
|
|
149
153
|
{editor}
|
|
150
154
|
</div>
|
|
151
155
|
<FieldHelperText includeDescription={includeDescription}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
showError={showError}
|
|
157
|
+
error={error}
|
|
158
|
+
property={property} />
|
|
155
159
|
</>
|
|
156
160
|
|
|
157
161
|
);
|
|
@@ -52,18 +52,18 @@ const rejectDropClasses = "transition-colors duration-200 ease-[cubic-bezier(0,0
|
|
|
52
52
|
type StorageUploadFieldProps = FieldProps<string | string[]>;
|
|
53
53
|
|
|
54
54
|
export function StorageUploadFieldBinding({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
propertyKey,
|
|
56
|
+
value,
|
|
57
|
+
setValue,
|
|
58
|
+
error,
|
|
59
|
+
showError,
|
|
60
|
+
autoFocus,
|
|
61
|
+
minimalistView,
|
|
62
|
+
property,
|
|
63
|
+
includeDescription,
|
|
64
|
+
context,
|
|
65
|
+
isSubmitting,
|
|
66
|
+
}: StorageUploadFieldProps) {
|
|
67
67
|
|
|
68
68
|
const authController = useAuthController();
|
|
69
69
|
|
|
@@ -100,7 +100,7 @@ export function StorageUploadFieldBinding({
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
const resolvedProperty = resolveProperty({
|
|
103
|
-
propertyOrBuilder: property as PropertyOrBuilder
|
|
103
|
+
propertyOrBuilder: property as PropertyOrBuilder<string>,
|
|
104
104
|
authController
|
|
105
105
|
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
106
106
|
|
|
@@ -114,7 +114,7 @@ export function StorageUploadFieldBinding({
|
|
|
114
114
|
icon={getIconForProperty(property, "small")}
|
|
115
115
|
required={property.validation?.required}
|
|
116
116
|
title={property.name}
|
|
117
|
-
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
|
|
117
|
+
className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"} />}
|
|
118
118
|
|
|
119
119
|
<StorageUpload
|
|
120
120
|
value={internalValue}
|
|
@@ -128,13 +128,13 @@ export function StorageUploadFieldBinding({
|
|
|
128
128
|
onFileUploadComplete={onFileUploadComplete}
|
|
129
129
|
storagePathBuilder={storagePathBuilder}
|
|
130
130
|
storage={storage}
|
|
131
|
-
multipleFilesSupported={multipleFilesSupported}/>
|
|
131
|
+
multipleFilesSupported={multipleFilesSupported} />
|
|
132
132
|
|
|
133
133
|
<FieldHelperText includeDescription={includeDescription}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
showError={showError}
|
|
135
|
+
error={error}
|
|
136
|
+
disabled={disabled}
|
|
137
|
+
property={property} />
|
|
138
138
|
|
|
139
139
|
</>
|
|
140
140
|
);
|
|
@@ -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,19 @@ 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
390
|
|
|
391
391
|
if (multipleFilesSupported) {
|
|
392
392
|
const arrayProperty = property as ResolvedArrayProperty<string[]>;
|
|
@@ -500,6 +500,6 @@ export function StorageUpload({
|
|
|
500
500
|
);
|
|
501
501
|
} else {
|
|
502
502
|
// For single file, no D&D context is needed
|
|
503
|
-
return <FileDropComponent {...fileDropProps} isDndItemDragging={false}/>;
|
|
503
|
+
return <FileDropComponent {...fileDropProps} isDndItemDragging={false} />;
|
|
504
504
|
}
|
|
505
505
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
|
|
3
|
-
import { CloseIcon, Collapse, IconButton, TextField } from "@firecms/ui";
|
|
3
|
+
import { CloseIcon, Collapse, IconButton, TextField, TextareaAutosize, fieldBackgroundHoverMixin, fieldBackgroundMixin, cls } from "@firecms/ui";
|
|
4
4
|
import { FieldProps, PreviewType } from "../../types";
|
|
5
5
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
6
6
|
import { getIconForProperty } from "../../util";
|
|
@@ -19,17 +19,17 @@ interface TextFieldBindingProps<T extends string | number> extends FieldProps<T>
|
|
|
19
19
|
* @group Form fields
|
|
20
20
|
*/
|
|
21
21
|
export function TextFieldBinding<T extends string | number>({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
propertyKey,
|
|
23
|
+
value,
|
|
24
|
+
setValue,
|
|
25
|
+
error,
|
|
26
|
+
showError,
|
|
27
|
+
disabled,
|
|
28
|
+
autoFocus,
|
|
29
|
+
property,
|
|
30
|
+
includeDescription,
|
|
31
|
+
size = "large"
|
|
32
|
+
}: TextFieldBindingProps<T>) {
|
|
33
33
|
|
|
34
34
|
let multiline: boolean | undefined;
|
|
35
35
|
let url: boolean | PreviewType | undefined;
|
|
@@ -68,46 +68,82 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
68
68
|
const isMultiline = Boolean(multiline);
|
|
69
69
|
|
|
70
70
|
const inputType = property.dataType === "number" ? "number" : undefined;
|
|
71
|
+
|
|
72
|
+
const label = (
|
|
73
|
+
<LabelWithIcon
|
|
74
|
+
icon={getIconForProperty(property, "small")}
|
|
75
|
+
required={property.validation?.required}
|
|
76
|
+
title={property.name} />
|
|
77
|
+
);
|
|
78
|
+
|
|
71
79
|
return (<>
|
|
72
|
-
|
|
80
|
+
<PropertyIdCopyTooltip propertyKey={propertyKey}>
|
|
81
|
+
{isMultiline ? (
|
|
82
|
+
<div className={cls(
|
|
83
|
+
"rounded-md relative max-w-full min-h-[64px]",
|
|
84
|
+
fieldBackgroundMixin,
|
|
85
|
+
fieldBackgroundHoverMixin,
|
|
86
|
+
showError && error ? "border border-red-500 dark:border-red-600" : "",
|
|
87
|
+
property.widthPercentage !== undefined ? "mt-8" : undefined
|
|
88
|
+
)}>
|
|
89
|
+
<div className="pointer-events-none absolute top-1 text-xs font-medium px-3 text-text-secondary dark:text-text-secondary-dark">
|
|
90
|
+
{label}
|
|
91
|
+
</div>
|
|
92
|
+
<TextareaAutosize
|
|
93
|
+
value={value ?? ""}
|
|
94
|
+
onChange={onChange}
|
|
95
|
+
autoFocus={autoFocus}
|
|
96
|
+
disabled={disabled}
|
|
97
|
+
className={cls(
|
|
98
|
+
"rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-8",
|
|
99
|
+
disabled && "outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500",
|
|
100
|
+
showError && error ? "text-red-500 dark:text-red-600" : ""
|
|
101
|
+
)}
|
|
102
|
+
/>
|
|
103
|
+
{property.clearable && (
|
|
104
|
+
<div className="flex flex-row justify-center items-center absolute h-full right-0 top-0 mr-4">
|
|
105
|
+
<IconButton onClick={handleClearClick}>
|
|
106
|
+
<CloseIcon />
|
|
107
|
+
</IconButton>
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
) : (
|
|
73
112
|
<TextField
|
|
74
113
|
size={size}
|
|
75
114
|
value={value}
|
|
76
115
|
onChange={onChange}
|
|
77
116
|
autoFocus={autoFocus}
|
|
78
117
|
className={property.widthPercentage !== undefined ? "mt-8" : undefined}
|
|
79
|
-
label={
|
|
80
|
-
icon={getIconForProperty(property, "small")}
|
|
81
|
-
required={property.validation?.required}
|
|
82
|
-
title={property.name}/>}
|
|
118
|
+
label={label}
|
|
83
119
|
type={inputType}
|
|
84
|
-
multiline={isMultiline}
|
|
85
120
|
disabled={disabled}
|
|
86
121
|
endAdornment={
|
|
87
122
|
property.clearable && <IconButton
|
|
88
123
|
onClick={handleClearClick}>
|
|
89
|
-
<CloseIcon/>
|
|
124
|
+
<CloseIcon />
|
|
90
125
|
</IconButton>
|
|
91
126
|
}
|
|
92
127
|
error={showError ? error : undefined}
|
|
93
|
-
inputClassName={error ? "text-red-500 dark:text-red-600" : ""}/>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
128
|
+
inputClassName={error ? "text-red-500 dark:text-red-600" : ""} />
|
|
129
|
+
)}
|
|
130
|
+
</PropertyIdCopyTooltip>
|
|
131
|
+
<FieldHelperText includeDescription={includeDescription}
|
|
132
|
+
showError={showError}
|
|
133
|
+
error={error}
|
|
134
|
+
disabled={disabled}
|
|
135
|
+
property={property} />
|
|
100
136
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
137
|
+
{url && <Collapse
|
|
138
|
+
className="mt-1 ml-1"
|
|
139
|
+
in={Boolean(value)}>
|
|
140
|
+
<PropertyPreview
|
|
141
|
+
value={value}
|
|
142
|
+
property={property}
|
|
143
|
+
size={size} />
|
|
144
|
+
</Collapse>}
|
|
109
145
|
|
|
110
|
-
|
|
146
|
+
</>
|
|
111
147
|
);
|
|
112
148
|
|
|
113
149
|
}
|