@firecms/core 3.0.0-beta.7 → 3.0.0-beta.9
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/app/AppBar.d.ts +12 -0
- package/dist/app/Drawer.d.ts +17 -0
- package/dist/app/Scaffold.d.ts +30 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/useApp.d.ts +16 -0
- package/dist/components/ArrayContainer.d.ts +2 -1
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +14 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +3 -8
- package/dist/core/DefaultDrawer.d.ts +19 -0
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +18 -4
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +3 -3
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/StorageItemPreview.d.ts +4 -4
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -5
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -5
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +14434 -11300
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19987 -587
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +6 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collections.d.ts +26 -3
- package/dist/types/datasource.d.ts +53 -30
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +47 -41
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/plugins.d.ts +11 -3
- package/dist/types/properties.d.ts +25 -20
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/storage.d.ts +75 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icons.d.ts +3 -2
- package/dist/util/index.d.ts +1 -0
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/property_utils.d.ts +1 -1
- package/dist/util/resolutions.d.ts +15 -1
- package/dist/util/storage.d.ts +23 -2
- package/dist/util/useStorageUploadController.d.ts +3 -3
- package/package.json +18 -29
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +25 -0
- package/src/{core → app}/Scaffold.tsx +71 -122
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +32 -0
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +11 -18
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +33 -29
- package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
- package/src/components/EntityPreview.tsx +30 -31
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/HomePage/DefaultHomePage.tsx +24 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/PropertyIdCopyTooltip.tsx +48 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
- package/src/components/SearchIconsView.tsx +5 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -4
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
- package/src/components/VirtualTable/VirtualTable.tsx +36 -10
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +17 -8
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
- package/src/components/common/useTableSearchHelper.ts +53 -12
- package/src/components/index.tsx +2 -1
- package/src/contexts/DialogsProvider.tsx +2 -2
- package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +28 -30
- package/src/core/DefaultDrawer.tsx +183 -0
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +712 -145
- package/src/core/EntitySidePanel.tsx +0 -1
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +4 -4
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/core/index.tsx +2 -2
- package/src/form/PropertyFieldBinding.tsx +53 -19
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +4 -4
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/components/LabelWithIcon.tsx +27 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +20 -10
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +26 -15
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +28 -25
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +48 -42
- package/src/form/field_bindings/MapFieldBinding.tsx +17 -17
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -14
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +32 -19
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +33 -43
- package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
- package/src/form/index.tsx +4 -9
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/form/validation.ts +1 -17
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useDataSource.tsx +11 -3
- package/src/hooks/useBuildNavigationController.tsx +10 -3
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/index.ts +1 -0
- package/src/internal/useBuildDataSource.ts +69 -74
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +17 -4
- package/src/internal/useUnsavedChangesDialog.tsx +3 -1
- package/src/preview/PropertyPreview.tsx +7 -4
- package/src/preview/PropertyPreviewProps.tsx +7 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +24 -34
- package/src/preview/components/ReferencePreview.tsx +2 -12
- package/src/preview/components/StorageThumbnail.tsx +5 -1
- package/src/preview/components/UrlComponentPreview.tsx +44 -11
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +2 -2
- package/src/types/auth.tsx +2 -2
- package/src/types/collections.ts +29 -4
- package/src/types/customization_controller.tsx +0 -1
- package/src/types/datasource.ts +62 -43
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +51 -45
- package/src/types/navigation.ts +1 -0
- package/src/types/plugins.tsx +12 -3
- package/src/types/properties.ts +25 -19
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +5 -4
- package/src/util/icon_list.ts +14 -9
- package/src/util/icons.tsx +8 -2
- package/src/util/index.ts +1 -0
- package/src/util/objects.ts +17 -7
- package/src/util/permissions.ts +1 -0
- package/src/util/plurals.ts +0 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/references.ts +3 -0
- package/src/util/resolutions.ts +43 -11
- package/src/util/storage.ts +79 -21
- package/src/util/useStorageUploadController.tsx +33 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/core/Drawer.d.ts +0 -16
- package/dist/core/Scaffold.d.ts +0 -51
- package/dist/form/EntityForm.d.ts +0 -77
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/core/Drawer.tsx +0 -139
- package/src/form/EntityForm.tsx +0 -736
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
|
@@ -1,55 +1,16 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useCallback } from "react";
|
|
2
|
-
import equal from "react-fast-compare"
|
|
3
|
-
import { Link } from "react-router-dom";
|
|
4
|
-
|
|
5
|
-
import { Drawer as DefaultDrawer, DrawerProps } from "./Drawer";
|
|
6
|
-
import { useLargeLayout, useNavigationController } from "../hooks";
|
|
7
|
-
import { ErrorBoundary, FireCMSAppBar as DefaultFireCMSAppBar, FireCMSAppBarProps, FireCMSLogo } from "../components";
|
|
8
2
|
import { ChevronLeftIcon, cls, defaultBorderMixin, IconButton, MenuIcon, Sheet, Tooltip } from "@firecms/ui";
|
|
3
|
+
import equal from "react-fast-compare"
|
|
4
|
+
import { useLargeLayout } from "../hooks";
|
|
5
|
+
import { ErrorBoundary } from "../components";
|
|
6
|
+
import { AppContext } from "./useApp";
|
|
9
7
|
|
|
10
8
|
export const DRAWER_WIDTH = 280;
|
|
11
9
|
|
|
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
|
-
|
|
28
10
|
/**
|
|
29
11
|
* @group Core
|
|
30
12
|
*/
|
|
31
|
-
export interface ScaffoldProps
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Name of the app, displayed as the main title and in the tab title
|
|
35
|
-
*/
|
|
36
|
-
name?: React.ReactNode;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Logo to be displayed in the drawer of the CMS
|
|
40
|
-
*/
|
|
41
|
-
logo?: string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Whether to include the drawer in the scaffold
|
|
45
|
-
*/
|
|
46
|
-
includeDrawer?: boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* You can define a custom drawer to be displayed in the scaffold.
|
|
50
|
-
* Use the hook `useDrawer` to access the context values.
|
|
51
|
-
*/
|
|
52
|
-
drawer?: React.ReactNode;
|
|
13
|
+
export interface ScaffoldProps {
|
|
53
14
|
|
|
54
15
|
/**
|
|
55
16
|
* Open the drawer on hover
|
|
@@ -57,15 +18,14 @@ export interface ScaffoldProps<ExtraAppbarProps = object> {
|
|
|
57
18
|
autoOpenDrawer?: boolean;
|
|
58
19
|
|
|
59
20
|
/**
|
|
60
|
-
*
|
|
21
|
+
* Logo to be displayed in the top bar and drawer.
|
|
22
|
+
* Note that this has no effect if you are using a custom AppBar or Drawer.
|
|
61
23
|
*/
|
|
62
|
-
|
|
24
|
+
logo?: string;
|
|
63
25
|
|
|
64
|
-
|
|
65
|
-
* Additional props passed to the custom AppBar
|
|
66
|
-
*/
|
|
67
|
-
fireCMSAppBarProps?: Partial<FireCMSAppBarProps> & ExtraAppbarProps;
|
|
26
|
+
className?: string;
|
|
68
27
|
|
|
28
|
+
style?: React.CSSProperties;
|
|
69
29
|
}
|
|
70
30
|
|
|
71
31
|
/**
|
|
@@ -76,7 +36,7 @@ export interface ScaffoldProps<ExtraAppbarProps = object> {
|
|
|
76
36
|
* This component needs a parent {@link FireCMS}
|
|
77
37
|
*
|
|
78
38
|
* @param props
|
|
79
|
-
|
|
39
|
+
|
|
80
40
|
* @group Core
|
|
81
41
|
*/
|
|
82
42
|
export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
@@ -84,15 +44,23 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
|
84
44
|
|
|
85
45
|
const {
|
|
86
46
|
children,
|
|
87
|
-
name,
|
|
88
|
-
logo,
|
|
89
|
-
includeDrawer = true,
|
|
90
47
|
autoOpenDrawer,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
48
|
+
logo,
|
|
49
|
+
className,
|
|
50
|
+
style
|
|
94
51
|
} = props;
|
|
95
52
|
|
|
53
|
+
const drawerChildren = React.Children.toArray(children).filter((child: any) => child.type.componentType === "Drawer");
|
|
54
|
+
if (drawerChildren.length > 1) {
|
|
55
|
+
throw Error("Only one Drawer component is allowed in Scaffold");
|
|
56
|
+
}
|
|
57
|
+
const appBarChildren = React.Children.toArray(children).filter((child: any) => child.type.componentType === "AppBar");
|
|
58
|
+
if (appBarChildren.length > 1) {
|
|
59
|
+
throw Error("Only one AppBar component is allowed in Scaffold");
|
|
60
|
+
}
|
|
61
|
+
const otherChildren = React.Children.toArray(children)
|
|
62
|
+
.filter((child: any) => child.type.componentType !== "Drawer" && child.type.componentType !== "AppBar");
|
|
63
|
+
const includeDrawer = drawerChildren.length > 0;
|
|
96
64
|
const largeLayout = useLargeLayout();
|
|
97
65
|
|
|
98
66
|
const [drawerOpen, setDrawerOpen] = React.useState(false);
|
|
@@ -111,55 +79,57 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
|
111
79
|
|
|
112
80
|
const computedDrawerOpen: boolean = drawerOpen || Boolean(largeLayout && autoOpenDrawer && onHover);
|
|
113
81
|
|
|
82
|
+
const hasAppBar = Boolean(appBarChildren.length > 0);
|
|
114
83
|
return (
|
|
115
|
-
<
|
|
116
|
-
|
|
84
|
+
<AppContext.Provider value={{
|
|
85
|
+
logo,
|
|
86
|
+
hasDrawer: includeDrawer,
|
|
87
|
+
drawerHovered: onHover,
|
|
117
88
|
drawerOpen: computedDrawerOpen,
|
|
118
89
|
closeDrawer: handleDrawerClose,
|
|
119
90
|
openDrawer: handleDrawerOpen,
|
|
120
91
|
autoOpenDrawer
|
|
121
92
|
}}>
|
|
122
93
|
<div
|
|
123
|
-
className="flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden"
|
|
94
|
+
className={cls("flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden", className)}
|
|
124
95
|
style={{
|
|
125
96
|
paddingTop: "env(safe-area-inset-top)",
|
|
126
97
|
paddingLeft: "env(safe-area-inset-left)",
|
|
127
98
|
paddingRight: "env(safe-area-inset-right)",
|
|
128
99
|
paddingBottom: "env(safe-area-inset-bottom)",
|
|
129
|
-
height: "100dvh"
|
|
100
|
+
height: "100dvh",
|
|
101
|
+
...style
|
|
130
102
|
}}>
|
|
131
103
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
logo={logo}
|
|
135
|
-
drawerOpen={computedDrawerOpen}
|
|
136
|
-
{...fireCMSAppBarProps}/>
|
|
104
|
+
{appBarChildren}
|
|
105
|
+
|
|
137
106
|
<DrawerWrapper
|
|
138
107
|
displayed={includeDrawer}
|
|
139
108
|
onMouseEnter={setOnHoverTrue}
|
|
140
109
|
onMouseMove={setOnHoverTrue}
|
|
141
110
|
onMouseLeave={setOnHoverFalse}
|
|
142
111
|
open={computedDrawerOpen}
|
|
143
|
-
logo={logo}
|
|
144
112
|
hovered={onHover}
|
|
145
113
|
setDrawerOpen={setDrawerOpen}>
|
|
146
|
-
{includeDrawer &&
|
|
114
|
+
{includeDrawer && drawerChildren}
|
|
147
115
|
</DrawerWrapper>
|
|
148
116
|
|
|
149
117
|
<main
|
|
150
118
|
className="flex flex-col flex-grow overflow-auto">
|
|
151
|
-
<DrawerHeader/>
|
|
119
|
+
{hasAppBar && <DrawerHeader/>}
|
|
152
120
|
<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"
|
|
121
|
+
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", {
|
|
122
|
+
"lg:mt-4": !hasAppBar
|
|
123
|
+
})}>
|
|
154
124
|
|
|
155
125
|
<ErrorBoundary>
|
|
156
|
-
{
|
|
126
|
+
{otherChildren}
|
|
157
127
|
</ErrorBoundary>
|
|
158
128
|
|
|
159
129
|
</div>
|
|
160
130
|
</main>
|
|
161
131
|
</div>
|
|
162
|
-
</
|
|
132
|
+
</AppContext.Provider>
|
|
163
133
|
);
|
|
164
134
|
},
|
|
165
135
|
equal
|
|
@@ -183,8 +153,6 @@ function DrawerWrapper(props: {
|
|
|
183
153
|
onMouseLeave: () => void
|
|
184
154
|
}) {
|
|
185
155
|
|
|
186
|
-
const navigation = useNavigationController();
|
|
187
|
-
|
|
188
156
|
const width = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);
|
|
189
157
|
const innerDrawer = <div
|
|
190
158
|
className={"relative h-full no-scrollbar overflow-y-auto overflow-x-hidden"}
|
|
@@ -198,44 +166,35 @@ function DrawerWrapper(props: {
|
|
|
198
166
|
<Tooltip title="Open menu"
|
|
199
167
|
side="right"
|
|
200
168
|
sideOffset={12}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
169
|
+
asChild={true}>
|
|
170
|
+
<div
|
|
171
|
+
className="ml-2 fixed top-2 left-3 !bg-gray-50 dark:!bg-gray-900 rounded-full w-fit z-20">
|
|
172
|
+
<IconButton
|
|
173
|
+
color="inherit"
|
|
174
|
+
aria-label="Open menu"
|
|
175
|
+
className="sticky top-2 left-3 "
|
|
176
|
+
onClick={() => props.setDrawerOpen(true)}
|
|
177
|
+
size="large"
|
|
178
|
+
>
|
|
179
|
+
<MenuIcon/>
|
|
180
|
+
</IconButton>
|
|
181
|
+
</div>
|
|
212
182
|
</Tooltip>
|
|
213
183
|
)}
|
|
214
184
|
|
|
215
|
-
<div
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
<Link
|
|
227
|
-
to={navigation.basePath}>
|
|
228
|
-
{props.logo
|
|
229
|
-
? <img src={props.logo}
|
|
230
|
-
alt="Logo"
|
|
231
|
-
className={cls("max-w-full max-h-full",
|
|
232
|
-
props.open ?? "w-[112px] h-[112px]")}/>
|
|
233
|
-
: <FireCMSLogo/>}
|
|
234
|
-
|
|
235
|
-
</Link>
|
|
236
|
-
</Tooltip>
|
|
237
|
-
</div>
|
|
185
|
+
<div
|
|
186
|
+
className={`z-20 absolute right-0 top-4 ${
|
|
187
|
+
props.open ? "opacity-100" : "opacity-0 invisible"
|
|
188
|
+
} transition-opacity duration-200 ease-in-out`}>
|
|
189
|
+
<IconButton
|
|
190
|
+
aria-label="Close drawer"
|
|
191
|
+
onClick={() => props.setDrawerOpen(false)}
|
|
192
|
+
>
|
|
193
|
+
<ChevronLeftIcon/>
|
|
194
|
+
</IconButton>
|
|
195
|
+
</div>
|
|
238
196
|
|
|
197
|
+
<div className={"flex flex-col h-full"}>
|
|
239
198
|
{props.children}
|
|
240
199
|
</div>
|
|
241
200
|
|
|
@@ -251,7 +210,7 @@ function DrawerWrapper(props: {
|
|
|
251
210
|
aria-label="Open drawer"
|
|
252
211
|
onClick={() => props.setDrawerOpen(true)}
|
|
253
212
|
size="large"
|
|
254
|
-
className="absolute top-2 left-
|
|
213
|
+
className="absolute top-2 left-5"
|
|
255
214
|
>
|
|
256
215
|
<MenuIcon/>
|
|
257
216
|
</IconButton>
|
|
@@ -259,6 +218,8 @@ function DrawerWrapper(props: {
|
|
|
259
218
|
transparent={true}
|
|
260
219
|
open={props.open}
|
|
261
220
|
onOpenChange={props.setDrawerOpen}
|
|
221
|
+
title={"Navigaion drawer"}
|
|
222
|
+
overlayClassName={"bg-white bg-opacity-80"}
|
|
262
223
|
>
|
|
263
224
|
{innerDrawer}
|
|
264
225
|
</Sheet>
|
|
@@ -267,7 +228,7 @@ function DrawerWrapper(props: {
|
|
|
267
228
|
|
|
268
229
|
return (
|
|
269
230
|
<div
|
|
270
|
-
className="relative"
|
|
231
|
+
className="z-20 relative"
|
|
271
232
|
onMouseEnter={props.onMouseEnter}
|
|
272
233
|
onMouseMove={props.onMouseMove}
|
|
273
234
|
onMouseLeave={props.onMouseLeave}
|
|
@@ -278,18 +239,6 @@ function DrawerWrapper(props: {
|
|
|
278
239
|
|
|
279
240
|
{innerDrawer}
|
|
280
241
|
|
|
281
|
-
<div
|
|
282
|
-
className={`absolute right-0 top-4 ${
|
|
283
|
-
props.open ? "opacity-100" : "opacity-0 invisible"
|
|
284
|
-
} transition-opacity duration-1000 ease-in-out`}>
|
|
285
|
-
<IconButton
|
|
286
|
-
aria-label="Close drawer"
|
|
287
|
-
onClick={() => props.setDrawerOpen(false)}
|
|
288
|
-
>
|
|
289
|
-
<ChevronLeftIcon/>
|
|
290
|
-
</IconButton>
|
|
291
|
-
</div>
|
|
292
|
-
|
|
293
242
|
</div>
|
|
294
243
|
);
|
|
295
244
|
}
|
package/src/app/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This context represents the state of the app in terms of layout.
|
|
5
|
+
* @group Core
|
|
6
|
+
*/
|
|
7
|
+
export type AppState = {
|
|
8
|
+
hasDrawer: boolean,
|
|
9
|
+
drawerHovered: boolean,
|
|
10
|
+
drawerOpen: boolean,
|
|
11
|
+
openDrawer: () => void,
|
|
12
|
+
closeDrawer: () => void,
|
|
13
|
+
autoOpenDrawer?: boolean,
|
|
14
|
+
logo?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const AppContext = React.createContext<AppState>({
|
|
18
|
+
hasDrawer: false,
|
|
19
|
+
drawerHovered: false,
|
|
20
|
+
drawerOpen: false,
|
|
21
|
+
openDrawer: () => {
|
|
22
|
+
throw new Error("openDrawer not implemented");
|
|
23
|
+
},
|
|
24
|
+
closeDrawer: () => {
|
|
25
|
+
throw new Error("closeDrawer not implemented");
|
|
26
|
+
},
|
|
27
|
+
autoOpenDrawer: false
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export function useApp() {
|
|
31
|
+
return React.useContext(AppContext);
|
|
32
|
+
}
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
AddIcon,
|
|
8
8
|
Button,
|
|
9
9
|
ContentCopyIcon,
|
|
10
|
-
fieldBackgroundHoverMixin,
|
|
10
|
+
fieldBackgroundHoverMixin,
|
|
11
|
+
HandleIcon,
|
|
11
12
|
IconButton,
|
|
12
13
|
Menu,
|
|
13
14
|
MenuItem,
|
|
@@ -26,7 +27,8 @@ interface ArrayContainerProps<T> {
|
|
|
26
27
|
onInternalIdAdded?: (id: number) => void;
|
|
27
28
|
includeAddButton?: boolean;
|
|
28
29
|
newDefaultEntry: T;
|
|
29
|
-
onValueChange: (value: T[]) => void
|
|
30
|
+
onValueChange: (value: T[]) => void,
|
|
31
|
+
className?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const buildIdsMap = (value: any[]) =>
|
|
@@ -52,7 +54,8 @@ export function ArrayContainer<T>({
|
|
|
52
54
|
onInternalIdAdded,
|
|
53
55
|
includeAddButton,
|
|
54
56
|
newDefaultEntry,
|
|
55
|
-
onValueChange
|
|
57
|
+
onValueChange,
|
|
58
|
+
className
|
|
56
59
|
}: ArrayContainerProps<T>) {
|
|
57
60
|
|
|
58
61
|
const hasValue = value && Array.isArray(value) && value.length > 0;
|
|
@@ -153,6 +156,7 @@ export function ArrayContainer<T>({
|
|
|
153
156
|
>
|
|
154
157
|
{(droppableProvided, droppableSnapshot) => (
|
|
155
158
|
<div
|
|
159
|
+
className={className}
|
|
156
160
|
{...droppableProvided.droppableProps}
|
|
157
161
|
ref={droppableProvided.innerRef}>
|
|
158
162
|
{hasValue && internalIds.map((internalId: number, index: number) => {
|
|
@@ -235,12 +239,13 @@ export function ArrayContainerItem({
|
|
|
235
239
|
{...provided.draggableProps}
|
|
236
240
|
style={provided.draggableProps.style}
|
|
237
241
|
className={`${
|
|
238
|
-
(isDragging || onHover) ?
|
|
242
|
+
(isDragging || onHover) ? "hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-20" : ""
|
|
239
243
|
} mb-1 rounded-md opacity-100`}
|
|
240
244
|
>
|
|
241
245
|
<div
|
|
242
246
|
className="flex items-start">
|
|
243
|
-
<div
|
|
247
|
+
<div
|
|
248
|
+
className="flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark">
|
|
244
249
|
{buildEntry(index, internalId)}
|
|
245
250
|
</div>
|
|
246
251
|
<ArrayItemOptions direction={size === "small" ? "row" : "column"}
|
|
@@ -253,7 +258,6 @@ export function ArrayContainerItem({
|
|
|
253
258
|
</div>;
|
|
254
259
|
}
|
|
255
260
|
|
|
256
|
-
|
|
257
261
|
export function ArrayItemOptions({
|
|
258
262
|
direction,
|
|
259
263
|
disabled,
|
|
@@ -283,11 +287,13 @@ export function ArrayItemOptions({
|
|
|
283
287
|
open={menuOpen ? false : undefined}
|
|
284
288
|
side={direction === "column" ? "left" : undefined}
|
|
285
289
|
title="Drag to move. Click for more options">
|
|
286
|
-
|
|
287
290
|
<IconButton
|
|
288
291
|
size="small"
|
|
289
292
|
disabled={disabled}
|
|
290
|
-
onClick={() =>
|
|
293
|
+
onClick={(e) => {
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
setMenuOpen(true);
|
|
296
|
+
}}
|
|
291
297
|
onDragStart={(e: any) => {
|
|
292
298
|
setMenuOpen(false);
|
|
293
299
|
}}
|
|
@@ -298,7 +304,7 @@ export function ArrayItemOptions({
|
|
|
298
304
|
<Menu
|
|
299
305
|
portalContainer={iconRef.current}
|
|
300
306
|
open={menuOpen}
|
|
301
|
-
trigger={<div/>}>
|
|
307
|
+
trigger={<div tabIndex={-1}/>}>
|
|
302
308
|
|
|
303
309
|
<MenuItem dense onClick={(e) => {
|
|
304
310
|
setMenuOpen(false);
|
|
@@ -316,7 +322,6 @@ export function ArrayItemOptions({
|
|
|
316
322
|
</MenuItem>
|
|
317
323
|
|
|
318
324
|
</Menu>
|
|
319
|
-
|
|
320
325
|
</Tooltip>
|
|
321
326
|
|
|
322
327
|
</div>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { MouseEvent, useCallback } from "react";
|
|
2
2
|
|
|
3
3
|
import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../types";
|
|
4
|
-
import { Checkbox, cls, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip
|
|
4
|
+
import { Checkbox, cls, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip } from "@firecms/ui";
|
|
5
5
|
import { useFireCMSContext, useLargeLayout } from "../../hooks";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -14,7 +14,6 @@ import { useFireCMSContext, useLargeLayout } from "../../hooks";
|
|
|
14
14
|
* @param size
|
|
15
15
|
* @param toggleEntitySelection
|
|
16
16
|
* @param hideId
|
|
17
|
-
* @constructor
|
|
18
17
|
*
|
|
19
18
|
* @group Collection components
|
|
20
19
|
*/
|
|
@@ -56,12 +55,7 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
|
56
55
|
const context = useFireCMSContext();
|
|
57
56
|
|
|
58
57
|
const onCheckedChange = useCallback((checked: boolean) => {
|
|
59
|
-
selectionController?.toggleEntitySelection(entity);
|
|
60
|
-
}, [entity, selectionController?.toggleEntitySelection]);
|
|
61
|
-
|
|
62
|
-
const onClick = useCallback((event: MouseEvent) => {
|
|
63
|
-
event.stopPropagation();
|
|
64
|
-
selectionController?.toggleEntitySelection(entity);
|
|
58
|
+
selectionController?.toggleEntitySelection(entity, checked);
|
|
65
59
|
}, [entity, selectionController?.toggleEntitySelection]);
|
|
66
60
|
|
|
67
61
|
const hasActions = actions.length > 0;
|
|
@@ -71,7 +65,6 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
|
71
65
|
const uncollapsedActions = actions.filter(a => a.collapsed === false);
|
|
72
66
|
return (
|
|
73
67
|
<div
|
|
74
|
-
onClick={onClick}
|
|
75
68
|
className={cls(
|
|
76
69
|
"h-full flex items-center justify-center flex-col bg-gray-50 dark:bg-gray-900 bg-opacity-90 dark:bg-opacity-90 z-10",
|
|
77
70
|
frozen ? "sticky left-0" : ""
|
|
@@ -87,7 +80,9 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
|
87
80
|
<div className="w-34 flex justify-center">
|
|
88
81
|
|
|
89
82
|
{uncollapsedActions.map((action, index) => (
|
|
90
|
-
<Tooltip key={index}
|
|
83
|
+
<Tooltip key={index}
|
|
84
|
+
title={action.name}
|
|
85
|
+
asChild={true}>
|
|
91
86
|
<IconButton
|
|
92
87
|
onClick={(event: MouseEvent) => {
|
|
93
88
|
event.stopPropagation();
|
|
@@ -149,16 +144,14 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
|
149
144
|
</div>}
|
|
150
145
|
|
|
151
146
|
{!hideId && size !== "xs" && (
|
|
152
|
-
<div
|
|
147
|
+
<div
|
|
148
|
+
className="w-[138px] text-center overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2"
|
|
149
|
+
onClick={(event) => {
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
}}>
|
|
153
152
|
|
|
154
153
|
{entity
|
|
155
|
-
?
|
|
156
|
-
onClick={(event) => {
|
|
157
|
-
event.stopPropagation();
|
|
158
|
-
}}
|
|
159
|
-
className={"font-mono select-all"}
|
|
160
|
-
variant={"caption"}
|
|
161
|
-
color={"secondary"}> {entity.id} </Typography>
|
|
154
|
+
? entity.id
|
|
162
155
|
: <Skeleton/>
|
|
163
156
|
}
|
|
164
157
|
</div>
|
|
@@ -246,7 +246,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
246
246
|
: collectionColumns) as VirtualTableColumn[]
|
|
247
247
|
];
|
|
248
248
|
|
|
249
|
-
const cellRenderer = (props: CellRendererParams<any>) => {
|
|
249
|
+
const cellRenderer = useCallback((props: CellRendererParams<any>) => {
|
|
250
250
|
const column = props.column;
|
|
251
251
|
const columns = props.columns;
|
|
252
252
|
const columnKey = column.key;
|
|
@@ -286,7 +286,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
286
286
|
<ErrorView error={e}/>
|
|
287
287
|
</EntityTableCell>;
|
|
288
288
|
}
|
|
289
|
-
}
|
|
289
|
+
}, [tableRowActionsBuilder, additionalCellRenderer, propertyCellRenderer, size]);
|
|
290
290
|
|
|
291
291
|
return (
|
|
292
292
|
|
|
@@ -49,6 +49,8 @@ export interface PropertyTableCellProps<T extends CMSType> {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function isStorageProperty(property: ResolvedProperty) {
|
|
52
|
+
if (property.dataType === "string" && property.markdown)
|
|
53
|
+
return false;
|
|
52
54
|
if (property.dataType === "string" && (property as ResolvedStringProperty).storage)
|
|
53
55
|
return true;
|
|
54
56
|
if (property.dataType === "array") {
|
|
@@ -147,7 +149,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
147
149
|
onValueUpdated,
|
|
148
150
|
data: entity,
|
|
149
151
|
});
|
|
150
|
-
} catch (e:any) {
|
|
152
|
+
} catch (e: any) {
|
|
151
153
|
console.error("onValueChange error", e);
|
|
152
154
|
setError(e);
|
|
153
155
|
}
|
|
@@ -306,7 +308,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
306
308
|
updateValue={updateValue}
|
|
307
309
|
/>;
|
|
308
310
|
fullHeight = true;
|
|
309
|
-
} else if (!stringProperty.storage) {
|
|
311
|
+
} else if (stringProperty.markdown || !stringProperty.storage) {
|
|
310
312
|
const multiline = Boolean(stringProperty.multiline) || Boolean(stringProperty.markdown);
|
|
311
313
|
innerComponent = <VirtualTableInput error={validationError ?? error}
|
|
312
314
|
disabled={disabled}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, { useCallback
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
2
|
import equal from "react-fast-compare"
|
|
3
3
|
|
|
4
4
|
import { ReferencePreview } from "../../../preview";
|
|
5
5
|
import { CollectionSize, Entity, EntityCollection, EntityReference, FilterValues } from "../../../types";
|
|
6
6
|
|
|
7
7
|
import { getPreviewSizeFrom } from "../../../preview/util";
|
|
8
|
-
import { getReferenceFrom } from "../../../util";
|
|
8
|
+
import { getReferenceFrom, IconForView } from "../../../util";
|
|
9
9
|
import { useCustomizationController, useNavigationController, useReferenceDialog } from "../../../hooks";
|
|
10
10
|
import { ErrorView } from "../../ErrorView";
|
|
11
|
-
import {
|
|
11
|
+
import { cls } from "@firecms/ui";
|
|
12
12
|
import { EntityPreviewContainer } from "../../EntityPreview";
|
|
13
13
|
|
|
14
14
|
type TableReferenceFieldProps = {
|
|
@@ -39,11 +39,11 @@ export function TableReferenceField(props: TableReferenceFieldProps) {
|
|
|
39
39
|
throw Error(`Couldn't find the corresponding collection view for the path: ${path}`);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
return <
|
|
42
|
+
return <TableReferenceFieldInternal {...props} collection={collection}/>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const
|
|
46
|
-
function
|
|
45
|
+
export const TableReferenceFieldInternal = React.memo(
|
|
46
|
+
function TableReferenceFieldInternal(props: TableReferenceFieldProps & {
|
|
47
47
|
collection: EntityCollection;
|
|
48
48
|
}) {
|
|
49
49
|
const {
|
|
@@ -87,11 +87,11 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
89
|
|
|
90
|
-
const handleOpen =
|
|
90
|
+
const handleOpen = () => {
|
|
91
91
|
if (disabled)
|
|
92
92
|
return;
|
|
93
93
|
referenceDialogController.open();
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
95
|
|
|
96
96
|
const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);
|
|
97
97
|
|
|
@@ -123,7 +123,7 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
123
123
|
key={`preview_array_ref_${name}_${index}`}>
|
|
124
124
|
<ReferencePreview
|
|
125
125
|
onClick={disabled ? undefined : handleOpen}
|
|
126
|
-
size={"
|
|
126
|
+
size={"smallest"}
|
|
127
127
|
reference={reference}
|
|
128
128
|
hover={!disabled}
|
|
129
129
|
disabled={!path}
|
|
@@ -150,13 +150,20 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
150
150
|
{internalValue && multiselect && buildMultipleReferenceField()}
|
|
151
151
|
|
|
152
152
|
{valueNotSet &&
|
|
153
|
-
<
|
|
153
|
+
<EntityPreviewContainer
|
|
154
|
+
className={cls("px-4 py-2 text-sm font-medium flex items-center uppercase",
|
|
155
|
+
multiselect ? "gap-4" : "gap-6",
|
|
156
|
+
disabled
|
|
157
|
+
? "text-slate-500"
|
|
158
|
+
: "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
|
|
154
159
|
onClick={handleOpen}
|
|
155
|
-
size={"
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
size={"medium"}>
|
|
161
|
+
<IconForView
|
|
162
|
+
size={"small"}
|
|
163
|
+
collectionOrView={collection}
|
|
164
|
+
className={"text-gray-300 dark:text-gray-600"}/>
|
|
158
165
|
Edit {title}
|
|
159
|
-
</
|
|
166
|
+
</EntityPreviewContainer>}
|
|
160
167
|
|
|
161
168
|
</div>
|
|
162
169
|
);
|