@firecms/core 3.0.0-beta.5 → 3.0.0-beta.7
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/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +1 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +11 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityPreview.d.ts +3 -2
- package/dist/components/FireCMSAppBar.d.ts +4 -2
- package/dist/components/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -6
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/core/Drawer.d.ts +5 -12
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +8 -12
- package/dist/core/index.d.ts +3 -4
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/hooks/data/save.d.ts +1 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useValidateAuthenticator.d.ts +2 -6
- package/dist/index.es.js +10087 -9914
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -16
- package/dist/preview/components/ReferencePreview.d.ts +2 -1
- package/dist/types/collections.d.ts +13 -2
- package/dist/types/datasource.d.ts +2 -5
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +3 -1
- package/dist/types/properties.d.ts +10 -2
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -97
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/resolutions.d.ts +13 -13
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +19 -18
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +10 -6
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +38 -34
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +47 -25
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityPreview.tsx +9 -7
- package/src/components/EntityView.tsx +5 -5
- package/src/components/FireCMSAppBar.tsx +32 -15
- package/src/components/HomePage/DefaultHomePage.tsx +1 -1
- package/src/components/HomePage/NavigationCard.tsx +2 -2
- package/src/components/HomePage/SmallNavigationCard.tsx +5 -5
- package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
- package/src/components/ReferenceWidget.tsx +21 -11
- package/src/components/SearchIconsView.tsx +5 -5
- package/src/components/SelectableTable/SelectableTable.tsx +5 -3
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +28 -6
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +36 -29
- package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -6
- package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +2 -2
- package/src/components/common/index.ts +1 -0
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useColumnsIds.tsx +10 -2
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
- package/src/components/index.tsx +1 -0
- package/src/core/Drawer.tsx +16 -68
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/EntityEditView.tsx +7 -8
- package/src/core/EntitySidePanel.tsx +1 -1
- package/src/core/FireCMS.tsx +37 -42
- package/src/core/NavigationRoutes.tsx +3 -4
- package/src/core/Scaffold.tsx +80 -66
- package/src/core/field_configs.tsx +2 -3
- package/src/core/index.tsx +3 -4
- package/src/form/EntityForm.tsx +29 -21
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +2 -2
- package/src/form/components/StorageUploadProgress.tsx +3 -3
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -2
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -4
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +4 -4
- package/src/hooks/data/save.ts +3 -1
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +77 -21
- package/src/hooks/useProjectLog.tsx +3 -3
- package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
- package/src/hooks/useValidateAuthenticator.tsx +17 -37
- package/src/internal/useBuildDataSource.ts +42 -47
- package/src/internal/useBuildSideEntityController.tsx +86 -22
- package/src/preview/PropertyPreview.tsx +4 -14
- package/src/preview/components/BooleanPreview.tsx +2 -2
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +21 -22
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/types/collections.ts +19 -3
- package/src/types/datasource.ts +7 -4
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +16 -3
- package/src/types/index.ts +0 -1
- package/src/types/navigation.ts +2 -3
- package/src/types/plugins.tsx +4 -3
- package/src/types/properties.ts +15 -4
- package/src/types/storage.ts +1 -1
- package/src/util/entities.ts +1 -1
- package/src/util/enums.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +3 -99
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +8 -21
- package/src/util/resolutions.ts +32 -31
- package/dist/components/VirtualTable/common.d.ts +0 -2
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/internal/useBuildCustomizationController.d.ts +0 -2
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/core/SideEntityView.tsx +0 -38
- package/src/internal/useBuildCustomizationController.tsx +0 -5
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
package/src/core/Scaffold.tsx
CHANGED
|
@@ -5,19 +5,35 @@ import { Link } from "react-router-dom";
|
|
|
5
5
|
import { Drawer as DefaultDrawer, DrawerProps } from "./Drawer";
|
|
6
6
|
import { useLargeLayout, useNavigationController } from "../hooks";
|
|
7
7
|
import { ErrorBoundary, FireCMSAppBar as DefaultFireCMSAppBar, FireCMSAppBarProps, FireCMSLogo } from "../components";
|
|
8
|
-
import { ChevronLeftIcon,
|
|
8
|
+
import { ChevronLeftIcon, cls, defaultBorderMixin, IconButton, MenuIcon, Sheet, Tooltip } from "@firecms/ui";
|
|
9
9
|
|
|
10
10
|
export const DRAWER_WIDTH = 280;
|
|
11
11
|
|
|
12
|
+
const DrawerContext = React.createContext<DrawerProps>({
|
|
13
|
+
hovered: false,
|
|
14
|
+
drawerOpen: false,
|
|
15
|
+
openDrawer: () => {
|
|
16
|
+
throw new Error("openDrawer not implemented");
|
|
17
|
+
},
|
|
18
|
+
closeDrawer: () => {
|
|
19
|
+
throw new Error("closeDrawer not implemented");
|
|
20
|
+
},
|
|
21
|
+
autoOpenDrawer: false
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export function useDrawer() {
|
|
25
|
+
return React.useContext(DrawerContext);
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
/**
|
|
13
29
|
* @group Core
|
|
14
30
|
*/
|
|
15
|
-
export interface ScaffoldProps<
|
|
31
|
+
export interface ScaffoldProps<ExtraAppbarProps = object> {
|
|
16
32
|
|
|
17
33
|
/**
|
|
18
34
|
* Name of the app, displayed as the main title and in the tab title
|
|
19
35
|
*/
|
|
20
|
-
name
|
|
36
|
+
name?: React.ReactNode;
|
|
21
37
|
|
|
22
38
|
/**
|
|
23
39
|
* Logo to be displayed in the drawer of the CMS
|
|
@@ -30,15 +46,10 @@ export interface ScaffoldProps<ExtraDrawerProps = object, ExtraAppbarProps = obj
|
|
|
30
46
|
includeDrawer?: boolean;
|
|
31
47
|
|
|
32
48
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
Drawer?: React.ComponentType<DrawerProps<ExtraDrawerProps>>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Additional props passed to the custom Drawer
|
|
49
|
+
* You can define a custom drawer to be displayed in the scaffold.
|
|
50
|
+
* Use the hook `useDrawer` to access the context values.
|
|
40
51
|
*/
|
|
41
|
-
|
|
52
|
+
drawer?: React.ReactNode;
|
|
42
53
|
|
|
43
54
|
/**
|
|
44
55
|
* Open the drawer on hover
|
|
@@ -46,8 +57,7 @@ export interface ScaffoldProps<ExtraDrawerProps = object, ExtraAppbarProps = obj
|
|
|
46
57
|
autoOpenDrawer?: boolean;
|
|
47
58
|
|
|
48
59
|
/**
|
|
49
|
-
*
|
|
50
|
-
* `toolbarExtraWidget` has no effect if this is set.
|
|
60
|
+
* The AppBar component to be used in the scaffold.
|
|
51
61
|
*/
|
|
52
62
|
FireCMSAppBar?: React.ComponentType<FireCMSAppBarProps<ExtraAppbarProps>>;
|
|
53
63
|
|
|
@@ -78,8 +88,7 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
|
78
88
|
logo,
|
|
79
89
|
includeDrawer = true,
|
|
80
90
|
autoOpenDrawer,
|
|
81
|
-
|
|
82
|
-
drawerProps,
|
|
91
|
+
drawer = <DefaultDrawer/>,
|
|
83
92
|
FireCMSAppBar = DefaultFireCMSAppBar,
|
|
84
93
|
fireCMSAppBarProps,
|
|
85
94
|
} = props;
|
|
@@ -92,60 +101,65 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
|
92
101
|
const setOnHoverTrue = useCallback(() => setOnHover(true), []);
|
|
93
102
|
const setOnHoverFalse = useCallback(() => setOnHover(false), []);
|
|
94
103
|
|
|
104
|
+
const handleDrawerOpen = useCallback(() => {
|
|
105
|
+
setDrawerOpen(true);
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
95
108
|
const handleDrawerClose = useCallback(() => {
|
|
96
109
|
setDrawerOpen(false);
|
|
97
110
|
}, []);
|
|
98
111
|
|
|
99
112
|
const computedDrawerOpen: boolean = drawerOpen || Boolean(largeLayout && autoOpenDrawer && onHover);
|
|
113
|
+
|
|
100
114
|
return (
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
</
|
|
147
|
-
</
|
|
148
|
-
</
|
|
115
|
+
<DrawerContext.Provider value={{
|
|
116
|
+
hovered: onHover,
|
|
117
|
+
drawerOpen: computedDrawerOpen,
|
|
118
|
+
closeDrawer: handleDrawerClose,
|
|
119
|
+
openDrawer: handleDrawerOpen,
|
|
120
|
+
autoOpenDrawer
|
|
121
|
+
}}>
|
|
122
|
+
<div
|
|
123
|
+
className="flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden"
|
|
124
|
+
style={{
|
|
125
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
126
|
+
paddingLeft: "env(safe-area-inset-left)",
|
|
127
|
+
paddingRight: "env(safe-area-inset-right)",
|
|
128
|
+
paddingBottom: "env(safe-area-inset-bottom)",
|
|
129
|
+
height: "100dvh"
|
|
130
|
+
}}>
|
|
131
|
+
|
|
132
|
+
<FireCMSAppBar title={name}
|
|
133
|
+
includeDrawer={includeDrawer}
|
|
134
|
+
logo={logo}
|
|
135
|
+
drawerOpen={computedDrawerOpen}
|
|
136
|
+
{...fireCMSAppBarProps}/>
|
|
137
|
+
<DrawerWrapper
|
|
138
|
+
displayed={includeDrawer}
|
|
139
|
+
onMouseEnter={setOnHoverTrue}
|
|
140
|
+
onMouseMove={setOnHoverTrue}
|
|
141
|
+
onMouseLeave={setOnHoverFalse}
|
|
142
|
+
open={computedDrawerOpen}
|
|
143
|
+
logo={logo}
|
|
144
|
+
hovered={onHover}
|
|
145
|
+
setDrawerOpen={setDrawerOpen}>
|
|
146
|
+
{includeDrawer && drawer}
|
|
147
|
+
</DrawerWrapper>
|
|
148
|
+
|
|
149
|
+
<main
|
|
150
|
+
className="flex flex-col flex-grow overflow-auto">
|
|
151
|
+
<DrawerHeader/>
|
|
152
|
+
<div
|
|
153
|
+
className={cls(defaultBorderMixin, "flex-grow overflow-auto lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid m-0 mt-1")}>
|
|
154
|
+
|
|
155
|
+
<ErrorBoundary>
|
|
156
|
+
{children}
|
|
157
|
+
</ErrorBoundary>
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
</main>
|
|
161
|
+
</div>
|
|
162
|
+
</DrawerContext.Provider>
|
|
149
163
|
);
|
|
150
164
|
},
|
|
151
165
|
equal
|
|
@@ -157,7 +171,7 @@ const DrawerHeader = () => {
|
|
|
157
171
|
);
|
|
158
172
|
};
|
|
159
173
|
|
|
160
|
-
function
|
|
174
|
+
function DrawerWrapper(props: {
|
|
161
175
|
children: React.ReactNode,
|
|
162
176
|
displayed: boolean,
|
|
163
177
|
open: boolean,
|
|
@@ -204,7 +218,7 @@ function StyledDrawer(props: {
|
|
|
204
218
|
transition: "padding 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms",
|
|
205
219
|
padding: props.open ? "32px 144px 0px 24px" : "72px 16px 0px"
|
|
206
220
|
}}
|
|
207
|
-
className={
|
|
221
|
+
className={cls("cursor-pointer")}>
|
|
208
222
|
|
|
209
223
|
<Tooltip title={"Home"}
|
|
210
224
|
sideOffset={20}
|
|
@@ -214,7 +228,7 @@ function StyledDrawer(props: {
|
|
|
214
228
|
{props.logo
|
|
215
229
|
? <img src={props.logo}
|
|
216
230
|
alt="Logo"
|
|
217
|
-
className={
|
|
231
|
+
className={cls("max-w-full max-h-full",
|
|
218
232
|
props.open ?? "w-[112px] h-[112px]")}/>
|
|
219
233
|
: <FireCMSLogo/>}
|
|
220
234
|
|
|
@@ -331,7 +331,7 @@ export function getFieldConfig(property: Property | ResolvedProperty, propertyCo
|
|
|
331
331
|
}
|
|
332
332
|
const defaultFieldConfig = DEFAULT_FIELD_CONFIGS[defaultFieldId];
|
|
333
333
|
const customField = fieldId ? propertyConfigs[fieldId] : undefined;
|
|
334
|
-
return mergeDeep(defaultFieldConfig ?? {}, customField ?? {});
|
|
334
|
+
return mergeDeep(defaultFieldConfig ?? {}, customField ?? {} as PropertyConfig);
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
export function getDefaultFieldId(property: Property | ResolvedProperty) {
|
|
@@ -359,8 +359,7 @@ export function getDefaultFieldId(property: Property | ResolvedProperty) {
|
|
|
359
359
|
} else if (property.dataType === "map") {
|
|
360
360
|
if (property.keyValue)
|
|
361
361
|
return "key_value";
|
|
362
|
-
|
|
363
|
-
return "group";
|
|
362
|
+
return "group";
|
|
364
363
|
} else if (property.dataType === "array") {
|
|
365
364
|
const of = (property as ArrayProperty).of;
|
|
366
365
|
const oneOf = (property as ArrayProperty).oneOf;
|
package/src/core/index.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export * from "./FireCMS";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
export { Scaffold } from "./Scaffold";
|
|
3
|
+
export * from "./Scaffold";
|
|
5
4
|
|
|
6
|
-
export
|
|
7
|
-
export
|
|
5
|
+
export * from "./Drawer";
|
|
6
|
+
export * from "./DrawerNavigationItem";
|
|
8
7
|
|
|
9
8
|
export * from "./field_configs";
|
|
10
9
|
|
package/src/form/EntityForm.tsx
CHANGED
|
@@ -35,12 +35,9 @@ import {
|
|
|
35
35
|
} from "../hooks";
|
|
36
36
|
import { ErrorFocus } from "./components/ErrorFocus";
|
|
37
37
|
import { CustomIdField } from "./components/CustomIdField";
|
|
38
|
-
import { Alert, Button,
|
|
39
|
-
import { ErrorBoundary } from "../components";
|
|
40
|
-
import {
|
|
41
|
-
copyEntityAction,
|
|
42
|
-
deleteEntityAction
|
|
43
|
-
} from "../components/EntityCollectionTable/internal/default_entity_actions";
|
|
38
|
+
import { Alert, Button, CircularProgress, cls, DialogActions, IconButton, Tooltip, Typography } from "@firecms/ui";
|
|
39
|
+
import { CircularProgressCenter, ErrorBoundary } from "../components";
|
|
40
|
+
import { copyEntityAction, deleteEntityAction } from "../components/common/default_entity_actions";
|
|
44
41
|
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
45
42
|
import { ValidationError } from "yup";
|
|
46
43
|
import { PropertyIdCopyTooltipContent } from "../components/PropertyIdCopyTooltipContent";
|
|
@@ -135,12 +132,13 @@ export type EntityFormSaveParams<M extends Record<string, any>> = {
|
|
|
135
132
|
* @constructor
|
|
136
133
|
* @group Components
|
|
137
134
|
*/
|
|
138
|
-
export const EntityForm =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
export const EntityForm = EntityFormInternal;
|
|
136
|
+
// export const EntityForm = React.memo<EntityFormProps<any>>(EntityFormInternal,
|
|
137
|
+
// (a: EntityFormProps<any>, b: EntityFormProps<any>) => {
|
|
138
|
+
// return a.status === b.status &&
|
|
139
|
+
// a.path === b.path &&
|
|
140
|
+
// equal(a.entity?.values, b.entity?.values);
|
|
141
|
+
// }) as typeof EntityFormInternal;
|
|
144
142
|
|
|
145
143
|
function getDataSourceEntityValues<M extends object>(initialResolvedCollection: ResolvedEntityCollection,
|
|
146
144
|
status: "new" | "existing" | "copy",
|
|
@@ -188,7 +186,7 @@ function EntityFormInternal<M extends Record<string, any>>({
|
|
|
188
186
|
path,
|
|
189
187
|
values: entity?.values,
|
|
190
188
|
fields: customizationController.propertyConfigs
|
|
191
|
-
}), [entity?.values, path]);
|
|
189
|
+
}), [entity?.values, path, customizationController.propertyConfigs]);
|
|
192
190
|
|
|
193
191
|
const mustSetCustomId: boolean = (status === "new" || status === "copy") &&
|
|
194
192
|
(Boolean(initialResolvedCollection.customId) && initialResolvedCollection.customId !== "optional");
|
|
@@ -415,7 +413,8 @@ function EntityFormInternal<M extends Record<string, any>>({
|
|
|
415
413
|
const pluginActions: React.ReactNode[] = [];
|
|
416
414
|
|
|
417
415
|
const formContext: FormContext<M> = {
|
|
418
|
-
|
|
416
|
+
// @ts-ignore
|
|
417
|
+
setFieldValue: useCallback(formex.setFieldValue, []),
|
|
419
418
|
values: formex.values,
|
|
420
419
|
collection: resolvedCollection,
|
|
421
420
|
entityId,
|
|
@@ -423,12 +422,14 @@ function EntityFormInternal<M extends Record<string, any>>({
|
|
|
423
422
|
save
|
|
424
423
|
};
|
|
425
424
|
|
|
425
|
+
const submittedFormContext = useRef<FormContext<M> | null>(null);
|
|
426
426
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
427
427
|
useEffect(() => {
|
|
428
|
-
if (onFormContextChange) {
|
|
428
|
+
if (onFormContextChange && !formContextsEqual(submittedFormContext.current ?? undefined, formContext)) {
|
|
429
429
|
onFormContextChange(formContext);
|
|
430
|
+
submittedFormContext.current = formContext;
|
|
430
431
|
}
|
|
431
|
-
}, [
|
|
432
|
+
}, [formContext, onFormContextChange]);
|
|
432
433
|
|
|
433
434
|
if (plugins && inputCollection) {
|
|
434
435
|
const actionProps: PluginFormActionProps = {
|
|
@@ -452,7 +453,7 @@ function EntityFormInternal<M extends Record<string, any>>({
|
|
|
452
453
|
<div className="h-full overflow-auto">
|
|
453
454
|
|
|
454
455
|
{pluginActions.length > 0 && <div
|
|
455
|
-
className={
|
|
456
|
+
className={cls("w-full flex justify-end items-center sticky top-0 right-0 left-0 z-10 bg-opacity-60 bg-slate-200 dark:bg-opacity-60 dark:bg-slate-800 backdrop-blur-md")}>
|
|
456
457
|
{pluginActions}
|
|
457
458
|
</div>}
|
|
458
459
|
|
|
@@ -670,10 +671,10 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
670
671
|
</IconButton>
|
|
671
672
|
))}
|
|
672
673
|
</div>}
|
|
673
|
-
|
|
674
|
+
{isSubmitting && <CircularProgress size={"small"}/>}
|
|
674
675
|
<Button
|
|
675
676
|
variant="text"
|
|
676
|
-
disabled={disabled}
|
|
677
|
+
disabled={disabled || isSubmitting}
|
|
677
678
|
type="reset"
|
|
678
679
|
>
|
|
679
680
|
{status === "existing" ? "Discard" : "Clear"}
|
|
@@ -683,7 +684,7 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
683
684
|
variant="text"
|
|
684
685
|
color="primary"
|
|
685
686
|
type="submit"
|
|
686
|
-
disabled={disabled}
|
|
687
|
+
disabled={disabled || isSubmitting}
|
|
687
688
|
onClick={() => {
|
|
688
689
|
closeAfterSaveRef.current = false;
|
|
689
690
|
}}
|
|
@@ -697,7 +698,7 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
697
698
|
variant="filled"
|
|
698
699
|
color="primary"
|
|
699
700
|
type="submit"
|
|
700
|
-
disabled={disabled}
|
|
701
|
+
disabled={disabled || isSubmitting}
|
|
701
702
|
onClick={() => {
|
|
702
703
|
closeAfterSaveRef.current = true;
|
|
703
704
|
}}
|
|
@@ -726,3 +727,10 @@ export function yupToFormErrors(yupError: ValidationError): Record<string, any>
|
|
|
726
727
|
}
|
|
727
728
|
return errors;
|
|
728
729
|
}
|
|
730
|
+
|
|
731
|
+
function formContextsEqual(a: FormContext<any> | undefined, b: FormContext<any> | undefined): boolean {
|
|
732
|
+
return a?.path === b?.path &&
|
|
733
|
+
a?.entityId === b?.entityId &&
|
|
734
|
+
equal(a?.values, b?.values) &&
|
|
735
|
+
equal(a?.collection, b?.collection);
|
|
736
|
+
}
|
|
@@ -92,7 +92,6 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
|
|
|
92
92
|
let Component: ComponentType<FieldProps<T>> | undefined;
|
|
93
93
|
const resolvedProperty: ResolvedProperty<T> | null = resolveProperty({
|
|
94
94
|
propertyKey,
|
|
95
|
-
propertyValue: fieldProps.field.value,
|
|
96
95
|
propertyOrBuilder: property,
|
|
97
96
|
values: fieldProps.form.values,
|
|
98
97
|
path: context.path,
|
|
@@ -116,7 +115,6 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
|
|
|
116
115
|
}
|
|
117
116
|
const configProperty = resolveProperty({
|
|
118
117
|
propertyOrBuilder: propertyConfig.property,
|
|
119
|
-
propertyValue: fieldProps.field.value,
|
|
120
118
|
values: fieldProps.form.values,
|
|
121
119
|
path: context.path,
|
|
122
120
|
entityId: context.entityId,
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { Entity, EntityCollection, ResolvedStringProperty } from "../../types";
|
|
4
4
|
import { PreviewSize, PropertyPreview } from "../../preview";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { cls, IconButton, paperMixin, RemoveIcon, Tooltip } from "@firecms/ui";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
|
|
9
9
|
interface StorageItemPreviewProps {
|
|
@@ -29,7 +29,7 @@ export function StorageItemPreview({
|
|
|
29
29
|
}: StorageItemPreviewProps) {
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<div className={
|
|
32
|
+
<div className={cls(paperMixin,
|
|
33
33
|
"relative m-4 border-box flex items-center justify-center",
|
|
34
34
|
size === "medium" ? "min-w-[220px] min-h-[220px] max-w-[220px]" : "min-w-[118px] min-h-[118px] max-w-[118px]")}>
|
|
35
35
|
|
|
@@ -3,7 +3,7 @@ import React, { useCallback } from "react";
|
|
|
3
3
|
import { useSnackbarController, useStorageSource } from "../../hooks";
|
|
4
4
|
import { StorageFieldItem } from "../../util/useStorageUploadController";
|
|
5
5
|
import { ErrorView } from "../../components";
|
|
6
|
-
import {
|
|
6
|
+
import { cls, paperMixin, Skeleton } from "@firecms/ui";
|
|
7
7
|
import { EntityCollection, StorageSource } from "../../types";
|
|
8
8
|
|
|
9
9
|
export interface StorageUploadItemProps {
|
|
@@ -49,7 +49,7 @@ export function StorageUploadProgress({
|
|
|
49
49
|
metadata
|
|
50
50
|
})
|
|
51
51
|
.then(async ({ path }) => {
|
|
52
|
-
console.debug("Upload successful");
|
|
52
|
+
console.debug("Upload successful", path);
|
|
53
53
|
await onFileUploadComplete(path, entry, metadata);
|
|
54
54
|
if (mounted.current)
|
|
55
55
|
setLoading(false);
|
|
@@ -88,7 +88,7 @@ export function StorageUploadProgress({
|
|
|
88
88
|
}
|
|
89
89
|
return (
|
|
90
90
|
|
|
91
|
-
<div className={
|
|
91
|
+
<div className={cls(paperMixin,
|
|
92
92
|
"relative m-4 border-box flex items-center justify-center",
|
|
93
93
|
`min-w-[${imageSize}px] min-h-[${imageSize}px]`)}>
|
|
94
94
|
|
|
@@ -6,7 +6,7 @@ import { ErrorView } from "../../components";
|
|
|
6
6
|
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
7
7
|
|
|
8
8
|
import { useNavigationController, useReferenceDialog } from "../../hooks";
|
|
9
|
-
import { Button,
|
|
9
|
+
import { Button, cls, ExpandablePanel, fieldBackgroundMixin } from "@firecms/ui";
|
|
10
10
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
11
11
|
|
|
12
12
|
type ArrayOfReferencesFieldProps = FieldProps<EntityReference[]>;
|
|
@@ -88,6 +88,8 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
88
88
|
onClick={onEntryClick}
|
|
89
89
|
hover={!disabled}
|
|
90
90
|
reference={entryValue}
|
|
91
|
+
includeId={ofProperty.includeId}
|
|
92
|
+
includeEntityLink={ofProperty.includeEntityLink}
|
|
91
93
|
/>
|
|
92
94
|
);
|
|
93
95
|
}, [ofProperty.path, ofProperty.previewProperties, value]);
|
|
@@ -130,7 +132,7 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
130
132
|
{!tableMode &&
|
|
131
133
|
<ExpandablePanel
|
|
132
134
|
titleClassName={fieldBackgroundMixin}
|
|
133
|
-
className={
|
|
135
|
+
className={cls("px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2", fieldBackgroundMixin)}
|
|
134
136
|
initiallyExpanded={expanded}
|
|
135
137
|
title={title}>
|
|
136
138
|
{body}
|
|
@@ -8,7 +8,7 @@ import { EnumValuesChip } from "../../preview";
|
|
|
8
8
|
import { FieldProps, FormContext, PropertyFieldBindingProps, PropertyOrBuilder } from "../../types";
|
|
9
9
|
import { getDefaultValueFor, getIconForProperty, } from "../../util";
|
|
10
10
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
11
|
-
import {
|
|
11
|
+
import { cls, ExpandablePanel, paperMixin, Select, SelectItem, Typography } from "@firecms/ui";
|
|
12
12
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -193,7 +193,7 @@ function BlockEntry({
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
return (
|
|
196
|
-
<div className={
|
|
196
|
+
<div className={cls(paperMixin, "bg-transparent p-4 my-4 py-8")}>
|
|
197
197
|
|
|
198
198
|
<Field
|
|
199
199
|
name={typeFieldName}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ArrowDropDownIcon,
|
|
9
9
|
BooleanSwitchWithLabel,
|
|
10
10
|
Button,
|
|
11
|
-
|
|
11
|
+
cls,
|
|
12
12
|
DateTimeField,
|
|
13
13
|
defaultBorderMixin,
|
|
14
14
|
ExpandablePanel,
|
|
@@ -316,7 +316,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
316
316
|
}}/>;
|
|
317
317
|
} else if (dataType === "array") {
|
|
318
318
|
return <div
|
|
319
|
-
className={
|
|
319
|
+
className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
320
320
|
<ArrayContainer value={entryValue}
|
|
321
321
|
newDefaultEntry={""}
|
|
322
322
|
droppableId={rowId.toString()}
|
|
@@ -349,7 +349,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
349
349
|
</div>;
|
|
350
350
|
} else if (dataType === "map") {
|
|
351
351
|
return <div
|
|
352
|
-
className={
|
|
352
|
+
className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
353
353
|
<MapEditView value={entryValue}
|
|
354
354
|
fieldName={fieldKey}
|
|
355
355
|
setValue={(updatedValue) => {
|
|
@@ -482,7 +482,7 @@ function ArrayKeyValueRow<T>({
|
|
|
482
482
|
Arrays of arrays are not supported.
|
|
483
483
|
</Typography>;
|
|
484
484
|
} else if (dataType === "map") {
|
|
485
|
-
return <div className={
|
|
485
|
+
return <div className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
486
486
|
<MapEditView value={entryValue}
|
|
487
487
|
setValue={(updatedValue) => {
|
|
488
488
|
setValue(updatedValue);
|
|
@@ -8,7 +8,7 @@ import { FieldHelperText, LabelWithIcon } from "../components";
|
|
|
8
8
|
import { FieldProps } from "../../types";
|
|
9
9
|
import { getIconForProperty } from "../../util";
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
cls,
|
|
12
12
|
fieldBackgroundDisabledMixin,
|
|
13
13
|
fieldBackgroundHoverMixin,
|
|
14
14
|
fieldBackgroundMixin,
|
|
@@ -81,7 +81,7 @@ export function MarkdownFieldBinding({
|
|
|
81
81
|
</Typography>}
|
|
82
82
|
|
|
83
83
|
<MdEditor value={internalValue ?? ""}
|
|
84
|
-
className={
|
|
84
|
+
className={cls(fieldBackgroundMixin,
|
|
85
85
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
|
86
86
|
"text-base")}
|
|
87
87
|
readOnly={disabled}
|
|
@@ -6,7 +6,7 @@ import { PropertyPreview } from "../../preview";
|
|
|
6
6
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
import { getIconForProperty } from "../../util";
|
|
9
|
-
import {
|
|
9
|
+
import { cls, paperMixin } from "@firecms/ui";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -47,7 +47,7 @@ export function ReadOnlyFieldBinding({
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
<div
|
|
50
|
-
className={
|
|
50
|
+
className={cls(paperMixin, "min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar")}>
|
|
51
51
|
|
|
52
52
|
<ErrorBoundary>
|
|
53
53
|
<PropertyPreview propertyKey={propertyKey}
|
|
@@ -27,19 +27,19 @@ export function ReferenceFieldBinding<M extends Record<string, any>>(props: Fiel
|
|
|
27
27
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function ReferenceFieldBindingInternal
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
function ReferenceFieldBindingInternal({
|
|
31
|
+
value,
|
|
32
|
+
setValue,
|
|
33
|
+
error,
|
|
34
|
+
showError,
|
|
35
|
+
isSubmitting,
|
|
36
|
+
disabled,
|
|
37
|
+
touched,
|
|
38
|
+
autoFocus,
|
|
39
|
+
property,
|
|
40
|
+
includeDescription,
|
|
41
|
+
context
|
|
42
|
+
}: FieldProps<EntityReference>) {
|
|
43
43
|
if (!property.path) {
|
|
44
44
|
throw new Error("Property path is required for ReferenceFieldBinding");
|
|
45
45
|
}
|
|
@@ -99,6 +99,8 @@ function ReferenceFieldBindingInternal<M extends Record<string, any>>({
|
|
|
99
99
|
size={"medium"}
|
|
100
100
|
onClick={disabled || isSubmitting ? undefined : onEntryClick}
|
|
101
101
|
reference={value}
|
|
102
|
+
includeEntityLink={property.includeEntityLink}
|
|
103
|
+
includeId={property.includeId}
|
|
102
104
|
/>}
|
|
103
105
|
|
|
104
106
|
{!value && <div className="justify-center text-left">
|
|
@@ -4,7 +4,7 @@ import { EnumType, FieldProps } from "../../types";
|
|
|
4
4
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
5
5
|
import { EnumValuesChip } from "../../preview";
|
|
6
6
|
import { getIconForProperty } from "../../util";
|
|
7
|
-
import { ClearIcon,
|
|
7
|
+
import { ClearIcon, cls, IconButton, Select, SelectItem } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
9
|
|
|
10
10
|
type SelectProps<T extends EnumType> = FieldProps<T>;
|
|
@@ -48,10 +48,10 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
48
48
|
<>
|
|
49
49
|
|
|
50
50
|
<Select
|
|
51
|
-
value={value ? value.toString() : ""}
|
|
51
|
+
value={value !== undefined && value != null ? value.toString() : ""}
|
|
52
52
|
disabled={disabled}
|
|
53
53
|
position="item-aligned"
|
|
54
|
-
inputClassName={
|
|
54
|
+
inputClassName={cls("w-full")}
|
|
55
55
|
label={<LabelWithIcon icon={getIconForProperty(property, "small")}
|
|
56
56
|
required={property.validation?.required}
|
|
57
57
|
title={property.name}
|