@firecms/core 3.0.0-canary.5 → 3.0.0-canary.51
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 -2
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +25 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/FireCMSAppBar.d.ts +3 -2
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +4 -2
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/core/Drawer.d.ts +5 -12
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +7 -10
- package/dist/core/index.d.ts +3 -4
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +3 -2
- package/dist/form/components/StorageUploadProgress.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/StorageUploadFieldBinding.d.ts +4 -3
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.es.js +9644 -9122
- 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 -12
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -7
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +29 -5
- package/dist/types/datasource.d.ts +3 -6
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +14 -13
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +20 -20
- package/dist/types/properties.d.ts +4 -4
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +2 -4
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +9 -13
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +275 -278
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +44 -44
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -16
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +9 -5
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +560 -554
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
- package/src/components/EntityPreview.tsx +207 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/FireCMSAppBar.tsx +33 -11
- package/src/components/HomePage/DefaultHomePage.tsx +15 -11
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +5 -5
- package/src/components/SearchIconsView.tsx +4 -4
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +35 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +28 -20
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/index.tsx +4 -2
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/core/Drawer.tsx +78 -103
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/{EntityView.tsx → EntityEditView.tsx} +21 -40
- package/src/core/EntitySidePanel.tsx +2 -2
- package/src/core/FireCMS.tsx +22 -7
- package/src/core/NavigationRoutes.tsx +11 -4
- package/src/core/Scaffold.tsx +76 -61
- package/src/core/field_configs.tsx +1 -2
- package/src/core/index.tsx +3 -4
- package/src/form/EntityForm.tsx +42 -22
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +5 -3
- package/src/form/components/StorageUploadProgress.tsx +7 -6
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -12
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +15 -15
- package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -0
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/validation.ts +3 -4
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +2 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +8 -3
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +3 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +199 -81
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/internal/useBuildDataSource.ts +42 -44
- package/src/internal/useBuildSideEntityController.tsx +86 -20
- package/src/preview/PropertyPreview.tsx +3 -14
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +55 -147
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +0 -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 +0 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +0 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +33 -5
- package/src/types/datasource.ts +8 -5
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -16
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +26 -28
- package/src/types/properties.ts +8 -6
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +4 -6
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +0 -14
- package/src/util/permissions.ts +11 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +6 -24
- package/src/util/strings.ts +2 -2
- package/src/util/useTraceUpdate.tsx +2 -1
- 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/components/HomePage/NavigationCollectionCard.tsx +0 -146
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { EnumValuesChip } from "../../../preview";
|
|
3
3
|
import { VirtualTableWhereFilterOp } from "../../VirtualTable";
|
|
4
|
-
import { ClearIcon, IconButton, Select, SelectItem, TextField } from "@firecms/ui";
|
|
4
|
+
import { Checkbox, ClearIcon, IconButton, Label, Select, SelectItem, TextField } from "@firecms/ui";
|
|
5
5
|
import { EnumValueConfig } from "../../../types";
|
|
6
6
|
|
|
7
7
|
interface StringNumberFilterFieldProps {
|
|
@@ -50,15 +50,15 @@ export function StringNumberFilterField({
|
|
|
50
50
|
|
|
51
51
|
const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
|
|
52
52
|
const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
|
|
53
|
-
const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | undefined>(fieldValue);
|
|
53
|
+
const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(fieldValue);
|
|
54
54
|
|
|
55
|
-
function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | undefined) {
|
|
55
|
+
function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {
|
|
56
56
|
let newValue = val;
|
|
57
57
|
const prevOpIsArray = multipleSelectOperations.includes(operation);
|
|
58
58
|
const newOpIsArray = multipleSelectOperations.includes(op);
|
|
59
59
|
if (prevOpIsArray !== newOpIsArray) {
|
|
60
60
|
// @ts-ignore
|
|
61
|
-
newValue = newOpIsArray ? (typeof val === "string" || typeof val === "number" ? [val] : []) :
|
|
61
|
+
newValue = newOpIsArray ? (typeof val === "string" || typeof val === "number" ? [val] : []) : undefined;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (typeof newValue === "number" && isNaN(newValue))
|
|
@@ -84,7 +84,7 @@ export function StringNumberFilterField({
|
|
|
84
84
|
const multiple = multipleSelectOperations.includes(operation);
|
|
85
85
|
return (
|
|
86
86
|
|
|
87
|
-
<div className="flex w-[440px]
|
|
87
|
+
<div className="flex w-[440px]">
|
|
88
88
|
<div className={"w-[80px]"}>
|
|
89
89
|
<Select value={operation}
|
|
90
90
|
position={"item-aligned"}
|
|
@@ -100,11 +100,11 @@ export function StringNumberFilterField({
|
|
|
100
100
|
</Select>
|
|
101
101
|
</div>
|
|
102
102
|
|
|
103
|
-
<div className="flex-grow ml-2">
|
|
103
|
+
<div className="flex-grow ml-2 flex flex-col gap-2">
|
|
104
104
|
|
|
105
105
|
{!enumValues && <TextField
|
|
106
106
|
type={dataType === "number" ? "number" : undefined}
|
|
107
|
-
value={internalValue !== undefined ? String(internalValue) : ""}
|
|
107
|
+
value={internalValue !== undefined && internalValue != null ? String(internalValue) : ""}
|
|
108
108
|
onChange={(evt) => {
|
|
109
109
|
const val = dataType === "number"
|
|
110
110
|
? parseFloat(evt.target.value)
|
|
@@ -118,26 +118,31 @@ export function StringNumberFilterField({
|
|
|
118
118
|
/>}
|
|
119
119
|
|
|
120
120
|
{enumValues &&
|
|
121
|
-
|
|
122
121
|
<Select
|
|
123
122
|
position={"item-aligned"}
|
|
124
123
|
value={internalValue !== undefined
|
|
125
124
|
? (Array.isArray(internalValue) ? internalValue.map(e => String(e)) : String(internalValue))
|
|
126
125
|
: isArray ? [] : ""}
|
|
127
126
|
onValueChange={(value) => {
|
|
128
|
-
|
|
127
|
+
if (value !== "")
|
|
128
|
+
updateFilter(operation, dataType === "number" ? parseInt(value as string) : value as string)
|
|
129
129
|
}}
|
|
130
130
|
multiple={multiple}
|
|
131
131
|
endAdornment={internalValue && <IconButton
|
|
132
|
-
className="absolute right-
|
|
132
|
+
className="absolute right-2 top-3"
|
|
133
133
|
onClick={(e) => updateFilter(operation, undefined)}>
|
|
134
134
|
<ClearIcon/>
|
|
135
135
|
</IconButton>}
|
|
136
|
-
renderValue={(enumKey) =>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
renderValue={(enumKey) => {
|
|
137
|
+
if (enumKey === null)
|
|
138
|
+
return "Filter for null values";
|
|
139
|
+
|
|
140
|
+
return <EnumValuesChip
|
|
141
|
+
key={`select_value_${name}_${enumKey}`}
|
|
142
|
+
enumKey={enumKey}
|
|
143
|
+
enumValues={enumValues}
|
|
144
|
+
size={"small"}/>;
|
|
145
|
+
}}>
|
|
141
146
|
{enumValues.map((enumConfig) => (
|
|
142
147
|
<SelectItem key={`select_value_${name}_${enumConfig.id}`}
|
|
143
148
|
value={String(enumConfig.id)}>
|
|
@@ -150,6 +155,21 @@ export function StringNumberFilterField({
|
|
|
150
155
|
</Select>
|
|
151
156
|
}
|
|
152
157
|
|
|
158
|
+
{!isArray && <Label
|
|
159
|
+
className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
|
|
160
|
+
htmlFor="null-filter"
|
|
161
|
+
>
|
|
162
|
+
<Checkbox id="null-filter"
|
|
163
|
+
checked={internalValue === null}
|
|
164
|
+
size={"small"}
|
|
165
|
+
onCheckedChange={(checked) => {
|
|
166
|
+
if (internalValue !== null)
|
|
167
|
+
updateFilter(operation, null);
|
|
168
|
+
else updateFilter(operation, undefined);
|
|
169
|
+
}}/>
|
|
170
|
+
Filter for null values
|
|
171
|
+
</Label>}
|
|
172
|
+
|
|
153
173
|
</div>
|
|
154
174
|
|
|
155
175
|
</div>
|
|
@@ -20,7 +20,7 @@ import { VirtualTableContextProps } from "./types";
|
|
|
20
20
|
import { VirtualTableHeaderRow } from "./VirtualTableHeaderRow";
|
|
21
21
|
import { VirtualTableRow } from "./VirtualTableRow";
|
|
22
22
|
import { VirtualTableCell } from "./VirtualTableCell";
|
|
23
|
-
import { AssignmentIcon,
|
|
23
|
+
import { AssignmentIcon, CenteredView, cn, Typography } from "@firecms/ui";
|
|
24
24
|
|
|
25
25
|
const VirtualListContext = createContext<VirtualTableContextProps<any>>({} as any);
|
|
26
26
|
VirtualListContext.displayName = "VirtualListContext";
|
|
@@ -225,24 +225,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
if (onFilterUpdate) onFilterUpdate(newFilterValue);
|
|
228
|
-
|
|
229
|
-
if (column.key !== sortByProperty) {
|
|
230
|
-
resetSort();
|
|
231
|
-
}
|
|
232
|
-
}, [checkFilterCombination, currentSort, onFilterUpdate, resetSort, sortByProperty]);
|
|
233
|
-
|
|
234
|
-
const buildErrorView = useCallback(() => (
|
|
235
|
-
<div
|
|
236
|
-
className="h-full flex flex-col items-center justify-center sticky left-0">
|
|
237
|
-
|
|
238
|
-
<Typography variant={"h6"}>
|
|
239
|
-
{"Error fetching data from the data source"}
|
|
240
|
-
</Typography>
|
|
241
|
-
|
|
242
|
-
{error?.message && <Markdown className={"px-4 break-all"} source={error.message}/>}
|
|
243
|
-
|
|
244
|
-
</div>
|
|
245
|
-
), [error?.message]);
|
|
228
|
+
}, [checkFilterCombination, currentSort, onFilterUpdate, sortByProperty]);
|
|
246
229
|
|
|
247
230
|
const buildEmptyView = useCallback(() => {
|
|
248
231
|
if (loading)
|
|
@@ -255,7 +238,18 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
255
238
|
}, [emptyComponent, loading]);
|
|
256
239
|
|
|
257
240
|
const empty = !loading && (data?.length ?? 0) === 0;
|
|
258
|
-
const customView = error
|
|
241
|
+
const customView = error
|
|
242
|
+
? <CenteredView maxWidth={"2xl"}
|
|
243
|
+
className="flex flex-col gap-2">
|
|
244
|
+
|
|
245
|
+
<Typography variant={"h6"}>
|
|
246
|
+
{"Error fetching data from the data source"}
|
|
247
|
+
</Typography>
|
|
248
|
+
|
|
249
|
+
{error?.message && <SafeLinkRenderer text={error.message}/>}
|
|
250
|
+
|
|
251
|
+
</CenteredView>
|
|
252
|
+
: (empty ? buildEmptyView() : undefined);
|
|
259
253
|
|
|
260
254
|
const virtualListController = {
|
|
261
255
|
data,
|
|
@@ -403,3 +397,17 @@ function MemoizedList({
|
|
|
403
397
|
{Row}
|
|
404
398
|
</List>;
|
|
405
399
|
}
|
|
400
|
+
|
|
401
|
+
const SafeLinkRenderer: React.FC<{
|
|
402
|
+
text: string;
|
|
403
|
+
}> = ({ text }) => {
|
|
404
|
+
const urlRegex = /https?:\/\/[^\s]+/g;
|
|
405
|
+
const htmlContent = text.replace(urlRegex, (url) => {
|
|
406
|
+
// For each URL found, replace it with an HTML <a> tag
|
|
407
|
+
return `<a href="${url}" class="underline" target="_blank">Link</a><br/>`;
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<div className={"break-all"} dangerouslySetInnerHTML={{ __html: htmlContent }}/>
|
|
412
|
+
);
|
|
413
|
+
};
|
|
@@ -252,7 +252,7 @@ export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [
|
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* Filter conditions in a `Query.where()` clause are specified using the
|
|
255
|
-
* strings
|
|
255
|
+
* strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
|
|
256
256
|
* @see Table
|
|
257
257
|
* @group Models
|
|
258
258
|
*/
|
|
@@ -25,7 +25,7 @@ export function VirtualTableDateField(props: {
|
|
|
25
25
|
return (
|
|
26
26
|
<DateTimeField
|
|
27
27
|
value={internalValue ?? undefined}
|
|
28
|
-
onChange={(dateValue) => updateValue(dateValue)}
|
|
28
|
+
onChange={(dateValue) => updateValue(dateValue ?? null)}
|
|
29
29
|
size={"medium"}
|
|
30
30
|
invisible={true}
|
|
31
31
|
className={"w-full h-full"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionSize,
|
|
1
|
+
import { CollectionSize, ResolvedProperty, SelectedCellProps } from "../../types";
|
|
2
2
|
|
|
3
3
|
export type EntityCollectionTableController<M extends Record<string, any>> = {
|
|
4
4
|
|
|
@@ -31,14 +31,12 @@ export type EntityCollectionTableController<M extends Record<string, any>> = {
|
|
|
31
31
|
* Props passed in a callback when the content of a cell in a table has been edited
|
|
32
32
|
* @group Collection components
|
|
33
33
|
*/
|
|
34
|
-
export interface OnCellValueChangeParams<T = any,
|
|
34
|
+
export interface OnCellValueChangeParams<T = any, D = any> {
|
|
35
35
|
value: T,
|
|
36
36
|
propertyKey: string,
|
|
37
|
-
|
|
37
|
+
data?: D,
|
|
38
38
|
onValueUpdated: () => void
|
|
39
|
-
setError: (e: Error) => void
|
|
40
|
-
fullPath: string
|
|
41
|
-
context: FireCMSContext
|
|
39
|
+
setError: (e: Error | undefined) => void
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
/**
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
User
|
|
13
13
|
} from "../../types";
|
|
14
14
|
import { useDebouncedData } from "./useDebouncedData";
|
|
15
|
+
import equal from "react-fast-compare"
|
|
15
16
|
|
|
16
17
|
const DEFAULT_PAGE_SIZE = 50;
|
|
17
18
|
|
|
@@ -31,6 +32,10 @@ export type DataSourceEntityCollectionTableControllerProps<M extends Record<stri
|
|
|
31
32
|
entitiesDisplayedFirst?: Entity<M>[];
|
|
32
33
|
|
|
33
34
|
lastDeleteTimestamp?: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Force filter to be applied to the table.
|
|
38
|
+
*/
|
|
34
39
|
forceFilter?: FilterValues<string>;
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -65,7 +70,7 @@ export function useDataSourceEntityCollectionTableController<M extends Record<st
|
|
|
65
70
|
|
|
66
71
|
const [popupCell, setPopupCell] = React.useState<SelectedCellProps<M> | undefined>(undefined);
|
|
67
72
|
const navigation = useNavigationController();
|
|
68
|
-
const dataSource = useDataSource();
|
|
73
|
+
const dataSource = useDataSource(collection);
|
|
69
74
|
const resolvedPath = useMemo(() => navigation.resolveAliasesFrom(fullPath), [fullPath, navigation.resolveAliasesFrom]);
|
|
70
75
|
|
|
71
76
|
const forceFilter = forceFilterFromProps ?? forceFilterFromCollection;
|
|
@@ -83,6 +88,12 @@ export function useDataSourceEntityCollectionTableController<M extends Record<st
|
|
|
83
88
|
return initialSort;
|
|
84
89
|
}, [initialSort, forceFilter]);
|
|
85
90
|
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!equal(forceFilter, filterValues)) {
|
|
93
|
+
setFilterValues(forceFilter)
|
|
94
|
+
}
|
|
95
|
+
}, [forceFilter]);
|
|
96
|
+
|
|
86
97
|
const [filterValues, setFilterValues] = React.useState<FilterValues<Extract<keyof M, string>> | undefined>(forceFilter ?? initialFilter ?? undefined);
|
|
87
98
|
const [sortBy, setSortBy] = React.useState<[Extract<keyof M, string>, "asc" | "desc"] | undefined>(initialSortInternal);
|
|
88
99
|
|
package/src/components/index.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { ErrorViewProps } from "./ErrorView";
|
|
2
2
|
export { ErrorView } from "./ErrorView";
|
|
3
3
|
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
4
|
+
export type { EntityViewProps } from "./EntityView";
|
|
5
|
+
export { EntityView } from "./EntityView";
|
|
6
6
|
|
|
7
7
|
export type { ReferenceSelectionInnerProps } from "./ReferenceTable/ReferenceSelectionTable";
|
|
8
8
|
export { ReferenceSelectionTable } from "./ReferenceTable/ReferenceSelectionTable";
|
|
@@ -15,6 +15,7 @@ export * from "./HomePage";
|
|
|
15
15
|
export * from "./SelectableTable/SelectableTable";
|
|
16
16
|
export * from "./EntityCollectionView/EntityCollectionView";
|
|
17
17
|
export * from "./EntityCollectionView/EntityCollectionViewActions";
|
|
18
|
+
export * from "./EntityCollectionView/useSelectionController";
|
|
18
19
|
|
|
19
20
|
export * from "./PropertyConfigBadge";
|
|
20
21
|
|
|
@@ -32,3 +33,4 @@ export * from "./FireCMSAppBar";
|
|
|
32
33
|
export * from "./ArrayContainer";
|
|
33
34
|
export * from "./ReferenceWidget";
|
|
34
35
|
export * from "./SearchIconsView";
|
|
36
|
+
export * from "./FieldCaption";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AuthController } from "../types";
|
|
3
3
|
|
|
4
|
-
export const AuthControllerContext = React.createContext<AuthController
|
|
4
|
+
export const AuthControllerContext = React.createContext<AuthController<any, any>>({} as AuthController<any, any>);
|
package/src/core/Drawer.tsx
CHANGED
|
@@ -2,37 +2,46 @@ import React, { useCallback } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useLargeLayout, useNavigationController } from "../hooks";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useNavigate } from "react-router-dom";
|
|
6
6
|
import { CMSAnalyticsEvent, TopNavigationEntry, TopNavigationResult } from "../types";
|
|
7
7
|
import { IconForView } from "../util";
|
|
8
|
-
import { cn, Tooltip, Typography } from "@firecms/ui";
|
|
8
|
+
import { cn, IconButton, Menu, MenuItem, MoreVertIcon, Tooltip, Typography } from "@firecms/ui";
|
|
9
9
|
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
10
|
+
import { useDrawer } from "./Scaffold";
|
|
11
|
+
import { DrawerNavigationItem } from "./DrawerNavigationItem";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Props used in case you need to override the default drawer
|
|
13
15
|
* @group Core
|
|
14
16
|
*/
|
|
15
|
-
export type DrawerProps
|
|
17
|
+
export type DrawerProps = {
|
|
16
18
|
hovered: boolean,
|
|
17
19
|
drawerOpen: boolean,
|
|
18
|
-
|
|
20
|
+
openDrawer: () => void,
|
|
21
|
+
closeDrawer: () => void,
|
|
22
|
+
autoOpenDrawer?: boolean
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Default drawer used in the CMS
|
|
23
27
|
* @group Core
|
|
24
28
|
*/
|
|
25
|
-
export function Drawer({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
export function Drawer() {
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
hovered,
|
|
33
|
+
drawerOpen,
|
|
34
|
+
closeDrawer,
|
|
35
|
+
} = useDrawer();
|
|
30
36
|
|
|
31
37
|
const analyticsController = useAnalyticsController();
|
|
32
38
|
const navigation = useNavigationController();
|
|
33
39
|
|
|
34
40
|
const tooltipsOpen = hovered && !drawerOpen;
|
|
35
41
|
const largeLayout = useLargeLayout();
|
|
42
|
+
const navigate = useNavigate();
|
|
43
|
+
|
|
44
|
+
const [adminMenuOpen, setAdminMenuOpen] = React.useState(false);
|
|
36
45
|
|
|
37
46
|
if (!navigation.topLevelNavigation)
|
|
38
47
|
throw Error("Navigation not ready in Drawer");
|
|
@@ -42,7 +51,8 @@ export function Drawer({
|
|
|
42
51
|
groups
|
|
43
52
|
}: TopNavigationResult = navigation.topLevelNavigation;
|
|
44
53
|
|
|
45
|
-
const
|
|
54
|
+
const adminViews = navigationEntries.filter(e => e.type === "admin") ?? [];
|
|
55
|
+
const groupsWithoutAdmin = groups.filter(g => g !== "Admin");
|
|
46
56
|
|
|
47
57
|
const buildGroupHeader = useCallback((group?: string) => {
|
|
48
58
|
if (!drawerOpen) return <div className="h-12 w-full"/>;
|
|
@@ -67,98 +77,63 @@ export function Drawer({
|
|
|
67
77
|
};
|
|
68
78
|
|
|
69
79
|
return (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
80
|
+
<>
|
|
81
|
+
|
|
82
|
+
<div className={"flex-grow overflow-scroll no-scrollbar"}>
|
|
83
|
+
|
|
84
|
+
{groupsWithoutAdmin.map((group) => (
|
|
85
|
+
<React.Fragment
|
|
86
|
+
key={`drawer_group_${group}`}>
|
|
87
|
+
{buildGroupHeader(group)}
|
|
88
|
+
{Object.values(navigationEntries)
|
|
89
|
+
.filter(e => e.group === group)
|
|
90
|
+
.map((view, index) =>
|
|
91
|
+
<DrawerNavigationItem
|
|
92
|
+
key={`navigation_${index}`}
|
|
93
|
+
icon={<IconForView collectionOrView={view.collection ?? view.view}/>}
|
|
94
|
+
tooltipsOpen={tooltipsOpen}
|
|
95
|
+
drawerOpen={drawerOpen}
|
|
96
|
+
onClick={() => onClick(view)}
|
|
97
|
+
url={view.url}
|
|
98
|
+
name={view.name}/>)}
|
|
99
|
+
</React.Fragment>
|
|
100
|
+
))}
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{adminViews.length > 0 && <Menu
|
|
105
|
+
open={adminMenuOpen}
|
|
106
|
+
onOpenChange={setAdminMenuOpen}
|
|
107
|
+
trigger={
|
|
108
|
+
<IconButton
|
|
109
|
+
shape={"square"}
|
|
110
|
+
className={"m-4 text-gray-900 dark:text-white w-fit"}>
|
|
111
|
+
<Tooltip title={"Admin"}
|
|
112
|
+
open={tooltipsOpen}
|
|
113
|
+
side={"right"} sideOffset={28}>
|
|
114
|
+
<MoreVertIcon/>
|
|
115
|
+
</Tooltip>
|
|
116
|
+
{drawerOpen && <div
|
|
117
|
+
className={cn(
|
|
118
|
+
drawerOpen ? "opacity-100" : "opacity-0 hidden",
|
|
119
|
+
"mx-4 font-inherit text-inherit"
|
|
120
|
+
)}>
|
|
121
|
+
ADMIN
|
|
122
|
+
</div>}
|
|
123
|
+
</IconButton>}
|
|
124
|
+
>
|
|
125
|
+
{adminViews.map((entry, index) =>
|
|
126
|
+
<MenuItem
|
|
127
|
+
onClick={(event) => {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
navigate(entry.path);
|
|
130
|
+
}}
|
|
131
|
+
key={`navigation_${index}`}>
|
|
132
|
+
{<IconForView collectionOrView={entry.view}/>}
|
|
133
|
+
{entry.name}
|
|
134
|
+
</MenuItem>)}
|
|
135
|
+
|
|
136
|
+
</Menu>}
|
|
137
|
+
</>
|
|
105
138
|
);
|
|
106
139
|
}
|
|
107
|
-
|
|
108
|
-
export function DrawerNavigationItem({
|
|
109
|
-
name,
|
|
110
|
-
icon,
|
|
111
|
-
drawerOpen,
|
|
112
|
-
tooltipsOpen,
|
|
113
|
-
url,
|
|
114
|
-
onClick
|
|
115
|
-
}: {
|
|
116
|
-
icon: React.ReactElement,
|
|
117
|
-
name: string,
|
|
118
|
-
tooltipsOpen: boolean,
|
|
119
|
-
drawerOpen: boolean,
|
|
120
|
-
url: string,
|
|
121
|
-
onClick?: () => void,
|
|
122
|
-
}) {
|
|
123
|
-
|
|
124
|
-
const iconWrap = <div
|
|
125
|
-
className={"text-gray-600 dark:text-gray-500"}>
|
|
126
|
-
{icon}
|
|
127
|
-
</div>;
|
|
128
|
-
|
|
129
|
-
const listItem = <NavLink
|
|
130
|
-
onClick={onClick}
|
|
131
|
-
style={{
|
|
132
|
-
width: !drawerOpen ? "72px" : "280px",
|
|
133
|
-
transition: drawerOpen ? "width 150ms ease-in" : undefined
|
|
134
|
-
}}
|
|
135
|
-
className={({ isActive }: any) => cn("rounded-r-xl truncate",
|
|
136
|
-
"hover:bg-slate-300 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-75 text-gray-800 dark:text-gray-200 hover:text-gray-900 hover:dark:text-gray-100",
|
|
137
|
-
"flex flex-row items-center mr-8",
|
|
138
|
-
// "transition-all ease-in-out delay-100 duration-300",
|
|
139
|
-
// drawerOpen ? "w-full" : "w-18",
|
|
140
|
-
drawerOpen ? "pl-8 h-12" : "pl-6 h-11",
|
|
141
|
-
"font-medium text-sm",
|
|
142
|
-
isActive ? "bg-slate-200 bg-opacity-75 dark:bg-gray-800" : ""
|
|
143
|
-
)}
|
|
144
|
-
to={url}
|
|
145
|
-
>
|
|
146
|
-
|
|
147
|
-
{iconWrap}
|
|
148
|
-
|
|
149
|
-
<div
|
|
150
|
-
className={cn(
|
|
151
|
-
drawerOpen ? "opacity-100" : "opacity-0 hidden",
|
|
152
|
-
"ml-4 font-inherit text-inherit"
|
|
153
|
-
)}>
|
|
154
|
-
{name.toUpperCase()}
|
|
155
|
-
</div>
|
|
156
|
-
</NavLink>;
|
|
157
|
-
|
|
158
|
-
return <Tooltip
|
|
159
|
-
open={drawerOpen ? false : tooltipsOpen}
|
|
160
|
-
side="right"
|
|
161
|
-
title={name}>
|
|
162
|
-
{listItem}
|
|
163
|
-
</Tooltip>;
|
|
164
|
-
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { NavLink } from "react-router-dom";
|
|
4
|
+
import { cn, Tooltip } from "@firecms/ui";
|
|
5
|
+
|
|
6
|
+
export function DrawerNavigationItem({
|
|
7
|
+
name,
|
|
8
|
+
icon,
|
|
9
|
+
drawerOpen,
|
|
10
|
+
tooltipsOpen,
|
|
11
|
+
url,
|
|
12
|
+
onClick
|
|
13
|
+
}: {
|
|
14
|
+
icon: React.ReactElement,
|
|
15
|
+
name: string,
|
|
16
|
+
tooltipsOpen: boolean,
|
|
17
|
+
drawerOpen: boolean,
|
|
18
|
+
url: string,
|
|
19
|
+
onClick?: () => void,
|
|
20
|
+
}) {
|
|
21
|
+
|
|
22
|
+
const iconWrap = <div
|
|
23
|
+
className={"text-gray-600 dark:text-gray-500"}>
|
|
24
|
+
{icon}
|
|
25
|
+
</div>;
|
|
26
|
+
|
|
27
|
+
const listItem = <NavLink
|
|
28
|
+
onClick={onClick}
|
|
29
|
+
style={{
|
|
30
|
+
width: !drawerOpen ? "72px" : "280px",
|
|
31
|
+
transition: drawerOpen ? "width 150ms ease-in" : undefined
|
|
32
|
+
}}
|
|
33
|
+
className={({ isActive }: any) => cn("rounded-r-lg truncate",
|
|
34
|
+
"hover:bg-slate-300 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-75 text-gray-800 dark:text-gray-200 hover:text-gray-900 hover:dark:text-white",
|
|
35
|
+
"flex flex-row items-center mr-8",
|
|
36
|
+
// "transition-all ease-in-out delay-100 duration-300",
|
|
37
|
+
// drawerOpen ? "w-full" : "w-18",
|
|
38
|
+
drawerOpen ? "pl-8 h-12" : "pl-6 h-11",
|
|
39
|
+
"font-medium text-sm",
|
|
40
|
+
isActive ? "bg-slate-200 bg-opacity-60 dark:bg-gray-800 dark:bg-opacity-30" : ""
|
|
41
|
+
)}
|
|
42
|
+
to={url}
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
{iconWrap}
|
|
46
|
+
|
|
47
|
+
<div
|
|
48
|
+
className={cn(
|
|
49
|
+
drawerOpen ? "opacity-100" : "opacity-0 hidden",
|
|
50
|
+
"ml-4 font-inherit text-inherit"
|
|
51
|
+
)}>
|
|
52
|
+
{name.toUpperCase()}
|
|
53
|
+
</div>
|
|
54
|
+
</NavLink>;
|
|
55
|
+
|
|
56
|
+
return <Tooltip
|
|
57
|
+
open={drawerOpen ? false : tooltipsOpen}
|
|
58
|
+
side="right"
|
|
59
|
+
title={name}>
|
|
60
|
+
{listItem}
|
|
61
|
+
</Tooltip>;
|
|
62
|
+
}
|