@firecms/core 3.3.0-canary.d3242eb → 3.4.0-canary.00f9be5
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 +4 -0
- package/dist/app/useApp.d.ts +1 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +4 -3
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +6 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/FiltersDialog.d.ts +2 -1
- package/dist/components/EntityCollectionView/useBoardDataController.d.ts +3 -1
- package/dist/components/EntityPreview.d.ts +3 -1
- package/dist/components/ErrorBoundary.d.ts +1 -3
- package/dist/components/LicenseBanner.d.ts +23 -0
- package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +10 -1
- package/dist/components/SelectableTable/filters/filter_text_input.d.ts +30 -0
- package/dist/components/SelectableTable/filters/filter_text_input.test.d.ts +1 -0
- package/dist/components/common/table_url_params.d.ts +24 -0
- package/dist/components/common/useDataSourceTableController.d.ts +9 -1
- package/dist/components/common/useTableSearchHelper.d.ts +9 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/contexts/LicenseStatusContext.d.ts +16 -0
- package/dist/core/DefaultDrawer.d.ts +10 -3
- package/dist/core/EntityEditView.d.ts +9 -1
- package/dist/core/EntityEditViewFormActions.d.ts +1 -1
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/plugin_translations.d.ts +38 -0
- package/dist/core/pro_plugins.d.ts +40 -0
- package/dist/de-BF5vcQPY.js +703 -0
- package/dist/de-BF5vcQPY.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +11 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/lazy_editor.d.ts +6 -0
- package/dist/editor-BSo_aS1I.js +4563 -0
- package/dist/editor-BSo_aS1I.js.map +1 -0
- package/dist/form/EntityForm.d.ts +8 -1
- package/dist/form/EntityFormActions.d.ts +2 -0
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +5 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/fr-DH9_wyFI.js +703 -0
- package/dist/fr-DH9_wyFI.js.map +1 -0
- package/dist/hi-BM8dm1Lu.js +703 -0
- package/dist/hi-BM8dm1Lu.js.map +1 -0
- package/dist/hooks/data/delete.d.ts +1 -1
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/hooks/data/useCollectionFetch.d.ts +7 -1
- package/dist/hooks/data/useEntityFetch.d.ts +9 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useLicenseStatus.d.ts +16 -0
- package/dist/hooks/useProjectLog.d.ts +11 -6
- package/dist/hooks/useTranslation.d.ts +1 -1
- package/dist/i18n/__tests__/FireCMSi18nProvider.test.d.ts +1 -0
- package/dist/i18n/__tests__/nested_provider_lifecycle.test.d.ts +1 -0
- package/dist/index.es.js +4429 -10479
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9313 -6582
- package/dist/index.umd.js.map +1 -1
- package/dist/it-D3K1gfe4.js +703 -0
- package/dist/it-D3K1gfe4.js.map +1 -0
- package/dist/locales/pl.d.ts +2 -0
- package/dist/pl-CP1zeLzn.js +705 -0
- package/dist/pl-CP1zeLzn.js.map +1 -0
- package/dist/preview/index.d.ts +1 -0
- package/dist/preview/property_previews/GeopointPropertyPreview.d.ts +4 -0
- package/dist/pt-Cus7eKQR.js +705 -0
- package/dist/pt-Cus7eKQR.js.map +1 -0
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +31 -0
- package/dist/types/datasource.d.ts +67 -4
- package/dist/types/entities.d.ts +21 -1
- package/dist/types/entity_actions.d.ts +6 -0
- package/dist/types/entity_callbacks.d.ts +21 -0
- package/dist/types/firecms.d.ts +18 -1
- package/dist/types/firecms_context.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/license.d.ts +55 -0
- package/dist/types/navigation.d.ts +34 -5
- package/dist/types/plugins.d.ts +22 -1
- package/dist/types/properties.d.ts +17 -1
- package/dist/types/side_entity_controller.d.ts +7 -0
- package/dist/types/translations.d.ts +54 -5
- package/dist/util/__tests__/collections.test.d.ts +1 -0
- package/dist/util/__tests__/urls.test.d.ts +1 -0
- package/dist/util/collections.d.ts +1 -1
- package/dist/util/date_fns_locales.d.ts +18 -0
- package/dist/util/entities.d.ts +1 -0
- package/dist/util/entity_cache.d.ts +11 -0
- package/dist/util/geopoint.d.ts +22 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/lazy_eager.d.ts +3 -3
- package/dist/util/navigation_blocking.d.ts +22 -0
- package/dist/util/navigation_from_path.d.ts +17 -0
- package/dist/util/navigation_utils.d.ts +107 -3
- package/dist/util/parent_references_from_path.d.ts +16 -0
- package/dist/util/paths.d.ts +28 -0
- package/dist/util/permissions.d.ts +10 -4
- package/dist/util/urls.d.ts +22 -0
- package/package.json +17 -11
- package/src/app/Scaffold.tsx +54 -45
- package/src/app/useApp.tsx +1 -0
- package/src/components/DeleteEntityDialog.tsx +2 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +3 -1
- package/src/components/EntityCollectionTable/column_utils.tsx +11 -19
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +7 -0
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -1
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +71 -17
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +6 -2
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +8 -1
- package/src/components/EntityCollectionView/FiltersDialog.tsx +39 -28
- package/src/components/EntityCollectionView/useBoardDataController.tsx +17 -1
- package/src/components/EntityPreview.tsx +45 -41
- package/src/components/ErrorBoundary.tsx +12 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +6 -3
- package/src/components/LicenseBanner.tsx +207 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +19 -2
- package/src/components/ReferenceWidget.tsx +1 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +33 -7
- package/src/components/SelectableTable/filters/filter_text_input.test.ts +184 -0
- package/src/components/SelectableTable/filters/filter_text_input.ts +71 -0
- package/src/components/VirtualTable/VirtualTable.tsx +19 -8
- package/src/components/common/default_entity_actions.tsx +22 -2
- package/src/components/common/table_url_params.ts +172 -0
- package/src/components/common/useDataSourceTableController.tsx +126 -163
- package/src/components/common/useTableSearchHelper.ts +26 -2
- package/src/components/index.tsx +1 -0
- package/src/contexts/LicenseStatusContext.tsx +50 -0
- package/src/contexts/SnackbarProvider.tsx +14 -1
- package/src/core/DefaultAppBar.tsx +28 -16
- package/src/core/DefaultDrawer.tsx +151 -65
- package/src/core/DrawerNavigationGroup.tsx +27 -29
- package/src/core/DrawerNavigationItem.tsx +10 -12
- package/src/core/EntityEditView.tsx +77 -35
- package/src/core/EntityEditViewFormActions.tsx +3 -2
- package/src/core/EntitySidePanel.tsx +8 -4
- package/src/core/FireCMS.tsx +73 -47
- package/src/core/SideDialogs.tsx +44 -1
- package/src/core/field_configs.tsx +15 -0
- package/src/core/index.tsx +1 -0
- package/src/core/plugin_translations.ts +87 -0
- package/src/core/pro_plugins.ts +79 -0
- package/src/editor/components/SlashCommandMenu.tsx +4 -1
- package/src/editor/extensions/Image.ts +17 -1
- package/src/editor/hooks/useProseMirror.ts +5 -0
- package/src/editor/index.ts +11 -1
- package/src/editor/lazy_editor.tsx +33 -0
- package/src/form/EntityForm.tsx +31 -10
- package/src/form/EntityFormActions.tsx +2 -0
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -1
- package/src/form/field_bindings/GeopointFieldBinding.tsx +139 -0
- package/src/form/index.tsx +1 -0
- package/src/hooks/data/delete.ts +8 -0
- package/src/hooks/data/save.ts +6 -1
- package/src/hooks/data/useCollectionFetch.tsx +21 -1
- package/src/hooks/data/useEntityFetch.tsx +35 -4
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildNavigationController.tsx +75 -16
- package/src/hooks/useFireCMSContext.tsx +7 -3
- package/src/hooks/useLicenseStatus.tsx +32 -0
- package/src/hooks/useProjectLog.tsx +27 -9
- package/src/hooks/useResolvedNavigationFrom.tsx +3 -1
- package/src/hooks/useTranslation.ts +3 -1
- package/src/hooks/useValidateAuthenticator.tsx +4 -0
- package/src/i18n/FireCMSi18nProvider.tsx +199 -23
- package/src/i18n/__tests__/FireCMSi18nProvider.test.tsx +91 -0
- package/src/i18n/__tests__/nested_provider_lifecycle.test.tsx +67 -0
- package/src/internal/useBuildDataSource.ts +37 -15
- package/src/internal/useBuildSideEntityController.tsx +20 -5
- package/src/locales/de.ts +37 -7
- package/src/locales/en.ts +41 -9
- package/src/locales/es.ts +37 -7
- package/src/locales/fr.ts +37 -7
- package/src/locales/hi.ts +37 -7
- package/src/locales/it.ts +37 -7
- package/src/locales/pl.ts +752 -0
- package/src/locales/pt.ts +37 -7
- package/src/preview/PropertyPreview.tsx +12 -0
- package/src/preview/components/DatePreview.tsx +2 -4
- package/src/preview/components/ReferencePreview.tsx +7 -3
- package/src/preview/components/StorageThumbnail.tsx +24 -2
- package/src/preview/index.ts +1 -0
- package/src/preview/property_previews/GeopointPropertyPreview.tsx +23 -0
- package/src/routes/FireCMSRoute.tsx +54 -27
- package/src/types/analytics.ts +3 -0
- package/src/types/collections.ts +34 -0
- package/src/types/datasource.ts +67 -4
- package/src/types/entities.ts +24 -1
- package/src/types/entity_actions.tsx +6 -0
- package/src/types/entity_callbacks.ts +24 -0
- package/src/types/firecms.tsx +19 -1
- package/src/types/firecms_context.tsx +9 -0
- package/src/types/index.ts +1 -0
- package/src/types/license.ts +63 -0
- package/src/types/navigation.ts +35 -5
- package/src/types/plugins.tsx +23 -1
- package/src/types/properties.ts +17 -0
- package/src/types/side_entity_controller.tsx +7 -0
- package/src/types/translations.ts +54 -5
- package/src/util/__tests__/collections.test.ts +32 -0
- package/src/util/__tests__/urls.test.ts +131 -0
- package/src/util/collections.ts +1 -1
- package/src/util/date_fns_locales.ts +168 -0
- package/src/util/entities.ts +16 -1
- package/src/util/entity_cache.ts +18 -0
- package/src/util/geopoint.ts +81 -0
- package/src/util/index.ts +3 -0
- package/src/util/lazy_eager.tsx +30 -8
- package/src/util/navigation_blocking.ts +45 -0
- package/src/util/navigation_from_path.ts +47 -7
- package/src/util/navigation_utils.ts +250 -5
- package/src/util/parent_references_from_path.ts +45 -4
- package/src/util/paths.ts +40 -3
- package/src/util/permissions.ts +22 -10
- package/src/util/previews.ts +8 -1
- package/src/util/resolutions.ts +11 -0
- package/src/util/urls.ts +52 -0
- package/src/util/useStorageUploadController.tsx +6 -1
package/src/util/previews.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthController, EntityCollection, Property, PropertyConfig, ResolvedEntityCollection } from "../types";
|
|
1
|
+
import { AuthController, EntityCollection, Property, PropertyConfig, ResolvedEntityCollection, ResolvedProperties } from "../types";
|
|
2
2
|
import { isReferenceProperty } from "./property_utils";
|
|
3
3
|
import { isPropertyBuilder } from "./entities";
|
|
4
4
|
import { getFieldConfig } from "../core";
|
|
@@ -44,6 +44,13 @@ export function getEntityTitlePropertyKey<M extends Record<string, any>>(collect
|
|
|
44
44
|
|
|
45
45
|
export function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined {
|
|
46
46
|
|
|
47
|
+
if (collection.imageProperty) {
|
|
48
|
+
const imagePropertyKey = collection.imageProperty as keyof ResolvedProperties<M>;
|
|
49
|
+
if (collection.properties[imagePropertyKey]) {
|
|
50
|
+
return collection.imageProperty as string;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
// find first storage property of type image
|
|
48
55
|
for (const key in collection.properties) {
|
|
49
56
|
const property = collection.properties[key];
|
package/src/util/resolutions.ts
CHANGED
|
@@ -90,8 +90,11 @@ export const resolveCollection = <M extends Record<string, any>,>
|
|
|
90
90
|
.map(([id, property]) => ({ [id]: property }))
|
|
91
91
|
.reduce((a, b) => ({ ...a, ...b }), {});
|
|
92
92
|
|
|
93
|
+
const { properties: overrideProps, ...restOverrides } = collectionOverride ?? {};
|
|
94
|
+
|
|
93
95
|
return {
|
|
94
96
|
...collection,
|
|
97
|
+
...restOverrides,
|
|
95
98
|
properties: cleanedProperties,
|
|
96
99
|
originalCollection: collection
|
|
97
100
|
} as ResolvedEntityCollection<M>;
|
|
@@ -302,7 +305,15 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
302
305
|
ignoreMissingFields,
|
|
303
306
|
...props
|
|
304
307
|
});
|
|
308
|
+
// `of` describes the shape of any element of the array, not one
|
|
309
|
+
// specific element, so there is no index to qualify the key with.
|
|
310
|
+
// We pass the array's own key, mirroring what the `oneOf` branch
|
|
311
|
+
// below does for `oneOf.properties`. Without this, a property
|
|
312
|
+
// builder used as `of` (or nested inside it) would be invoked with
|
|
313
|
+
// `propertyKey: undefined`, while the per-index resolutions above
|
|
314
|
+
// receive `${propertyKey}.${index}`.
|
|
305
315
|
const ofProperty = resolveProperty({
|
|
316
|
+
propertyKey,
|
|
306
317
|
propertyOrBuilder: of,
|
|
307
318
|
ignoreMissingFields,
|
|
308
319
|
...props
|
package/src/util/urls.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { PreviewType } from "../types";
|
|
2
|
+
|
|
3
|
+
const ABSOLUTE_HTTP_URL_REGEX = /^https?:\/\//i;
|
|
4
|
+
|
|
5
|
+
const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "webp", "avif", "bmp", "svg", "ico", "tif", "tiff", "heic", "heif"];
|
|
6
|
+
const VIDEO_EXTENSIONS = ["mp4", "webm", "ogv", "mov", "m4v", "avi", "mkv", "mpeg", "mpg", "3gp"];
|
|
7
|
+
const AUDIO_EXTENSIONS = ["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac", "weba", "opus", "mid", "midi"];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Is the given value an absolute `http(s)` URL, as opposed to a relative
|
|
11
|
+
* storage path such as `images/my_image.png`?
|
|
12
|
+
*
|
|
13
|
+
* Values saved in the datasource for storage properties can be either, e.g.
|
|
14
|
+
* when the property is configured with `storeUrl: true`, or when the value was
|
|
15
|
+
* written directly pointing to an externally hosted file.
|
|
16
|
+
*/
|
|
17
|
+
export function isAbsoluteHttpUrl(value?: string | null): boolean {
|
|
18
|
+
if (!value) return false;
|
|
19
|
+
return ABSOLUTE_HTTP_URL_REGEX.test(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extract the lowercase file extension of a URL or path, ignoring any query
|
|
24
|
+
* string or hash fragment. Returns `undefined` when there is no extension.
|
|
25
|
+
*/
|
|
26
|
+
export function getFileExtensionFromUrl(urlOrPath?: string | null): string | undefined {
|
|
27
|
+
if (!urlOrPath) return undefined;
|
|
28
|
+
// Query strings and hash fragments are not part of the file name, and they
|
|
29
|
+
// are common in download URLs, e.g. `?alt=media&token=...`
|
|
30
|
+
const withoutQuery = urlOrPath.split(/[?#]/)[0];
|
|
31
|
+
const lastSegment = withoutQuery.split("/").pop();
|
|
32
|
+
if (!lastSegment) return undefined;
|
|
33
|
+
const lastDot = lastSegment.lastIndexOf(".");
|
|
34
|
+
// No dot, a leading dot (a dotfile), or a trailing dot means no extension
|
|
35
|
+
if (lastDot <= 0 || lastDot === lastSegment.length - 1) return undefined;
|
|
36
|
+
return lastSegment.substring(lastDot + 1).toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Best effort guess of the preview type of a URL or path, based on its file
|
|
41
|
+
* extension. Used when no storage metadata (and therefore no content type) is
|
|
42
|
+
* available, e.g. for externally hosted files.
|
|
43
|
+
* Returns `undefined` when the extension is missing or not recognised.
|
|
44
|
+
*/
|
|
45
|
+
export function getPreviewTypeFromUrl(urlOrPath?: string | null): PreviewType | undefined {
|
|
46
|
+
const extension = getFileExtensionFromUrl(urlOrPath);
|
|
47
|
+
if (!extension) return undefined;
|
|
48
|
+
if (IMAGE_EXTENSIONS.includes(extension)) return "image";
|
|
49
|
+
if (VIDEO_EXTENSIONS.includes(extension)) return "video";
|
|
50
|
+
if (AUDIO_EXTENSIONS.includes(extension)) return "audio";
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type CompressorType from "compressorjs";
|
|
2
2
|
import equal from "react-fast-compare";
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -321,6 +321,11 @@ export async function resizeImage(
|
|
|
321
321
|
mimeType = `image/${imageResize.format}`;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
// Loaded here rather than imported: compressing an image is something a
|
|
325
|
+
// small fraction of sessions ever does, and a static import put the library
|
|
326
|
+
// in `@firecms/core` for everyone.
|
|
327
|
+
const Compressor: typeof CompressorType = (await import("compressorjs")).default;
|
|
328
|
+
|
|
324
329
|
return new Promise<File>((resolve, reject) => {
|
|
325
330
|
new Compressor(file, {
|
|
326
331
|
quality,
|