@firecms/core 3.0.0-canary.77 → 3.0.0-canary.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/components/StorageItemPreview.d.ts +3 -1
- package/dist/index.es.js +3235 -3186
- 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/preview/PropertyPreviewProps.d.ts +5 -0
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/plugins.d.ts +6 -0
- package/dist/types/properties.d.ts +5 -0
- package/package.json +4 -13
- package/src/components/common/useTableSearchHelper.ts +29 -19
- package/src/contexts/DialogsProvider.tsx +2 -2
- package/src/core/DefaultAppBar.tsx +8 -2
- package/src/form/components/StorageItemPreview.tsx +19 -6
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +40 -35
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +1 -0
- package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -1
- package/src/preview/PropertyPreview.tsx +5 -2
- package/src/preview/PropertyPreviewProps.tsx +6 -0
- package/src/preview/components/ImagePreview.tsx +5 -13
- package/src/preview/components/StorageThumbnail.tsx +5 -1
- package/src/preview/components/UrlComponentPreview.tsx +44 -11
- package/src/types/auth.tsx +1 -1
- package/src/types/plugins.tsx +7 -0
- package/src/types/properties.ts +5 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
|
|
3
3
|
import { ImagePreview } from "./ImagePreview";
|
|
4
4
|
import { getThumbnailMeasure } from "../util";
|
|
5
5
|
import { PreviewType } from "../../types";
|
|
6
6
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
7
|
-
import { DescriptionIcon, OpenInNewIcon, Tooltip, Typography } from "@firecms/ui";
|
|
7
|
+
import { cls, DescriptionIcon, OpenInNewIcon, Tooltip, Typography } from "@firecms/ui";
|
|
8
8
|
import { EmptyValue } from "./EmptyValue";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -14,12 +14,15 @@ export function UrlComponentPreview({
|
|
|
14
14
|
url,
|
|
15
15
|
previewType,
|
|
16
16
|
size,
|
|
17
|
-
hint
|
|
17
|
+
hint,
|
|
18
|
+
interactive = true
|
|
18
19
|
}: {
|
|
19
20
|
url: string,
|
|
20
21
|
previewType?: PreviewType,
|
|
21
22
|
size: PreviewSize,
|
|
22
|
-
hint?: string
|
|
23
|
+
hint?: string,
|
|
24
|
+
// for video controls
|
|
25
|
+
interactive?: boolean
|
|
23
26
|
}): React.ReactElement {
|
|
24
27
|
|
|
25
28
|
if (!previewType) {
|
|
@@ -43,17 +46,13 @@ export function UrlComponentPreview({
|
|
|
43
46
|
size={size}/>;
|
|
44
47
|
} else if (previewType === "audio") {
|
|
45
48
|
return <audio controls
|
|
49
|
+
className={"max-w-100%"}
|
|
46
50
|
src={url}>
|
|
47
51
|
Your browser does not support the
|
|
48
52
|
<code>audio</code> element.
|
|
49
53
|
</audio>;
|
|
50
54
|
} else if (previewType === "video") {
|
|
51
|
-
return <
|
|
52
|
-
className={`max-w-${size === "small" ? "sm" : "md"}`}
|
|
53
|
-
controls
|
|
54
|
-
>
|
|
55
|
-
<source src={url}/>
|
|
56
|
-
</video>;
|
|
55
|
+
return <VideoPreview size={size} src={url} interactive={interactive}/>;
|
|
57
56
|
} else {
|
|
58
57
|
return (
|
|
59
58
|
<a
|
|
@@ -66,7 +65,7 @@ export function UrlComponentPreview({
|
|
|
66
65
|
width: getThumbnailMeasure(size),
|
|
67
66
|
height: getThumbnailMeasure(size)
|
|
68
67
|
}}>
|
|
69
|
-
<DescriptionIcon className="
|
|
68
|
+
<DescriptionIcon className="text-gray-700 dark:text-gray-300"/>
|
|
70
69
|
{hint &&
|
|
71
70
|
<Tooltip title={hint}>
|
|
72
71
|
<Typography
|
|
@@ -77,3 +76,37 @@ export function UrlComponentPreview({
|
|
|
77
76
|
);
|
|
78
77
|
}
|
|
79
78
|
}
|
|
79
|
+
|
|
80
|
+
function VideoPreview({
|
|
81
|
+
size,
|
|
82
|
+
src,
|
|
83
|
+
interactive
|
|
84
|
+
}: { size: PreviewSize, src: string, interactive: boolean }) {
|
|
85
|
+
|
|
86
|
+
const imageSize = useMemo(() => {
|
|
87
|
+
if (size === "tiny")
|
|
88
|
+
return "140px";
|
|
89
|
+
else if (size === "small")
|
|
90
|
+
return "240px";
|
|
91
|
+
else if (size === "medium")
|
|
92
|
+
return "100%";
|
|
93
|
+
else throw new Error("Invalid size");
|
|
94
|
+
}, [size]);
|
|
95
|
+
|
|
96
|
+
const videoProps = {
|
|
97
|
+
controls: interactive
|
|
98
|
+
};
|
|
99
|
+
return <video
|
|
100
|
+
style={{
|
|
101
|
+
position: "relative",
|
|
102
|
+
objectFit: "cover",
|
|
103
|
+
width: imageSize,
|
|
104
|
+
minWidth: "140px",
|
|
105
|
+
// height: imageSize,
|
|
106
|
+
maxHeight: "100%"
|
|
107
|
+
}}
|
|
108
|
+
{...videoProps}
|
|
109
|
+
className={cls("max-w-100% rounded", { "pointer-events-none": !interactive })}>
|
|
110
|
+
<source src={src}/>
|
|
111
|
+
</video>;
|
|
112
|
+
}
|
package/src/types/auth.tsx
CHANGED
package/src/types/plugins.tsx
CHANGED
|
@@ -98,6 +98,13 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
98
98
|
CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
|
|
99
99
|
collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
|
|
100
100
|
|
|
101
|
+
blockSearch?: (props: {
|
|
102
|
+
context: FireCMSContext,
|
|
103
|
+
path: string,
|
|
104
|
+
collection: EC,
|
|
105
|
+
parentCollectionIds?: string[]
|
|
106
|
+
}) => boolean;
|
|
107
|
+
|
|
101
108
|
showTextSearchBar?: (props: {
|
|
102
109
|
context: FireCMSContext,
|
|
103
110
|
path: string,
|
package/src/types/properties.ts
CHANGED
|
@@ -783,6 +783,11 @@ export type StorageConfig = {
|
|
|
783
783
|
*/
|
|
784
784
|
postProcess?: (pathOrUrl: string) => Promise<string>;
|
|
785
785
|
|
|
786
|
+
/**
|
|
787
|
+
* You can use this prop in order to provide a custom preview URL.
|
|
788
|
+
* Useful when the file's path is different from the original field value
|
|
789
|
+
*/
|
|
790
|
+
previewUrl?: (fileName: string) => string;
|
|
786
791
|
}
|
|
787
792
|
|
|
788
793
|
/**
|