@firecms/core 3.0.0-canary.7 → 3.0.0-canary.71
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/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/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/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +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 +26 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- 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/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +6 -7
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +6 -3
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +5 -8
- package/dist/core/DefaultDrawer.d.ts +19 -0
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/EntityEditView.d.ts +36 -0
- package/dist/core/NavigationRoutes.d.ts +2 -2
- package/dist/core/index.d.ts +3 -4
- package/dist/form/PropertiesForm.d.ts +8 -0
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +3 -3
- package/dist/form/components/StorageItemPreview.d.ts +2 -3
- 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 +3 -4
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/index.d.ts +0 -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.d.ts +1 -0
- package/dist/index.es.js +10507 -9993
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -16
- package/dist/preview/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 +3 -8
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +44 -6
- package/dist/types/datasource.d.ts +21 -14
- 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/fields.d.ts +31 -30
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +15 -14
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +22 -22
- package/dist/types/properties.d.ts +13 -5
- 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 +1 -97
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +14 -14
- package/dist/util/storage.d.ts +23 -2
- package/dist/util/useStorageUploadController.d.ts +1 -1
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +25 -0
- package/src/app/Scaffold.tsx +249 -0
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +32 -0
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +276 -279
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +48 -45
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +18 -17
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -5
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +75 -74
- 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 +209 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- 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 +22 -12
- package/src/components/SearchIconsView.tsx +5 -5
- package/src/components/SelectableTable/SelectableTable.tsx +5 -3
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +38 -29
- package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableProps.tsx +7 -7
- package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +11 -7
- package/src/components/common/index.ts +1 -0
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useColumnsIds.tsx +10 -2
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/common/useTableSearchHelper.ts +39 -9
- package/src/components/index.tsx +6 -3
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +51 -34
- package/src/core/DefaultDrawer.tsx +177 -0
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/EntityEditView.tsx +1100 -0
- package/src/core/EntitySidePanel.tsx +3 -4
- package/src/core/FireCMS.tsx +54 -43
- package/src/core/NavigationRoutes.tsx +14 -7
- package/src/core/field_configs.tsx +2 -3
- package/src/core/index.tsx +3 -4
- package/src/form/PropertiesForm.tsx +81 -0
- package/src/form/PropertyFieldBinding.tsx +29 -7
- package/src/form/components/FieldHelperText.tsx +3 -3
- package/src/form/components/StorageItemPreview.tsx +5 -7
- package/src/form/components/StorageUploadProgress.tsx +9 -8
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +10 -12
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +19 -19
- package/src/form/field_bindings/MapFieldBinding.tsx +25 -17
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -9
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +16 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -35
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/index.tsx +4 -4
- package/src/form/validation.ts +4 -21
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +4 -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 +8 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +200 -83
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/index.ts +1 -0
- package/src/internal/useBuildDataSource.ts +54 -47
- package/src/internal/useBuildSideEntityController.tsx +88 -21
- package/src/preview/PropertyPreview.tsx +5 -15
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +2 -2
- package/src/preview/components/ReferencePreview.tsx +72 -165
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +51 -6
- package/src/types/customization_controller.tsx +0 -1
- package/src/types/datasource.ts +24 -17
- 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/fields.tsx +33 -33
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -17
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +28 -30
- package/src/types/properties.ts +19 -7
- 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 +2 -1
- package/src/util/enums.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +3 -99
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +8 -21
- package/src/util/permissions.ts +12 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +32 -31
- package/src/util/storage.ts +75 -21
- package/src/util/strings.ts +2 -2
- package/src/util/useStorageUploadController.tsx +21 -3
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/components/VirtualTable/common.d.ts +0 -2
- package/dist/core/Drawer.d.ts +0 -23
- package/dist/core/EntityView.d.ts +0 -22
- package/dist/core/Scaffold.d.ts +0 -55
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/form/EntityForm.d.ts +0 -77
- 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/Drawer.tsx +0 -164
- package/src/core/EntityView.tsx +0 -578
- package/src/core/Scaffold.tsx +0 -281
- package/src/core/SideEntityView.tsx +0 -38
- package/src/form/EntityForm.tsx +0 -720
- package/src/internal/useBuildCustomizationController.tsx +0 -5
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
|
@@ -24,16 +24,15 @@ import { getPreviewSizeFrom } from "../../preview/util";
|
|
|
24
24
|
import { isReadOnly } from "../../util";
|
|
25
25
|
|
|
26
26
|
import { CustomFieldValidator, mapPropertyToYup } from "../../form/validation";
|
|
27
|
-
import { useFireCMSContext } from "../../hooks";
|
|
28
27
|
|
|
29
28
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
30
29
|
import { EntityTableCellActions } from "./internal/EntityTableCellActions";
|
|
31
30
|
|
|
32
|
-
import { getRowHeight } from "../VirtualTable/common";
|
|
33
31
|
import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
|
|
34
32
|
import { useClearRestoreValue } from "../../form/useClearRestoreValue";
|
|
33
|
+
import { getRowHeight } from "../common/table_height";
|
|
35
34
|
|
|
36
|
-
export interface PropertyTableCellProps<T extends CMSType
|
|
35
|
+
export interface PropertyTableCellProps<T extends CMSType> {
|
|
37
36
|
propertyKey: string;
|
|
38
37
|
columnIndex: number;
|
|
39
38
|
align: "right" | "left" | "center";
|
|
@@ -46,6 +45,7 @@ export interface PropertyTableCellProps<T extends CMSType, M extends Record<stri
|
|
|
46
45
|
entity: Entity<any>;
|
|
47
46
|
path: string;
|
|
48
47
|
disabled: boolean;
|
|
48
|
+
enablePopupIcon?: boolean;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function isStorageProperty(property: ResolvedProperty) {
|
|
@@ -62,7 +62,7 @@ function isStorageProperty(property: ResolvedProperty) {
|
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export const PropertyTableCell = React.memo<PropertyTableCellProps<any
|
|
65
|
+
export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
66
66
|
function PropertyTableCell<T extends CMSType, M extends Record<string, any>>({
|
|
67
67
|
propertyKey,
|
|
68
68
|
customFieldValidator,
|
|
@@ -74,10 +74,9 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
74
74
|
path,
|
|
75
75
|
entity,
|
|
76
76
|
readonly,
|
|
77
|
-
disabled: disabledProp
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const context = useFireCMSContext();
|
|
77
|
+
disabled: disabledProp,
|
|
78
|
+
enablePopupIcon = true
|
|
79
|
+
}: PropertyTableCellProps<T>) {
|
|
81
80
|
|
|
82
81
|
const {
|
|
83
82
|
onValueChange,
|
|
@@ -95,6 +94,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
95
94
|
const internalValueRef = useRef(value);
|
|
96
95
|
|
|
97
96
|
const [error, setError] = useState<Error | undefined>();
|
|
97
|
+
const [validationError, setValidationError] = useState<Error | undefined>();
|
|
98
98
|
const [saved, setSaved] = useState<boolean>(false);
|
|
99
99
|
|
|
100
100
|
const onValueUpdated = useCallback(() => {
|
|
@@ -120,7 +120,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
120
120
|
useEffect(
|
|
121
121
|
() => {
|
|
122
122
|
if (!equal(value, internalValueRef.current)) {
|
|
123
|
-
|
|
123
|
+
setValidationError(undefined);
|
|
124
124
|
setInternalValue(value);
|
|
125
125
|
internalValueRef.current = value;
|
|
126
126
|
onValueUpdated();
|
|
@@ -136,32 +136,34 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
136
136
|
validation
|
|
137
137
|
.validate(value)
|
|
138
138
|
.then(() => {
|
|
139
|
-
|
|
139
|
+
setValidationError(undefined);
|
|
140
140
|
internalValueRef.current = value;
|
|
141
141
|
if (onValueChange) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
})
|
|
142
|
+
try {
|
|
143
|
+
onValueChange({
|
|
144
|
+
value,
|
|
145
|
+
propertyKey,
|
|
146
|
+
setError,
|
|
147
|
+
onValueUpdated,
|
|
148
|
+
data: entity,
|
|
149
|
+
});
|
|
150
|
+
} catch (e:any) {
|
|
151
|
+
console.error("onValueChange error", e);
|
|
152
|
+
setError(e);
|
|
153
|
+
}
|
|
154
|
+
|
|
151
155
|
}
|
|
152
156
|
})
|
|
153
157
|
.catch((e) => {
|
|
154
|
-
|
|
158
|
+
setValidationError(e);
|
|
155
159
|
});
|
|
156
160
|
};
|
|
157
161
|
|
|
158
162
|
useEffect(() => {
|
|
159
163
|
validation
|
|
160
164
|
.validate(internalValue)
|
|
161
|
-
.then(() =>
|
|
162
|
-
.catch(
|
|
163
|
-
setError(e);
|
|
164
|
-
});
|
|
165
|
+
.then(() => setValidationError(undefined))
|
|
166
|
+
.catch(setValidationError);
|
|
165
167
|
}, [internalValue, validation, propertyKey, property, entity]);
|
|
166
168
|
|
|
167
169
|
const updateValue = (newValue: any | null) => {
|
|
@@ -237,7 +239,6 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
237
239
|
height={getRowHeight(size)}
|
|
238
240
|
propertyKey={propertyKey}
|
|
239
241
|
property={property}
|
|
240
|
-
// entity={entity}
|
|
241
242
|
value={internalValue}
|
|
242
243
|
size={getPreviewSizeFrom(size)}
|
|
243
244
|
/>
|
|
@@ -247,7 +248,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
247
248
|
if (!customField && (!customPreview || selected)) {
|
|
248
249
|
const isAStorageProperty = isStorageProperty(property);
|
|
249
250
|
if (isAStorageProperty) {
|
|
250
|
-
innerComponent = <TableStorageUpload error={error}
|
|
251
|
+
innerComponent = <TableStorageUpload error={validationError ?? error}
|
|
251
252
|
disabled={disabled}
|
|
252
253
|
focused={selected}
|
|
253
254
|
selected={selected}
|
|
@@ -274,7 +275,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
274
275
|
valueType={"number"}
|
|
275
276
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
276
277
|
enumValues={numberProperty.enumValues}
|
|
277
|
-
error={error}
|
|
278
|
+
error={validationError ?? error}
|
|
278
279
|
internalValue={internalValue as string | number}
|
|
279
280
|
updateValue={updateValue}
|
|
280
281
|
/>;
|
|
@@ -282,7 +283,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
282
283
|
} else {
|
|
283
284
|
innerComponent = <VirtualTableNumberInput
|
|
284
285
|
align={align}
|
|
285
|
-
error={error}
|
|
286
|
+
error={validationError ?? error}
|
|
286
287
|
focused={selected}
|
|
287
288
|
disabled={disabled}
|
|
288
289
|
value={internalValue as number}
|
|
@@ -300,14 +301,14 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
300
301
|
valueType={"string"}
|
|
301
302
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
302
303
|
enumValues={stringProperty.enumValues}
|
|
303
|
-
error={error}
|
|
304
|
+
error={validationError ?? error}
|
|
304
305
|
internalValue={internalValue as string | number}
|
|
305
306
|
updateValue={updateValue}
|
|
306
307
|
/>;
|
|
307
308
|
fullHeight = true;
|
|
308
309
|
} else if (!stringProperty.storage) {
|
|
309
310
|
const multiline = Boolean(stringProperty.multiline) || Boolean(stringProperty.markdown);
|
|
310
|
-
innerComponent = <VirtualTableInput error={error}
|
|
311
|
+
innerComponent = <VirtualTableInput error={validationError ?? error}
|
|
311
312
|
disabled={disabled}
|
|
312
313
|
multiline={multiline}
|
|
313
314
|
focused={selected}
|
|
@@ -317,7 +318,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
317
318
|
allowScroll = true;
|
|
318
319
|
}
|
|
319
320
|
} else if (property.dataType === "boolean") {
|
|
320
|
-
innerComponent = <VirtualTableSwitch error={error}
|
|
321
|
+
innerComponent = <VirtualTableSwitch error={validationError ?? error}
|
|
321
322
|
disabled={disabled}
|
|
322
323
|
focused={selected}
|
|
323
324
|
internalValue={internalValue as boolean}
|
|
@@ -325,7 +326,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
325
326
|
/>;
|
|
326
327
|
} else if (property.dataType === "date") {
|
|
327
328
|
innerComponent = <VirtualTableDateField name={propertyKey as string}
|
|
328
|
-
error={error}
|
|
329
|
+
error={validationError ?? error}
|
|
329
330
|
disabled={disabled}
|
|
330
331
|
mode={property.mode}
|
|
331
332
|
focused={selected}
|
|
@@ -346,6 +347,8 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
346
347
|
path={property.path}
|
|
347
348
|
multiselect={false}
|
|
348
349
|
previewProperties={property.previewProperties}
|
|
350
|
+
includeId={property.includeId}
|
|
351
|
+
includeEntityLink={property.includeEntityLink}
|
|
349
352
|
title={property.name}
|
|
350
353
|
forceFilter={property.forceFilter}
|
|
351
354
|
/>;
|
|
@@ -368,7 +371,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
368
371
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
369
372
|
valueType={arrayProperty.of.dataType}
|
|
370
373
|
enumValues={arrayProperty.of.enumValues}
|
|
371
|
-
error={error}
|
|
374
|
+
error={validationError ?? error}
|
|
372
375
|
internalValue={internalValue as string | number}
|
|
373
376
|
updateValue={updateValue}
|
|
374
377
|
/>;
|
|
@@ -390,6 +393,8 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
390
393
|
previewProperties={arrayProperty.of.previewProperties}
|
|
391
394
|
title={arrayProperty.name}
|
|
392
395
|
forceFilter={arrayProperty.of.forceFilter}
|
|
396
|
+
includeId={arrayProperty.of.includeId}
|
|
397
|
+
includeEntityLink={arrayProperty.of.includeEntityLink}
|
|
393
398
|
/>;
|
|
394
399
|
}
|
|
395
400
|
allowScroll = false;
|
|
@@ -401,16 +406,14 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
401
406
|
|
|
402
407
|
if (!innerComponent) {
|
|
403
408
|
allowScroll = false;
|
|
404
|
-
showExpandIcon = selected && !innerComponent && !disabled && !readOnlyProperty;
|
|
409
|
+
showExpandIcon = enablePopupIcon && selected && !innerComponent && !disabled && !readOnlyProperty;
|
|
405
410
|
innerComponent = (
|
|
406
|
-
<PropertyPreview
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
property={property}
|
|
413
|
-
size={getPreviewSizeFrom(size)}
|
|
411
|
+
<PropertyPreview width={width}
|
|
412
|
+
height={height}
|
|
413
|
+
propertyKey={propertyKey as string}
|
|
414
|
+
value={internalValue}
|
|
415
|
+
property={property}
|
|
416
|
+
size={getPreviewSizeFrom(size)}
|
|
414
417
|
/>
|
|
415
418
|
);
|
|
416
419
|
}
|
|
@@ -427,7 +430,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
427
430
|
removePadding={removePadding}
|
|
428
431
|
fullHeight={fullHeight}
|
|
429
432
|
saved={saved}
|
|
430
|
-
error={error}
|
|
433
|
+
error={validationError ?? error}
|
|
431
434
|
align={align}
|
|
432
435
|
allowScroll={allowScroll}
|
|
433
436
|
showExpandIcon={showExpandIcon}
|
|
@@ -447,9 +450,9 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
447
450
|
);
|
|
448
451
|
|
|
449
452
|
},
|
|
450
|
-
areEqual) as React.FunctionComponent<PropertyTableCellProps<any
|
|
453
|
+
areEqual) as React.FunctionComponent<PropertyTableCellProps<any>>;
|
|
451
454
|
|
|
452
|
-
function areEqual(prevProps: PropertyTableCellProps<any
|
|
455
|
+
function areEqual(prevProps: PropertyTableCellProps<any>, nextProps: PropertyTableCellProps<any>) {
|
|
453
456
|
return prevProps.height === nextProps.height &&
|
|
454
457
|
prevProps.propertyKey === nextProps.propertyKey &&
|
|
455
458
|
prevProps.align === nextProps.align &&
|
|
@@ -21,7 +21,6 @@ export interface PropertiesToColumnsParams<M extends Record<string, any>> {
|
|
|
21
21
|
properties: ResolvedProperties<M>;
|
|
22
22
|
sortable?: boolean;
|
|
23
23
|
forceFilter?: FilterValues<keyof M extends string ? keyof M : never>;
|
|
24
|
-
disabledFilter?: boolean;
|
|
25
24
|
AdditionalHeaderWidget?: React.ComponentType<{
|
|
26
25
|
property: ResolvedProperty,
|
|
27
26
|
propertyKey: string,
|
|
@@ -29,7 +28,8 @@ export interface PropertiesToColumnsParams<M extends Record<string, any>> {
|
|
|
29
28
|
}>;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
export function propertiesToColumns<M extends Record<string, any>>({ properties, sortable, forceFilter,
|
|
31
|
+
export function propertiesToColumns<M extends Record<string, any>>({ properties, sortable, forceFilter, AdditionalHeaderWidget }: PropertiesToColumnsParams<M>): VirtualTableColumn[] {
|
|
32
|
+
const disabledFilter = Boolean(forceFilter);
|
|
33
33
|
return Object.entries<ResolvedProperty>(properties)
|
|
34
34
|
.flatMap(([key, property]) => getColumnKeysForProperty(property, key))
|
|
35
35
|
.map(({
|
|
@@ -45,7 +45,7 @@ export function propertiesToColumns<M extends Record<string, any>>({ properties,
|
|
|
45
45
|
align: getTableCellAlignment(property),
|
|
46
46
|
icon: getIconForProperty(property, "small"),
|
|
47
47
|
title: property.name ?? key as string,
|
|
48
|
-
sortable: sortable
|
|
48
|
+
sortable: sortable,
|
|
49
49
|
filter: !disabledFilter && filterable,
|
|
50
50
|
width: getTablePropertyColumnWidth(property),
|
|
51
51
|
resizable: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
2
|
import equal from "react-fast-compare"
|
|
3
3
|
|
|
4
|
-
import { ReferencePreview
|
|
4
|
+
import { ReferencePreview } from "../../../preview";
|
|
5
5
|
import { CollectionSize, Entity, EntityCollection, EntityReference, FilterValues } from "../../../types";
|
|
6
6
|
|
|
7
7
|
import { getPreviewSizeFrom } from "../../../preview/util";
|
|
@@ -9,6 +9,7 @@ import { getReferenceFrom } from "../../../util";
|
|
|
9
9
|
import { useCustomizationController, useNavigationController, useReferenceDialog } from "../../../hooks";
|
|
10
10
|
import { ErrorView } from "../../ErrorView";
|
|
11
11
|
import { Button } from "@firecms/ui";
|
|
12
|
+
import { EntityPreviewContainer } from "../../EntityPreview";
|
|
12
13
|
|
|
13
14
|
type TableReferenceFieldProps = {
|
|
14
15
|
name: string;
|
|
@@ -21,6 +22,8 @@ type TableReferenceFieldProps = {
|
|
|
21
22
|
title?: string;
|
|
22
23
|
path: string;
|
|
23
24
|
forceFilter?: FilterValues<string>;
|
|
25
|
+
includeId?: boolean;
|
|
26
|
+
includeEntityLink?: boolean;
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
export function TableReferenceField(props: TableReferenceFieldProps) {
|
|
@@ -28,7 +31,7 @@ export function TableReferenceField(props: TableReferenceFieldProps) {
|
|
|
28
31
|
|
|
29
32
|
const navigationController = useNavigationController();
|
|
30
33
|
const { path } = props;
|
|
31
|
-
const collection = navigationController.getCollection
|
|
34
|
+
const collection = navigationController.getCollection(path);
|
|
32
35
|
if (!collection) {
|
|
33
36
|
if (customizationController.components?.missingReference) {
|
|
34
37
|
return <customizationController.components.missingReference path={path}/>;
|
|
@@ -54,14 +57,11 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
54
57
|
title,
|
|
55
58
|
disabled,
|
|
56
59
|
forceFilter,
|
|
57
|
-
collection
|
|
60
|
+
collection,
|
|
61
|
+
includeId,
|
|
62
|
+
includeEntityLink
|
|
58
63
|
} = props;
|
|
59
64
|
|
|
60
|
-
const [onHover, setOnHover] = useState(false);
|
|
61
|
-
|
|
62
|
-
const hoverTrue = useCallback(() => setOnHover(true), []);
|
|
63
|
-
const hoverFalse = useCallback(() => setOnHover(false), []);
|
|
64
|
-
|
|
65
65
|
const onSingleEntitySelected = useCallback((entity: Entity<any>) => {
|
|
66
66
|
updateValue(entity ? getReferenceFrom(entity) : null);
|
|
67
67
|
}, [updateValue]);
|
|
@@ -101,31 +101,35 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
101
101
|
onClick={disabled ? undefined : handleOpen}
|
|
102
102
|
size={getPreviewSizeFrom(size)}
|
|
103
103
|
reference={internalValue as EntityReference}
|
|
104
|
-
|
|
104
|
+
hover={!disabled}
|
|
105
105
|
disabled={!path}
|
|
106
106
|
previewProperties={previewProperties}
|
|
107
|
+
includeId={includeId}
|
|
108
|
+
includeEntityLink={includeEntityLink}
|
|
107
109
|
/>;
|
|
108
110
|
else
|
|
109
|
-
return <
|
|
111
|
+
return <EntityPreviewContainer
|
|
110
112
|
onClick={disabled ? undefined : handleOpen}
|
|
111
113
|
size={getPreviewSizeFrom(size)}>
|
|
112
114
|
<ErrorView title="Value is not a reference." error={"Click to edit"}/>
|
|
113
|
-
</
|
|
115
|
+
</EntityPreviewContainer>;
|
|
114
116
|
};
|
|
115
117
|
|
|
116
118
|
const buildMultipleReferenceField = () => {
|
|
117
119
|
if (Array.isArray(internalValue))
|
|
118
120
|
return <>
|
|
119
121
|
{internalValue.map((reference, index) =>
|
|
120
|
-
<div className="
|
|
122
|
+
<div className="w-full my-0.5"
|
|
121
123
|
key={`preview_array_ref_${name}_${index}`}>
|
|
122
124
|
<ReferencePreview
|
|
123
125
|
onClick={disabled ? undefined : handleOpen}
|
|
124
126
|
size={"tiny"}
|
|
125
127
|
reference={reference}
|
|
126
|
-
|
|
128
|
+
hover={!disabled}
|
|
127
129
|
disabled={!path}
|
|
128
130
|
previewProperties={previewProperties}
|
|
131
|
+
includeId={includeId}
|
|
132
|
+
includeEntityLink={includeEntityLink}
|
|
129
133
|
/>
|
|
130
134
|
</div>
|
|
131
135
|
)
|
|
@@ -139,10 +143,7 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
139
143
|
return <ErrorView error={"The specified collection does not exist"}/>;
|
|
140
144
|
|
|
141
145
|
return (
|
|
142
|
-
<div className="w-full"
|
|
143
|
-
onMouseEnter={hoverTrue}
|
|
144
|
-
onMouseMove={hoverTrue}
|
|
145
|
-
onMouseLeave={hoverFalse}>
|
|
146
|
+
<div className="w-full group">
|
|
146
147
|
|
|
147
148
|
{internalValue && !multiselect && buildSingleReferenceField()}
|
|
148
149
|
|
|
@@ -9,7 +9,7 @@ import { useSnackbarController, useStorageSource } from "../../../hooks";
|
|
|
9
9
|
import { getThumbnailMeasure } from "../../../preview/util";
|
|
10
10
|
import { StorageFieldItem, useStorageUploadController } from "../../../util/useStorageUploadController";
|
|
11
11
|
import { StorageUploadProgress } from "../../../form/components/StorageUploadProgress";
|
|
12
|
-
import {
|
|
12
|
+
import { cls, EditIcon, IconButton, Typography } from "@firecms/ui";
|
|
13
13
|
import { EntityTableCellActions } from "../internal/EntityTableCellActions";
|
|
14
14
|
|
|
15
15
|
const dropZoneClasses = "max-w-full box-border relative pt-[2px] items-center border border-transparent outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid";
|
|
@@ -51,7 +51,7 @@ export function TableStorageUpload(props: {
|
|
|
51
51
|
entity,
|
|
52
52
|
path,
|
|
53
53
|
previewSize,
|
|
54
|
-
updateValue
|
|
54
|
+
updateValue,
|
|
55
55
|
} = props;
|
|
56
56
|
|
|
57
57
|
const storageSource = useStorageSource();
|
|
@@ -137,7 +137,7 @@ function StorageUpload({
|
|
|
137
137
|
storage,
|
|
138
138
|
onFilesAdded,
|
|
139
139
|
onFileUploadComplete,
|
|
140
|
-
storagePathBuilder
|
|
140
|
+
storagePathBuilder,
|
|
141
141
|
}: StorageUploadProps) {
|
|
142
142
|
|
|
143
143
|
const [onHover, setOnHover] = useState(false);
|
|
@@ -207,7 +207,7 @@ function StorageUpload({
|
|
|
207
207
|
onMouseEnter={() => setOnHover(true)}
|
|
208
208
|
onMouseMove={() => setOnHover(true)}
|
|
209
209
|
onMouseLeave={() => setOnHover(false)}
|
|
210
|
-
className={
|
|
210
|
+
className={cls(dropZoneClasses,
|
|
211
211
|
"relative w-full h-full flex",
|
|
212
212
|
`justify-${hasValue ? "start" : "center"}`,
|
|
213
213
|
isDragActive ? activeDropClasses : "",
|
|
@@ -293,7 +293,7 @@ export function TableStorageItemPreview({
|
|
|
293
293
|
|
|
294
294
|
return (
|
|
295
295
|
<div
|
|
296
|
-
className={"relative
|
|
296
|
+
className={"relative p-2 max-w-full"}
|
|
297
297
|
>
|
|
298
298
|
|
|
299
299
|
{value &&
|
|
@@ -3,7 +3,7 @@ import React, { useEffect } from "react";
|
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
5
5
|
CircularProgress,
|
|
6
|
-
|
|
6
|
+
cls,
|
|
7
7
|
defaultBorderMixin,
|
|
8
8
|
FilterListOffIcon,
|
|
9
9
|
SearchBar,
|
|
@@ -16,20 +16,27 @@ import { useLargeLayout } from "../../../hooks";
|
|
|
16
16
|
|
|
17
17
|
interface CollectionTableToolbarProps {
|
|
18
18
|
size: CollectionSize;
|
|
19
|
-
filterIsSet: boolean;
|
|
20
19
|
loading: boolean;
|
|
21
|
-
forceFilter?: boolean;
|
|
22
20
|
actionsStart?: React.ReactNode;
|
|
23
21
|
actions?: React.ReactNode;
|
|
24
22
|
title?: React.ReactNode,
|
|
25
23
|
onTextSearchClick?: () => void;
|
|
26
24
|
onTextSearch?: (searchString?: string) => void;
|
|
27
25
|
onSizeChanged: (size: CollectionSize) => void;
|
|
28
|
-
clearFilter?: () => void;
|
|
29
26
|
textSearchLoading?: boolean;
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
export function CollectionTableToolbar(
|
|
29
|
+
export function CollectionTableToolbar({
|
|
30
|
+
actions,
|
|
31
|
+
actionsStart,
|
|
32
|
+
loading,
|
|
33
|
+
onSizeChanged,
|
|
34
|
+
onTextSearch,
|
|
35
|
+
onTextSearchClick,
|
|
36
|
+
size,
|
|
37
|
+
textSearchLoading,
|
|
38
|
+
title
|
|
39
|
+
}: CollectionTableToolbarProps) {
|
|
33
40
|
|
|
34
41
|
const searchInputRef = React.useRef<HTMLInputElement>(null);
|
|
35
42
|
const largeLayout = useLargeLayout();
|
|
@@ -37,30 +44,20 @@ export function CollectionTableToolbar(props: CollectionTableToolbarProps) {
|
|
|
37
44
|
const searchLoading = React.useRef<boolean>(false);
|
|
38
45
|
|
|
39
46
|
useEffect(() => {
|
|
40
|
-
if (searchInputRef.current && searchLoading.current && !
|
|
47
|
+
if (searchInputRef.current && searchLoading.current && !textSearchLoading) {
|
|
41
48
|
searchInputRef.current.focus();
|
|
42
49
|
}
|
|
43
|
-
searchLoading.current =
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
const clearFilterButton = !props.forceFilter && props.filterIsSet && props.clearFilter &&
|
|
47
|
-
<Button
|
|
48
|
-
variant={"outlined"}
|
|
49
|
-
className="h-fit-content"
|
|
50
|
-
aria-label="filter clear"
|
|
51
|
-
onClick={props.clearFilter}
|
|
52
|
-
size="small">
|
|
53
|
-
<FilterListOffIcon/>
|
|
54
|
-
Clear filter
|
|
55
|
-
</Button>;
|
|
50
|
+
searchLoading.current = textSearchLoading ?? false;
|
|
51
|
+
}, [textSearchLoading]);
|
|
52
|
+
|
|
56
53
|
|
|
57
54
|
const sizeSelect = (
|
|
58
55
|
<Tooltip title={"Table row size"} side={"right"} sideOffset={4}>
|
|
59
56
|
<Select
|
|
60
|
-
value={
|
|
57
|
+
value={size as string}
|
|
61
58
|
className="w-16 h-10"
|
|
62
59
|
size={"small"}
|
|
63
|
-
onValueChange={(v) =>
|
|
60
|
+
onValueChange={(v) => onSizeChanged(v as CollectionSize)}
|
|
64
61
|
renderValue={(v) => <div className={"font-medium"}>{v.toUpperCase()}</div>}
|
|
65
62
|
>
|
|
66
63
|
{["xs", "s", "m", "l", "xl"].map((size) => (
|
|
@@ -74,40 +71,38 @@ export function CollectionTableToolbar(props: CollectionTableToolbarProps) {
|
|
|
74
71
|
|
|
75
72
|
return (
|
|
76
73
|
<div
|
|
77
|
-
className={
|
|
74
|
+
className={cls(defaultBorderMixin, "no-scrollbar min-h-[56px] overflow-x-auto px-2 md:px-4 bg-gray-50 dark:bg-gray-900 border-b flex flex-row justify-between items-center w-full")}>
|
|
78
75
|
|
|
79
76
|
<div className="flex items-center gap-2 md:mr-4 mr-2">
|
|
80
77
|
|
|
81
|
-
{
|
|
82
|
-
{
|
|
78
|
+
{title && <div className={"hidden lg:block"}>
|
|
79
|
+
{title}
|
|
83
80
|
</div>}
|
|
84
81
|
|
|
85
82
|
{sizeSelect}
|
|
86
83
|
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
{clearFilterButton}
|
|
84
|
+
{actionsStart}
|
|
90
85
|
|
|
91
86
|
</div>
|
|
92
87
|
|
|
93
88
|
<div className="flex items-center gap-2">
|
|
94
89
|
|
|
95
90
|
{largeLayout && <div className="w-[22px]">
|
|
96
|
-
{
|
|
91
|
+
{loading &&
|
|
97
92
|
<CircularProgress size={"small"}/>}
|
|
98
93
|
</div>}
|
|
99
94
|
|
|
100
|
-
{(
|
|
95
|
+
{(onTextSearch || onTextSearchClick) &&
|
|
101
96
|
<SearchBar
|
|
102
97
|
key={"search-bar"}
|
|
103
98
|
inputRef={searchInputRef}
|
|
104
|
-
loading={
|
|
105
|
-
disabled={Boolean(
|
|
106
|
-
onClick={
|
|
107
|
-
onTextSearch={
|
|
99
|
+
loading={textSearchLoading}
|
|
100
|
+
disabled={Boolean(onTextSearchClick)}
|
|
101
|
+
onClick={onTextSearchClick}
|
|
102
|
+
onTextSearch={onTextSearchClick ? undefined : onTextSearch}
|
|
108
103
|
expandable={true}/>}
|
|
109
104
|
|
|
110
|
-
{
|
|
105
|
+
{actions}
|
|
111
106
|
|
|
112
107
|
</div>
|
|
113
108
|
|
|
@@ -2,10 +2,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
|
2
2
|
|
|
3
3
|
import useMeasure from "react-use-measure";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { getRowHeight } from "../../VirtualTable/common";
|
|
7
|
-
import { cn, RemoveCircleIcon, Tooltip } from "@firecms/ui";
|
|
5
|
+
import { cls, RemoveCircleIcon, Tooltip } from "@firecms/ui";
|
|
8
6
|
import { ErrorBoundary } from "../../../components";
|
|
7
|
+
import { getRowHeight, TableSize } from "../../common/table_height";
|
|
9
8
|
|
|
10
9
|
interface EntityTableCellProps {
|
|
11
10
|
children: React.ReactNode;
|
|
@@ -19,7 +18,7 @@ interface EntityTableCellProps {
|
|
|
19
18
|
error?: Error;
|
|
20
19
|
allowScroll?: boolean;
|
|
21
20
|
align: "right" | "left" | "center";
|
|
22
|
-
size:
|
|
21
|
+
size: TableSize;
|
|
23
22
|
disabledTooltip?: string;
|
|
24
23
|
width: number;
|
|
25
24
|
showExpandIcon?: boolean;
|
|
@@ -47,7 +46,7 @@ const TableCellInner = ({
|
|
|
47
46
|
}: TableCellInnerProps) => {
|
|
48
47
|
return (
|
|
49
48
|
<div
|
|
50
|
-
className={
|
|
49
|
+
className={cls("flex flex-col max-h-full w-full",
|
|
51
50
|
{
|
|
52
51
|
"items-start": faded || scrollable
|
|
53
52
|
})}
|
|
@@ -96,7 +95,7 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
96
95
|
const [onHover, setOnHover] = useState(false);
|
|
97
96
|
const [internalSaved, setInternalSaved] = useState(saved);
|
|
98
97
|
|
|
99
|
-
const showError = !disabled && error;
|
|
98
|
+
const showError = !disabled && Boolean(error);
|
|
100
99
|
|
|
101
100
|
useEffect(() => {
|
|
102
101
|
if (saved) {
|
|
@@ -176,21 +175,26 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
176
175
|
const setOnHoverTrue = useCallback(() => setOnHover(true), []);
|
|
177
176
|
const setOnHoverFalse = useCallback(() => setOnHover(false), []);
|
|
178
177
|
|
|
178
|
+
const borderClass = showError
|
|
179
|
+
? "border-red-500"
|
|
180
|
+
: internalSaved
|
|
181
|
+
? "border-green-500"
|
|
182
|
+
: isSelected
|
|
183
|
+
? "border-primary"
|
|
184
|
+
: "border-transparent";
|
|
185
|
+
|
|
179
186
|
return (
|
|
180
187
|
<div
|
|
181
|
-
|
|
182
|
-
className={cn(
|
|
188
|
+
className={cls(
|
|
183
189
|
"transition-colors duration-100 ease-in-out",
|
|
184
190
|
`flex relative h-full rounded-md p-${p} border border-4 border-opacity-75`,
|
|
185
191
|
onHover && !disabled ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
186
192
|
saved ? "bg-gray-100 bg-opacity-75 dark:bg-gray-800 dark:bg-opacity-75" : "",
|
|
187
|
-
!isSelected && !internalSaved && !showError ? "border-transparent" : "",
|
|
188
193
|
hideOverflow ? "overflow-hidden" : "",
|
|
189
194
|
isSelected ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
190
|
-
|
|
191
|
-
internalSaved ? "border-green-500 " : "",
|
|
192
|
-
showError ? "border-red-500" : ""
|
|
195
|
+
borderClass
|
|
193
196
|
)}
|
|
197
|
+
ref={ref}
|
|
194
198
|
style={{
|
|
195
199
|
justifyContent,
|
|
196
200
|
alignItems: disabled || !isOverflowing ? "center" : undefined,
|