@firecms/core 3.0.0-beta.2-pre.2 → 3.0.0-beta.2-pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +0 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -8
- package/dist/components/EntityCollectionTable/index.d.ts +2 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/{ReferenceSelectionInner.d.ts → ReferenceTable/ReferenceSelectionTable.d.ts} +2 -2
- package/dist/components/{EntityCollectionTable/SimpleTable.d.ts → SelectableTable/SelectableTable.d.ts} +3 -4
- package/dist/components/SelectableTable/SelectableTableContext.d.ts +4 -0
- package/dist/components/common/index.d.ts +5 -0
- package/dist/components/{EntityCollectionTable → common}/types.d.ts +7 -0
- package/dist/components/common/useTableSearchHelper.d.ts +12 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/form/EntityForm.d.ts +2 -0
- package/dist/form/components/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/{internal → hooks}/useBuildNavigationController.d.ts +11 -4
- package/dist/hooks/useSnackbarController.d.ts +1 -0
- package/dist/index.es.js +4081 -4049
- 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/types/fields.d.ts +0 -1
- package/dist/types/firecms.d.ts +6 -25
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +0 -8
- package/package.json +4 -4
- package/src/components/ArrayContainer.tsx +11 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +16 -22
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -2
- package/src/components/EntityCollectionTable/column_utils.tsx +1 -1
- package/src/components/EntityCollectionTable/index.tsx +1 -9
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +133 -136
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +20 -41
- package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx} +31 -15
- package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx} +8 -9
- package/src/components/SelectableTable/SelectableTableContext.tsx +6 -0
- package/src/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.tsx +0 -1
- package/src/components/VirtualTable/VirtualTableHeader.tsx +10 -4
- package/src/components/common/index.ts +5 -0
- package/src/components/{EntityCollectionTable → common}/types.tsx +5 -0
- package/src/components/common/useTableSearchHelper.ts +47 -0
- package/src/components/index.tsx +6 -2
- package/src/core/EntitySidePanel.tsx +7 -5
- package/src/core/FireCMS.tsx +1 -16
- package/src/form/EntityForm.tsx +237 -196
- package/src/form/PropertyFieldBinding.tsx +7 -7
- package/src/form/components/CustomIdField.tsx +35 -34
- package/src/form/components/ErrorFocus.tsx +3 -3
- package/src/form/components/index.tsx +0 -1
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -12
- package/src/hooks/index.tsx +1 -0
- package/src/{internal → hooks}/useBuildNavigationController.tsx +23 -17
- package/src/hooks/useFireCMSContext.tsx +51 -3
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useSnackbarController.tsx +1 -2
- package/src/internal/useBuildSideEntityController.tsx +1 -1
- package/src/types/fields.tsx +1 -1
- package/src/types/firecms.tsx +7 -28
- package/src/types/navigation.ts +2 -2
- package/src/types/plugins.tsx +0 -9
- package/src/util/resolutions.ts +1 -1
- package/dist/form/components/SubmitListener.d.ts +0 -1
- package/dist/form/components/SwitchControl.d.ts +0 -8
- package/src/form/components/SubmitListener.tsx +0 -32
- package/src/form/components/SwitchControl.tsx +0 -39
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionView → common}/useColumnsIds.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDebouncedData.d.ts +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionView → common}/useColumnsIds.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDebouncedData.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
|
|
3
|
-
import { ErrorMessage } from "
|
|
4
|
-
|
|
3
|
+
// import { ErrorMessage } from "@firecms/formex";
|
|
5
4
|
import { Entity, EntityStatus, EnumValueConfig, EnumValues } from "../../types";
|
|
6
5
|
|
|
7
6
|
import { useClipboard, useSnackbarController } from "../../hooks";
|
|
@@ -14,11 +13,13 @@ import {
|
|
|
14
13
|
Select,
|
|
15
14
|
SelectItem,
|
|
16
15
|
TextField,
|
|
17
|
-
Tooltip
|
|
16
|
+
Tooltip,
|
|
17
|
+
Typography
|
|
18
18
|
} from "@firecms/ui";
|
|
19
19
|
import { EnumValuesChip } from "../../preview";
|
|
20
20
|
import { useCustomizationController } from "../../hooks/useCustomizationController";
|
|
21
21
|
import { CustomizationController } from "../../types/customization_controller";
|
|
22
|
+
import { useFormex } from "@firecms/formex";
|
|
22
23
|
|
|
23
24
|
export function CustomIdField<M extends Record<string, any>>({
|
|
24
25
|
customId,
|
|
@@ -38,6 +39,7 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
38
39
|
loading: boolean
|
|
39
40
|
}) {
|
|
40
41
|
|
|
42
|
+
const { errors } = useFormex();
|
|
41
43
|
const disabled = status === "existing" || !customId;
|
|
42
44
|
const idSetAutomatically = status !== "existing" && !customId;
|
|
43
45
|
|
|
@@ -62,33 +64,33 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
62
64
|
disabled: disabled || loading,
|
|
63
65
|
name: "id",
|
|
64
66
|
value: (entity && status === "existing" ? entity.id : entityId) ?? "",
|
|
65
|
-
endAdornment: entity
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</IconButton>
|
|
74
|
-
</Tooltip>
|
|
75
|
-
|
|
76
|
-
{customizationController?.entityLinkBuilder &&
|
|
77
|
-
<Tooltip title={"Open in the console"}>
|
|
78
|
-
<IconButton component={"a"}
|
|
79
|
-
href={customizationController.entityLinkBuilder({ entity })}
|
|
80
|
-
rel="noopener noreferrer"
|
|
81
|
-
target="_blank"
|
|
82
|
-
onClick={(e) => e.stopPropagation()}
|
|
83
|
-
aria-label="go-to-datasource">
|
|
84
|
-
<OpenInNewIcon size={"small"}/>
|
|
67
|
+
endAdornment: loading ? <CircularProgress size={"small"}/> : (entity
|
|
68
|
+
? (
|
|
69
|
+
<>
|
|
70
|
+
|
|
71
|
+
<Tooltip title={"Copy"}>
|
|
72
|
+
<IconButton onClick={(e) => copy(entity.id)}
|
|
73
|
+
aria-label="copy-id">
|
|
74
|
+
<ContentCopyIcon size={"small"}/>
|
|
85
75
|
</IconButton>
|
|
86
|
-
</Tooltip>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
</Tooltip>
|
|
77
|
+
|
|
78
|
+
{customizationController?.entityLinkBuilder &&
|
|
79
|
+
<Tooltip title={"Open in the console"}>
|
|
80
|
+
<IconButton component={"a"}
|
|
81
|
+
href={customizationController.entityLinkBuilder({ entity })}
|
|
82
|
+
rel="noopener noreferrer"
|
|
83
|
+
target="_blank"
|
|
84
|
+
onClick={(e) => e.stopPropagation()}
|
|
85
|
+
aria-label="go-to-datasource">
|
|
86
|
+
<OpenInNewIcon size={"small"}/>
|
|
87
|
+
</IconButton>
|
|
88
|
+
</Tooltip>}
|
|
89
|
+
|
|
90
|
+
</>
|
|
91
|
+
)
|
|
92
|
+
: undefined
|
|
93
|
+
)
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
return (
|
|
@@ -120,7 +122,6 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
120
122
|
{!enumValues &&
|
|
121
123
|
<TextField {...fieldProps}
|
|
122
124
|
error={error}
|
|
123
|
-
endAdornment={loading ? <CircularProgress size={"small"}/> : undefined}
|
|
124
125
|
placeholder={customId === "optional" ? "Autogenerated ID, it can be manually changed" : (status === "new" || status === "copy" ? "ID of the new document" : "ID of the document")}
|
|
125
126
|
onChange={(event) => {
|
|
126
127
|
let value = event.target.value;
|
|
@@ -128,10 +129,10 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
128
129
|
return onChange(value.length ? value : undefined);
|
|
129
130
|
}}/>}
|
|
130
131
|
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
</
|
|
132
|
+
{errors.id && <Typography variant={"caption"}
|
|
133
|
+
className={"ml-3.5 text-red-500 dark:text-red-500"}>
|
|
134
|
+
{errors.id}
|
|
135
|
+
</Typography>}
|
|
135
136
|
|
|
136
137
|
</>
|
|
137
138
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useFormex } from "@firecms/formex";
|
|
3
3
|
|
|
4
4
|
export const ErrorFocus = ({ containerRef }:
|
|
5
5
|
{
|
|
6
6
|
containerRef?: React.RefObject<HTMLDivElement>
|
|
7
7
|
}) => {
|
|
8
|
-
const { isSubmitting, isValidating, errors } =
|
|
8
|
+
const { isSubmitting, isValidating, errors } = useFormex();
|
|
9
9
|
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
const keys = Object.keys(errors);
|
|
@@ -21,7 +21,7 @@ export const ErrorFocus = ({ containerRef }:
|
|
|
21
21
|
if (scrollableParent) {
|
|
22
22
|
const top = errorElement.getBoundingClientRect().top;
|
|
23
23
|
scrollableParent.scrollTo({
|
|
24
|
-
top: scrollableParent.scrollTop + top,
|
|
24
|
+
top: scrollableParent.scrollTop + top - 196,
|
|
25
25
|
behavior: "smooth"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Field, useFormex } from "@firecms/formex";
|
|
4
4
|
|
|
5
5
|
import { FieldHelperText, FormikArrayContainer } from "../components";
|
|
6
6
|
import { LabelWithIcon } from "../../components";
|
|
@@ -148,7 +148,7 @@ function BlockEntry({
|
|
|
148
148
|
const type = value && value[typeField];
|
|
149
149
|
const [typeInternal, setTypeInternal] = useState<string | undefined>(type ?? undefined);
|
|
150
150
|
|
|
151
|
-
const
|
|
151
|
+
const formex = useFormex();
|
|
152
152
|
|
|
153
153
|
useEffect(() => {
|
|
154
154
|
if (!type) {
|
|
@@ -188,20 +188,20 @@ function BlockEntry({
|
|
|
188
188
|
const updateType = (newType: any) => {
|
|
189
189
|
const newSelectedProperty = newType ? properties[newType] : undefined;
|
|
190
190
|
setTypeInternal(newType);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
formex.setFieldTouched(typeFieldName, true);
|
|
192
|
+
formex.setFieldValue(typeFieldName, newType);
|
|
193
|
+
formex.setFieldValue(valueFieldName, newSelectedProperty ? getDefaultValueFor(newSelectedProperty) : null);
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
return (
|
|
197
197
|
<div className={cn(paperMixin, "bg-transparent p-4 my-4 py-8")}>
|
|
198
198
|
|
|
199
|
-
<
|
|
200
|
-
required={true}
|
|
199
|
+
<Field
|
|
201
200
|
name={typeFieldName}
|
|
202
201
|
>
|
|
203
|
-
{(fieldProps
|
|
204
|
-
|
|
202
|
+
{(fieldProps) => {
|
|
203
|
+
const value1 = fieldProps.field.value !== undefined && fieldProps.field.value !== null ? fieldProps.field.value as string : "";
|
|
204
|
+
return (
|
|
205
205
|
<>
|
|
206
206
|
<Select
|
|
207
207
|
className="mb-2"
|
|
@@ -209,7 +209,7 @@ function BlockEntry({
|
|
|
209
209
|
className={"px-4 py-2 font-medium"}>Type</Typography>}
|
|
210
210
|
size={"small"}
|
|
211
211
|
position={"item-aligned"}
|
|
212
|
-
value={
|
|
212
|
+
value={value1}
|
|
213
213
|
renderValue={(enumKey: any) =>
|
|
214
214
|
<EnumValuesChip
|
|
215
215
|
enumKey={enumKey}
|
|
@@ -231,9 +231,10 @@ function BlockEntry({
|
|
|
231
231
|
)}
|
|
232
232
|
</Select>
|
|
233
233
|
</>
|
|
234
|
-
)
|
|
234
|
+
);
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
}
|
|
237
|
+
</Field>
|
|
237
238
|
|
|
238
239
|
{fieldProps && (
|
|
239
240
|
// It is important to use this key to force a re-render of the field on type change
|
package/src/hooks/index.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
EntityCollection,
|
|
10
10
|
EntityCollectionsBuilder,
|
|
11
11
|
EntityReference,
|
|
12
|
-
FireCMSPlugin,
|
|
13
12
|
NavigationController,
|
|
14
13
|
TopNavigationEntry,
|
|
15
14
|
TopNavigationResult,
|
|
@@ -35,8 +34,15 @@ type BuildNavigationContextProps<EC extends EntityCollection, UserType extends U
|
|
|
35
34
|
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
36
35
|
views?: CMSView[] | CMSViewsBuilder;
|
|
37
36
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
38
|
+
/**
|
|
39
|
+
* Use this method to inject collections to the CMS.
|
|
40
|
+
* You receive the current collections as a parameter, and you can return
|
|
41
|
+
* a new list of collections.
|
|
42
|
+
* @see {@link joinCollectionLists}
|
|
43
|
+
* @param collections
|
|
44
|
+
*/
|
|
45
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export function useBuildNavigationController<EC extends EntityCollection, UserType extends User>({
|
|
@@ -46,8 +52,8 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
46
52
|
collections: baseCollections,
|
|
47
53
|
views: baseViews,
|
|
48
54
|
userConfigPersistence,
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
dataSourceDelegate,
|
|
56
|
+
injectCollections
|
|
51
57
|
}: BuildNavigationContextProps<EC, UserType>): NavigationController {
|
|
52
58
|
|
|
53
59
|
const location = useLocation();
|
|
@@ -119,8 +125,8 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
119
125
|
|
|
120
126
|
try {
|
|
121
127
|
const [resolvedCollections = [], resolvedViews = []] = await Promise.all([
|
|
122
|
-
resolveCollections(baseCollections, authController,
|
|
123
|
-
resolveCMSViews(baseViews, authController,
|
|
128
|
+
resolveCollections(baseCollections, authController, dataSourceDelegate, injectCollections),
|
|
129
|
+
resolveCMSViews(baseViews, authController, dataSourceDelegate)
|
|
124
130
|
]
|
|
125
131
|
);
|
|
126
132
|
|
|
@@ -134,7 +140,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
134
140
|
|
|
135
141
|
setNavigationLoading(false);
|
|
136
142
|
setInitialised(true);
|
|
137
|
-
}, [baseCollections, authController.user, authController.initialLoading,
|
|
143
|
+
}, [baseCollections, authController.user, authController.initialLoading, baseViews, computeTopNavigation, injectCollections]);
|
|
138
144
|
|
|
139
145
|
useEffect(() => {
|
|
140
146
|
refreshNavigation();
|
|
@@ -277,8 +283,8 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
277
283
|
, [getCollectionFromIds]);
|
|
278
284
|
|
|
279
285
|
return useMemo(() => ({
|
|
280
|
-
collections
|
|
281
|
-
views
|
|
286
|
+
collections,
|
|
287
|
+
views,
|
|
282
288
|
loading: !initialised || navigationLoading,
|
|
283
289
|
navigationLoadingError,
|
|
284
290
|
homeUrl,
|
|
@@ -332,7 +338,10 @@ function filterOutNotAllowedCollections(resolvedCollections: EntityCollection[],
|
|
|
332
338
|
});
|
|
333
339
|
}
|
|
334
340
|
|
|
335
|
-
async function resolveCollections(collections: undefined | EntityCollection[] | EntityCollectionsBuilder<any>,
|
|
341
|
+
async function resolveCollections(collections: undefined | EntityCollection[] | EntityCollectionsBuilder<any>,
|
|
342
|
+
authController: AuthController,
|
|
343
|
+
dataSource: DataSourceDelegate,
|
|
344
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[]) {
|
|
336
345
|
let resolvedCollections: EntityCollection[] = [];
|
|
337
346
|
if (typeof collections === "function") {
|
|
338
347
|
resolvedCollections = await collections({
|
|
@@ -346,13 +355,10 @@ async function resolveCollections(collections: undefined | EntityCollection[] |
|
|
|
346
355
|
|
|
347
356
|
resolvedCollections = filterOutNotAllowedCollections(resolvedCollections, authController);
|
|
348
357
|
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
if (plugin.collections?.injectCollections) {
|
|
352
|
-
resolvedCollections = plugin.collections?.injectCollections(resolvedCollections ?? []);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
358
|
+
if (injectCollections) {
|
|
359
|
+
resolvedCollections = injectCollections(resolvedCollections ?? []);
|
|
355
360
|
}
|
|
361
|
+
|
|
356
362
|
return resolvedCollections;
|
|
357
363
|
}
|
|
358
364
|
|
|
@@ -10,6 +10,7 @@ import { useUserConfigurationPersistence } from "./useUserConfigurationPersisten
|
|
|
10
10
|
import { useDialogsController } from "./useDialogsController";
|
|
11
11
|
import { useCustomizationController } from "./useCustomizationController";
|
|
12
12
|
import { useAnalyticsController } from "./useAnalyticsController";
|
|
13
|
+
import React, { useEffect } from "react";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Hook to retrieve the {@link FireCMSContext}.
|
|
@@ -34,7 +35,7 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
34
35
|
const customizationController = useCustomizationController();
|
|
35
36
|
const analyticsController = useAnalyticsController();
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const fireCMSContextRef = React.useRef<FireCMSContext<UserType, AuthControllerType>>({
|
|
38
39
|
authController,
|
|
39
40
|
sideDialogsController,
|
|
40
41
|
sideEntityController,
|
|
@@ -46,6 +47,53 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
46
47
|
dialogsController,
|
|
47
48
|
customizationController,
|
|
48
49
|
analyticsController
|
|
49
|
-
};
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
fireCMSContextRef.current = {
|
|
54
|
+
authController,
|
|
55
|
+
sideDialogsController,
|
|
56
|
+
sideEntityController,
|
|
57
|
+
navigation,
|
|
58
|
+
dataSource,
|
|
59
|
+
storageSource,
|
|
60
|
+
snackbarController,
|
|
61
|
+
userConfigPersistence,
|
|
62
|
+
dialogsController,
|
|
63
|
+
customizationController,
|
|
64
|
+
analyticsController
|
|
65
|
+
};
|
|
66
|
+
}, [authController, dialogsController, navigation, sideDialogsController]);
|
|
67
|
+
|
|
68
|
+
return fireCMSContextRef.current;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// export const useFireCMSContext = <UserType extends User = User, AuthControllerType extends AuthController<UserType> = AuthController<UserType>>(): FireCMSContext<UserType, AuthControllerType> => {
|
|
72
|
+
//
|
|
73
|
+
// const authController = useAuthController<UserType, AuthControllerType>();
|
|
74
|
+
// const sideDialogsController = useSideDialogsController();
|
|
75
|
+
// const sideEntityController = useSideEntityController();
|
|
76
|
+
// const navigation = useNavigationController();
|
|
77
|
+
// const dataSource = useDataSource();
|
|
78
|
+
// const storageSource = useStorageSource();
|
|
79
|
+
// const snackbarController = useSnackbarController();
|
|
80
|
+
// const userConfigPersistence = useUserConfigurationPersistence();
|
|
81
|
+
// const dialogsController = useDialogsController();
|
|
82
|
+
// const customizationController = useCustomizationController();
|
|
83
|
+
// const analyticsController = useAnalyticsController();
|
|
84
|
+
//
|
|
85
|
+
// return {
|
|
86
|
+
// authController,
|
|
87
|
+
// sideDialogsController,
|
|
88
|
+
// sideEntityController,
|
|
89
|
+
// navigation,
|
|
90
|
+
// dataSource,
|
|
91
|
+
// storageSource,
|
|
92
|
+
// snackbarController,
|
|
93
|
+
// userConfigPersistence,
|
|
94
|
+
// dialogsController,
|
|
95
|
+
// customizationController,
|
|
96
|
+
// analyticsController
|
|
97
|
+
// };
|
|
98
|
+
//
|
|
99
|
+
// };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSideDialogsController } from "./useSideDialogsController";
|
|
2
|
-
import {
|
|
2
|
+
import { ReferenceSelectionTable, ReferenceSelectionInnerProps } from "../components";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
import { useNavigationController } from "./useNavigationController";
|
|
5
5
|
|
|
@@ -31,7 +31,7 @@ export function useReferenceDialog<M extends Record<string, any>>(referenceDialo
|
|
|
31
31
|
sideDialogsController.open({
|
|
32
32
|
key: `reference_${referenceDialogProps.path}`,
|
|
33
33
|
component:
|
|
34
|
-
<
|
|
34
|
+
<ReferenceSelectionTable
|
|
35
35
|
collection={usedCollection}
|
|
36
36
|
{...referenceDialogProps as ReferenceSelectionInnerProps<M>}/>,
|
|
37
37
|
width: "90vw",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from "react";
|
|
1
2
|
import { useSnackbar } from "notistack";
|
|
2
|
-
import { useCallback, useMemo } from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Possible snackbar types
|
|
@@ -48,7 +48,6 @@ export const useSnackbarController = () => {
|
|
|
48
48
|
|
|
49
49
|
const open = useCallback((props: {
|
|
50
50
|
type: SnackbarMessageType;
|
|
51
|
-
// title?: string;
|
|
52
51
|
message: React.ReactNode;
|
|
53
52
|
autoHideDuration?: number;
|
|
54
53
|
}) => {
|
|
@@ -37,7 +37,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
37
37
|
if (navigation.isUrlCollectionPath(location.pathname)) {
|
|
38
38
|
const newFlag = location.hash === `#${NEW_URL_HASH}`;
|
|
39
39
|
const entityOrCollectionPath = navigation.urlPathToDataPath(location.pathname);
|
|
40
|
-
const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, navigation.collections, newFlag);
|
|
40
|
+
const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, navigation.collections ?? [], newFlag);
|
|
41
41
|
for (let i = 0; i < panelsFromUrl.length; i++) {
|
|
42
42
|
const panel = panelsFromUrl[i];
|
|
43
43
|
setTimeout(() => {
|
package/src/types/fields.tsx
CHANGED
package/src/types/firecms.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { User } from "./user";
|
|
|
3
3
|
import { AuthController } from "./auth";
|
|
4
4
|
import { DataSourceDelegate } from "./datasource";
|
|
5
5
|
import { EntityCollection, EntityCustomView } from "./collections";
|
|
6
|
-
import { CMSView } from "./navigation";
|
|
6
|
+
import { CMSView, NavigationController } from "./navigation";
|
|
7
7
|
import { FireCMSContext } from "./firecms_context";
|
|
8
8
|
import { PropertyConfig } from "./property_config";
|
|
9
9
|
import { Locale } from "./locales";
|
|
@@ -67,19 +67,6 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
67
67
|
loading: boolean;
|
|
68
68
|
}) => React.ReactNode;
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* List of the mapped collections in the CMS.
|
|
72
|
-
* Each entry relates to a collection in the root database.
|
|
73
|
-
* Each of the navigation entries in this field
|
|
74
|
-
* generates an entry in the main menu.
|
|
75
|
-
*/
|
|
76
|
-
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Custom additional views created by the developer, added to the main
|
|
80
|
-
* navigation
|
|
81
|
-
*/
|
|
82
|
-
views?: CMSView[] | CMSViewsBuilder;
|
|
83
70
|
|
|
84
71
|
/**
|
|
85
72
|
* Record of custom form fields to be used in the CMS.
|
|
@@ -88,6 +75,12 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
88
75
|
*/
|
|
89
76
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
90
77
|
|
|
78
|
+
/**
|
|
79
|
+
* This controller is in charge of the navigation of the CMS.
|
|
80
|
+
* It is in charge of resolving the collection and entity paths.
|
|
81
|
+
*/
|
|
82
|
+
navigationController: NavigationController;
|
|
83
|
+
|
|
91
84
|
/**
|
|
92
85
|
* List of additional custom views for entities.
|
|
93
86
|
* You can use the key to reference the custom view in
|
|
@@ -124,20 +117,6 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
124
117
|
*/
|
|
125
118
|
authController: AuthController<UserType>;
|
|
126
119
|
|
|
127
|
-
/**
|
|
128
|
-
* Path under the navigation routes of the CMS will be created. Defaults to `/`.
|
|
129
|
-
* Internally FireCMS uses `react-router` to create the routes, the base path is attached to the
|
|
130
|
-
* `BrowserRouter` component. If you are using FireCMS in a subpath of your website, you can use
|
|
131
|
-
* this prop to specify the base path.
|
|
132
|
-
*/
|
|
133
|
-
basePath?: string;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Path under the collection routes of the CMS will be created.
|
|
137
|
-
* Defaults to `/c`.
|
|
138
|
-
*/
|
|
139
|
-
baseCollectionPath?: string;
|
|
140
|
-
|
|
141
120
|
/**
|
|
142
121
|
* Use this controller to access the configuration that is stored locally,
|
|
143
122
|
* and not defined in code
|
package/src/types/navigation.ts
CHANGED
|
@@ -14,13 +14,13 @@ export type NavigationController = {
|
|
|
14
14
|
* Each of the navigation entries in this field
|
|
15
15
|
* generates an entry in the main menu.
|
|
16
16
|
*/
|
|
17
|
-
collections
|
|
17
|
+
collections?: EntityCollection[];
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Custom additional views created by the developer, added to the main
|
|
21
21
|
* navigation
|
|
22
22
|
*/
|
|
23
|
-
views
|
|
23
|
+
views?: CMSView[];
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Configuration for the views that should be displayed at the top
|
package/src/types/plugins.tsx
CHANGED
|
@@ -28,15 +28,6 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
28
28
|
|
|
29
29
|
collections?: {
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* Use this method to inject collections to the CMS.
|
|
33
|
-
* You receive the current collections as a parameter, and you can return
|
|
34
|
-
* a new list of collections.
|
|
35
|
-
* @see {@link joinCollectionLists}
|
|
36
|
-
* @param collections
|
|
37
|
-
*/
|
|
38
|
-
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
39
|
-
|
|
40
31
|
/**
|
|
41
32
|
* Use this component to add custom actions to the entity collections
|
|
42
33
|
* toolbar.
|
package/src/util/resolutions.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { getValueInPath, mergeDeep } from "./objects";
|
|
25
25
|
import { getDefaultValuesFor, isPropertyBuilder } from "./entities";
|
|
26
26
|
import { DEFAULT_ONE_OF_TYPE } from "./common";
|
|
27
|
-
import { getIn } from "
|
|
27
|
+
import { getIn } from "@firecms/formex";
|
|
28
28
|
import { enumToObjectEntries } from "./enums";
|
|
29
29
|
import { isDefaultFieldConfigId } from "../core";
|
|
30
30
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function SubmitListener(): null;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FieldProps } from "formik";
|
|
2
|
-
export declare function SwitchControl({ field, form, label, tooltip, disabled, size, allowIndeterminate }: FieldProps & {
|
|
3
|
-
label: string;
|
|
4
|
-
tooltip?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
size: "small" | "medium";
|
|
7
|
-
allowIndeterminate?: boolean;
|
|
8
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { useFormikContext } from "formik";
|
|
4
|
-
import equal from "react-fast-compare";
|
|
5
|
-
|
|
6
|
-
export function SubmitListener() {
|
|
7
|
-
|
|
8
|
-
const formik = useFormikContext()
|
|
9
|
-
const [lastValues, setLastValues] = React.useState(formik.values);
|
|
10
|
-
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
const valuesEqualLastValues = equal(lastValues, formik.values)
|
|
13
|
-
const valuesEqualInitialValues = equal(formik.values, formik.initialValues)
|
|
14
|
-
|
|
15
|
-
if (!valuesEqualLastValues) {
|
|
16
|
-
setLastValues(formik.values)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const doSubmit = () => {
|
|
20
|
-
if (!valuesEqualLastValues && !valuesEqualInitialValues && formik.isValid) {
|
|
21
|
-
formik.submitForm();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const handler = setTimeout(doSubmit, 300);
|
|
26
|
-
return () => {
|
|
27
|
-
clearTimeout(handler);
|
|
28
|
-
};
|
|
29
|
-
}, [formik.values, formik.isValid])
|
|
30
|
-
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { FieldProps } from "formik";
|
|
4
|
-
import { BooleanSwitchWithLabel, Tooltip } from "@firecms/ui";
|
|
5
|
-
|
|
6
|
-
export function SwitchControl({
|
|
7
|
-
field,
|
|
8
|
-
form,
|
|
9
|
-
label,
|
|
10
|
-
tooltip,
|
|
11
|
-
disabled,
|
|
12
|
-
size = "small",
|
|
13
|
-
allowIndeterminate
|
|
14
|
-
}: FieldProps & {
|
|
15
|
-
label: string,
|
|
16
|
-
tooltip?: string,
|
|
17
|
-
disabled?: boolean,
|
|
18
|
-
size: "small" | "medium",
|
|
19
|
-
allowIndeterminate?: boolean
|
|
20
|
-
}) {
|
|
21
|
-
|
|
22
|
-
const formControlLabel = <BooleanSwitchWithLabel
|
|
23
|
-
label={label}
|
|
24
|
-
size={size}
|
|
25
|
-
position={"start"}
|
|
26
|
-
value={field.value}
|
|
27
|
-
disabled={disabled}
|
|
28
|
-
allowIndeterminate={allowIndeterminate}
|
|
29
|
-
onValueChange={(checked:boolean | null) => form.setFieldValue(field.name, checked)}/>;
|
|
30
|
-
|
|
31
|
-
if (tooltip)
|
|
32
|
-
return (
|
|
33
|
-
<Tooltip
|
|
34
|
-
title={tooltip}>
|
|
35
|
-
{formControlLabel}
|
|
36
|
-
</Tooltip>
|
|
37
|
-
);
|
|
38
|
-
return formControlLabel;
|
|
39
|
-
}
|
/package/dist/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.d.ts
RENAMED
|
File without changes
|
/package/dist/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.d.ts
RENAMED
|
File without changes
|
/package/dist/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.tsx
RENAMED
|
File without changes
|
/package/src/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.tsx
RENAMED
|
File without changes
|
/package/src/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.tsx
RENAMED
|
File without changes
|
|
File without changes
|