@firecms/core 3.0.0-canary.150 → 3.0.0-canary.152
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/index.es.js +65 -61
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +65 -61
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/util.d.ts +3 -3
- package/dist/types/fields.d.ts +2 -2
- package/package.json +5 -5
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +1 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
- package/src/components/EntityPreview.tsx +14 -14
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +2 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +1 -0
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +1 -0
- package/src/form/components/CustomIdField.tsx +1 -0
- package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +6 -6
- package/src/form/field_bindings/MapFieldBinding.tsx +1 -0
- package/src/form/field_bindings/SelectFieldBinding.tsx +2 -2
- package/src/form/field_bindings/TextFieldBinding.tsx +1 -1
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +1 -1
- package/src/preview/components/UrlComponentPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +12 -12
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +10 -10
- package/src/types/fields.tsx +2 -2
|
@@ -3,7 +3,7 @@ import { EnumValues } from "../../types";
|
|
|
3
3
|
export interface EnumValuesChipProps {
|
|
4
4
|
enumValues?: EnumValues;
|
|
5
5
|
enumKey: string | number;
|
|
6
|
-
size: "
|
|
6
|
+
size: "small" | "medium" | "large";
|
|
7
7
|
className?: string;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
}
|
package/dist/preview/util.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CollectionSize } from "../types";
|
|
2
2
|
import { PreviewSize } from "./PropertyPreviewProps";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
3
|
+
export declare const SMALL_THUMBNAIL = 40;
|
|
4
|
+
export declare const MEDIUM_THUMBNAIL = 100;
|
|
5
|
+
export declare const LARGE_THUMBNAIL = 200;
|
|
6
6
|
export declare function getThumbnailMeasure(size: PreviewSize): number;
|
|
7
7
|
export declare function getPreviewSizeFrom(size: CollectionSize): PreviewSize;
|
package/dist/types/fields.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
89
89
|
/**
|
|
90
90
|
* Size of the field
|
|
91
91
|
*/
|
|
92
|
-
size?: "
|
|
92
|
+
size?: "small" | "medium" | "large";
|
|
93
93
|
/**
|
|
94
94
|
* Some properties might change internal state (like expanding a panel).
|
|
95
95
|
* This function should be called when the internal state changes.
|
|
@@ -190,7 +190,7 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
190
190
|
/**
|
|
191
191
|
* The size of the field
|
|
192
192
|
*/
|
|
193
|
-
size?: "
|
|
193
|
+
size?: "small" | "medium" | "large";
|
|
194
194
|
/**
|
|
195
195
|
* Some properties might change internal state (like expanding a panel).
|
|
196
196
|
* This function should be called when the internal state changes.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.152",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
50
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
51
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/editor": "^3.0.0-canary.152",
|
|
50
|
+
"@firecms/formex": "^3.0.0-canary.152",
|
|
51
|
+
"@firecms/ui": "^3.0.0-canary.152",
|
|
52
52
|
"@hello-pangea/dnd": "^17.0.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.2",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dist",
|
|
101
101
|
"src"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "be8e639101ee20faccf85a5b0225a7ead151d2d9",
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
@@ -123,7 +123,7 @@ export const TableReferenceFieldInternal = React.memo(
|
|
|
123
123
|
key={`preview_array_ref_${name}_${index}`}>
|
|
124
124
|
<ReferencePreview
|
|
125
125
|
onClick={disabled ? undefined : handleOpen}
|
|
126
|
-
size={"
|
|
126
|
+
size={"small"}
|
|
127
127
|
reference={reference}
|
|
128
128
|
hover={!disabled}
|
|
129
129
|
disabled={!path}
|
|
@@ -56,7 +56,7 @@ export function CollectionTableToolbar({
|
|
|
56
56
|
<Select
|
|
57
57
|
value={size as string}
|
|
58
58
|
className="w-16 h-10"
|
|
59
|
-
size={"
|
|
59
|
+
size={"medium"}
|
|
60
60
|
onValueChange={(v) => onSizeChanged(v as CollectionSize)}
|
|
61
61
|
renderValue={(v) => <div className={"font-medium"}>{v.toUpperCase()}</div>}
|
|
62
62
|
>
|
|
@@ -65,7 +65,7 @@ export function EntityPreview({
|
|
|
65
65
|
propertyConfigs: customizationController.propertyConfigs
|
|
66
66
|
}), [collection]);
|
|
67
67
|
|
|
68
|
-
const listProperties = useMemo(() => getEntityPreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "
|
|
68
|
+
const listProperties = useMemo(() => getEntityPreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "medium" || size === "large" ? 3 : 1),
|
|
69
69
|
[previewProperties, resolvedCollection, size]);
|
|
70
70
|
|
|
71
71
|
const titleProperty = getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs);
|
|
@@ -77,10 +77,10 @@ export function EntityPreview({
|
|
|
77
77
|
return <EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
78
78
|
hover={disabled ? undefined : hover}
|
|
79
79
|
size={size}>
|
|
80
|
-
<div className={cls("flex w-10 h-10 ml-1 mr-2 shrink-0", size === "
|
|
80
|
+
<div className={cls("flex w-10 h-10 ml-1 mr-2 shrink-0", size === "small" ? "my-0.5" : "m-2 self-start")}>
|
|
81
81
|
{imageProperty && <PropertyPreview property={imageProperty}
|
|
82
82
|
propertyKey={imagePropertyKey as string}
|
|
83
|
-
size={"
|
|
83
|
+
size={"small"}
|
|
84
84
|
value={getValueInPath(entity.values, imagePropertyKey as string)}/>}
|
|
85
85
|
{!imageProperty && <IconForView collectionOrView={collection}
|
|
86
86
|
color={"primary"}
|
|
@@ -91,10 +91,10 @@ export function EntityPreview({
|
|
|
91
91
|
|
|
92
92
|
<div className={"flex flex-col grow-1 w-full max-w-full m-1"}>
|
|
93
93
|
|
|
94
|
-
{size !== "
|
|
94
|
+
{size !== "small" && includeId && (
|
|
95
95
|
entity
|
|
96
96
|
? <div className={`${
|
|
97
|
-
size !== "
|
|
97
|
+
size !== "large"
|
|
98
98
|
? "block whitespace-nowrap overflow-hidden truncate"
|
|
99
99
|
: ""
|
|
100
100
|
}`}>
|
|
@@ -107,17 +107,17 @@ export function EntityPreview({
|
|
|
107
107
|
: <Skeleton/>)}
|
|
108
108
|
|
|
109
109
|
{titleProperty && (
|
|
110
|
-
<div className={"my-0.5 text-sm font-
|
|
110
|
+
<div className={"my-0.5 text-sm font-large"}>
|
|
111
111
|
{
|
|
112
112
|
entity
|
|
113
113
|
? <PropertyPreview
|
|
114
114
|
propertyKey={titleProperty as string}
|
|
115
115
|
value={getValueInPath(entity.values, titleProperty)}
|
|
116
116
|
property={resolvedCollection.properties[titleProperty as string] as ResolvedProperty}
|
|
117
|
-
size={"
|
|
117
|
+
size={"large"}/>
|
|
118
118
|
: <SkeletonPropertyComponent
|
|
119
119
|
property={resolvedCollection.properties[titleProperty as string] as ResolvedProperty}
|
|
120
|
-
size={"
|
|
120
|
+
size={"large"}/>
|
|
121
121
|
}
|
|
122
122
|
</div>
|
|
123
123
|
)}
|
|
@@ -135,10 +135,10 @@ export function EntityPreview({
|
|
|
135
135
|
propertyKey={key as string}
|
|
136
136
|
value={getValueInPath(entity.values, key)}
|
|
137
137
|
property={childProperty as ResolvedProperty}
|
|
138
|
-
size={"
|
|
138
|
+
size={"small"}/>
|
|
139
139
|
: <SkeletonPropertyComponent
|
|
140
140
|
property={childProperty as ResolvedProperty}
|
|
141
|
-
size={"
|
|
141
|
+
size={"small"}/>
|
|
142
142
|
}
|
|
143
143
|
</div>
|
|
144
144
|
);
|
|
@@ -150,8 +150,8 @@ export function EntityPreview({
|
|
|
150
150
|
<Tooltip title={`See details for ${entity.id}`}>
|
|
151
151
|
<IconButton
|
|
152
152
|
color={"inherit"}
|
|
153
|
-
size={"
|
|
154
|
-
className={size !== "
|
|
153
|
+
size={"medium"}
|
|
154
|
+
className={size !== "small" ? "self-start" : ""}
|
|
155
155
|
onClick={(e) => {
|
|
156
156
|
e.stopPropagation();
|
|
157
157
|
analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
|
|
@@ -165,7 +165,7 @@ export function EntityPreview({
|
|
|
165
165
|
updateUrl: true
|
|
166
166
|
});
|
|
167
167
|
}}>
|
|
168
|
-
<KeyboardTabIcon size={"
|
|
168
|
+
<KeyboardTabIcon size={"medium"}/>
|
|
169
169
|
</IconButton>
|
|
170
170
|
</Tooltip>}
|
|
171
171
|
|
|
@@ -207,7 +207,7 @@ export const EntityPreviewContainer = React.forwardRef<HTMLDivElement, EntityPre
|
|
|
207
207
|
fullwidth ? "w-full" : "",
|
|
208
208
|
"items-center",
|
|
209
209
|
hover ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800" : "",
|
|
210
|
-
size === "
|
|
210
|
+
size === "small" ? "p-1" : "px-2 py-1",
|
|
211
211
|
"flex border rounded-lg",
|
|
212
212
|
onClick ? "cursor-pointer" : "",
|
|
213
213
|
defaultBorderMixin,
|
|
@@ -76,6 +76,7 @@ export function DateTimeFilterField({
|
|
|
76
76
|
<div className="flex w-[440px]">
|
|
77
77
|
<div className="w-[80px]">
|
|
78
78
|
<Select value={operation}
|
|
79
|
+
size={"large"}
|
|
79
80
|
onValueChange={(value) => {
|
|
80
81
|
updateFilter(value as VirtualTableWhereFilterOp, internalValue);
|
|
81
82
|
}}
|
|
@@ -92,7 +93,7 @@ export function DateTimeFilterField({
|
|
|
92
93
|
|
|
93
94
|
<DateTimeField
|
|
94
95
|
mode={mode}
|
|
95
|
-
size={"
|
|
96
|
+
size={"large"}
|
|
96
97
|
locale={locale}
|
|
97
98
|
value={internalValue ?? undefined}
|
|
98
99
|
onChange={(dateValue: Date | null) => {
|
|
@@ -147,6 +147,7 @@ export function ReferenceFilterField({
|
|
|
147
147
|
<div className="flex w-[440px] flex-row">
|
|
148
148
|
<div className="w-[140px]">
|
|
149
149
|
<Select value={operation}
|
|
150
|
+
size={"large"}
|
|
150
151
|
onValueChange={(value) => {
|
|
151
152
|
updateFilter(value as VirtualTableWhereFilterOp, internalValue);
|
|
152
153
|
}}
|
|
@@ -26,7 +26,7 @@ export function VirtualTableDateField(props: {
|
|
|
26
26
|
<DateTimeField
|
|
27
27
|
value={internalValue ?? undefined}
|
|
28
28
|
onChange={(dateValue) => updateValue(dateValue ?? null)}
|
|
29
|
-
size={"
|
|
29
|
+
size={"large"}
|
|
30
30
|
invisible={true}
|
|
31
31
|
inputClassName={cls("w-full h-full", focusedDisabled)}
|
|
32
32
|
className={cls("w-full h-full", focusedDisabled)}
|
|
@@ -225,7 +225,7 @@ function BlockEntry({
|
|
|
225
225
|
className="mb-2"
|
|
226
226
|
placeholder={<Typography variant={"caption"}
|
|
227
227
|
className={"px-4 py-2 font-medium"}>Type</Typography>}
|
|
228
|
-
size={"
|
|
228
|
+
size={"medium"}
|
|
229
229
|
position={"item-aligned"}
|
|
230
230
|
value={value1}
|
|
231
231
|
renderValue={(enumKey: any) =>
|
|
@@ -270,7 +270,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
270
270
|
placeholder={"value"}
|
|
271
271
|
value={entryValue}
|
|
272
272
|
type={dataType === "number" ? "number" : "text"}
|
|
273
|
-
size={"
|
|
273
|
+
size={"medium"}
|
|
274
274
|
disabled={disabled || !fieldKey}
|
|
275
275
|
onChange={(event) => {
|
|
276
276
|
if (dataType === "number") {
|
|
@@ -300,7 +300,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
300
300
|
}}/>;
|
|
301
301
|
} else if (dataType === "date") {
|
|
302
302
|
return <DateTimeField value={entryValue}
|
|
303
|
-
size={"
|
|
303
|
+
size={"medium"}
|
|
304
304
|
locale={locale}
|
|
305
305
|
disabled={disabled || !fieldKey}
|
|
306
306
|
onChange={(date) => {
|
|
@@ -311,7 +311,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
311
311
|
}}/>;
|
|
312
312
|
} else if (dataType === "boolean") {
|
|
313
313
|
return <BooleanSwitchWithLabel value={entryValue}
|
|
314
|
-
size={"
|
|
314
|
+
size={"medium"}
|
|
315
315
|
position={"start"}
|
|
316
316
|
disabled={disabled || !fieldKey}
|
|
317
317
|
onValueChange={(newValue) => {
|
|
@@ -389,7 +389,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
389
389
|
value={fieldKey}
|
|
390
390
|
placeholder={"key"}
|
|
391
391
|
disabled={disabled || (entryValue !== undefined && entryValue !== null && entryValue !== "")}
|
|
392
|
-
size={"
|
|
392
|
+
size={"medium"}
|
|
393
393
|
onChange={(event) => {
|
|
394
394
|
onFieldKeyChange(event.target.value);
|
|
395
395
|
}}/>
|
|
@@ -457,7 +457,7 @@ function ArrayKeyValueRow<T>({
|
|
|
457
457
|
if (dataType === "string" || dataType === "number") {
|
|
458
458
|
return <TextField value={entryValue}
|
|
459
459
|
type={dataType === "number" ? "number" : "text"}
|
|
460
|
-
size={"
|
|
460
|
+
size={"medium"}
|
|
461
461
|
onChange={(event) => {
|
|
462
462
|
if (dataType === "number") {
|
|
463
463
|
const numberValue = event.target.value ? parseFloat(event.target.value) : undefined;
|
|
@@ -474,7 +474,7 @@ function ArrayKeyValueRow<T>({
|
|
|
474
474
|
}}/>;
|
|
475
475
|
} else if (dataType === "date") {
|
|
476
476
|
return <DateTimeField value={entryValue}
|
|
477
|
-
size={"
|
|
477
|
+
size={"medium"}
|
|
478
478
|
locale={locale}
|
|
479
479
|
onChange={(date) => {
|
|
480
480
|
setValue(date as T);
|
|
@@ -145,6 +145,7 @@ const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue
|
|
|
145
145
|
<InputLabel>Add property</InputLabel>
|
|
146
146
|
<Select
|
|
147
147
|
value={""}
|
|
148
|
+
size={"large"}
|
|
148
149
|
disabled={disabled}
|
|
149
150
|
onValueChange={handleAddProperty}
|
|
150
151
|
renderValue={(key) => (properties as Properties)[key].name || key}>
|
|
@@ -29,7 +29,7 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
29
29
|
touched,
|
|
30
30
|
property,
|
|
31
31
|
includeDescription,
|
|
32
|
-
size = "
|
|
32
|
+
size = "large"
|
|
33
33
|
}: SelectProps<T>) {
|
|
34
34
|
|
|
35
35
|
const enumValues = resolveEnumValues(property.enumValues ?? []);
|
|
@@ -50,9 +50,9 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
50
50
|
<>
|
|
51
51
|
|
|
52
52
|
<Select
|
|
53
|
-
size={size === "medium" ? "medium" : "small"}
|
|
54
53
|
value={value !== undefined && value != null ? value.toString() : ""}
|
|
55
54
|
disabled={disabled}
|
|
55
|
+
size={size}
|
|
56
56
|
position="item-aligned"
|
|
57
57
|
inputClassName={cls("w-full")}
|
|
58
58
|
label={
|
|
@@ -21,6 +21,6 @@ export function BooleanPreview({
|
|
|
21
21
|
size={size}
|
|
22
22
|
color={"secondary"}/>
|
|
23
23
|
{property.name && <span
|
|
24
|
-
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "
|
|
24
|
+
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "small" ? "text-sm" : "")}>{property.name}</span>}
|
|
25
25
|
</div>;
|
|
26
26
|
}
|
|
@@ -6,7 +6,7 @@ import { buildEnumLabel, enumToObjectEntries, getColorScheme, getLabelOrConfigFr
|
|
|
6
6
|
export interface EnumValuesChipProps {
|
|
7
7
|
enumValues?: EnumValues;
|
|
8
8
|
enumKey: string | number;
|
|
9
|
-
size: "
|
|
9
|
+
size: "small" | "medium" | "large";
|
|
10
10
|
className?: string;
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
}
|
|
@@ -84,11 +84,11 @@ function VideoPreview({
|
|
|
84
84
|
}: { size: PreviewSize, src: string, interactive: boolean }) {
|
|
85
85
|
|
|
86
86
|
const imageSize = useMemo(() => {
|
|
87
|
-
if (size === "
|
|
87
|
+
if (size === "small")
|
|
88
88
|
return "140px";
|
|
89
|
-
else if (size === "small")
|
|
90
|
-
return "240px";
|
|
91
89
|
else if (size === "medium")
|
|
90
|
+
return "240px";
|
|
91
|
+
else if (size === "large")
|
|
92
92
|
return "100%";
|
|
93
93
|
else throw new Error("Invalid size");
|
|
94
94
|
}, [size]);
|
|
@@ -28,7 +28,7 @@ export function ArrayOfReferencesPreview({
|
|
|
28
28
|
if (property?.dataType !== "array" || !property.of || property.of.dataType !== "reference")
|
|
29
29
|
throw Error("Picked wrong preview component ArrayOfReferencesPreview");
|
|
30
30
|
|
|
31
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
31
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<div className="flex flex-col w-full">
|
|
@@ -33,7 +33,7 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
33
33
|
if (property.dataType !== "array" || !property.of || property.of.dataType !== "string")
|
|
34
34
|
throw Error("Picked wrong preview component ArrayOfStorageComponentsPreview");
|
|
35
35
|
|
|
36
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
36
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div className={"flex flex-wrap gap-2"}>
|
|
@@ -37,7 +37,7 @@ export function ArrayOneOfPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
41
41
|
|
|
42
42
|
const typeField = property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE;
|
|
43
43
|
const valueField = property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE;
|
|
@@ -37,7 +37,7 @@ export function ArrayPropertyPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex flex-col gap-2">
|
|
@@ -34,7 +34,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
34
34
|
|
|
35
35
|
const mapPropertyKeys: string[] = Object.keys(mapProperty.properties)
|
|
36
36
|
|
|
37
|
-
if (size === "
|
|
37
|
+
if (size === "small")
|
|
38
38
|
return (
|
|
39
39
|
<div className="w-full flex flex-col space-y-1 md:space-y-2">
|
|
40
40
|
{mapPropertyKeys.map((key, index) => (
|
|
@@ -81,17 +81,17 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
81
81
|
return <></>;
|
|
82
82
|
|
|
83
83
|
let mapPropertyKeys: string[];
|
|
84
|
-
if (size === "
|
|
84
|
+
if (size === "large") {
|
|
85
85
|
mapPropertyKeys = Object.keys(property.properties);
|
|
86
86
|
} else {
|
|
87
87
|
mapPropertyKeys = (property.previewProperties || Object.keys(property.properties)) as string[];
|
|
88
|
-
if (size === "
|
|
88
|
+
if (size === "medium")
|
|
89
89
|
mapPropertyKeys = mapPropertyKeys.slice(0, 3);
|
|
90
|
-
else if (size === "
|
|
90
|
+
else if (size === "small")
|
|
91
91
|
mapPropertyKeys = mapPropertyKeys.slice(0, 1);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
if (size !== "
|
|
94
|
+
if (size !== "large")
|
|
95
95
|
return (
|
|
96
96
|
<div
|
|
97
97
|
className="w-full flex flex-col space-y-4"
|
|
@@ -101,7 +101,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
101
101
|
{property.properties && property.properties[key] &&
|
|
102
102
|
<SkeletonPropertyComponent
|
|
103
103
|
property={property.properties[key]}
|
|
104
|
-
size={"
|
|
104
|
+
size={"medium"}/>}
|
|
105
105
|
</div>
|
|
106
106
|
))}
|
|
107
107
|
</div>
|
|
@@ -128,7 +128,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
128
128
|
{property.properties && property.properties[key] &&
|
|
129
129
|
<SkeletonPropertyComponent
|
|
130
130
|
property={property.properties[key]}
|
|
131
|
-
size={"
|
|
131
|
+
size={"medium"}/>}
|
|
132
132
|
</th>
|
|
133
133
|
</tr>
|
|
134
134
|
);
|
|
@@ -160,7 +160,7 @@ function renderArrayOfMaps<M extends Record<string, any>>(properties: ResolvedPr
|
|
|
160
160
|
>
|
|
161
161
|
<SkeletonPropertyComponent
|
|
162
162
|
property={(properties)[key]}
|
|
163
|
-
size={"
|
|
163
|
+
size={"medium"}/>
|
|
164
164
|
</th>
|
|
165
165
|
)
|
|
166
166
|
)}
|
|
@@ -210,7 +210,7 @@ function renderGenericArrayCell(
|
|
|
210
210
|
<>
|
|
211
211
|
<SkeletonPropertyComponent key={`i_${index}`}
|
|
212
212
|
property={property}
|
|
213
|
-
size={"
|
|
213
|
+
size={"medium"}/>
|
|
214
214
|
</>
|
|
215
215
|
)}
|
|
216
216
|
</div>
|
|
@@ -226,7 +226,7 @@ function renderUrlAudioComponent() {
|
|
|
226
226
|
|
|
227
227
|
export function renderSkeletonImageThumbnail(size: PreviewSize) {
|
|
228
228
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
229
|
-
const imageSize = size === "
|
|
229
|
+
const imageSize = size === "small" ? 40 : size === "medium" ? 100 : 200;
|
|
230
230
|
return (
|
|
231
231
|
<Skeleton width={imageSize}
|
|
232
232
|
height={imageSize}/>
|
|
@@ -236,8 +236,8 @@ export function renderSkeletonImageThumbnail(size: PreviewSize) {
|
|
|
236
236
|
function renderUrlVideo(size: PreviewSize) {
|
|
237
237
|
|
|
238
238
|
return (
|
|
239
|
-
<Skeleton width={size !== "
|
|
240
|
-
height={size !== "
|
|
239
|
+
<Skeleton width={size !== "large" ? 300 : 500}
|
|
240
|
+
height={size !== "large" ? 200 : 250}/>
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -245,7 +245,7 @@ function renderReference() {
|
|
|
245
245
|
return <Skeleton width={200} height={100}/>;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
function renderUrlComponent(property: ResolvedStringProperty, size: PreviewSize = "
|
|
248
|
+
function renderUrlComponent(property: ResolvedStringProperty, size: PreviewSize = "large") {
|
|
249
249
|
|
|
250
250
|
if (typeof property.url === "boolean") {
|
|
251
251
|
return <div style={{
|
|
@@ -45,14 +45,14 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={cls("overflow-x-scroll", size === "
|
|
48
|
+
? <div className={cls("overflow-x-scroll", size === "small" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
|
52
52
|
{index !== lines.length - 1 && <br/>}
|
|
53
53
|
</React.Fragment>)}
|
|
54
54
|
</div>
|
|
55
|
-
: (size === "
|
|
55
|
+
: (size === "small"
|
|
56
56
|
? <span className={"text-sm"}>{value}</span>
|
|
57
57
|
: <>{value}</>
|
|
58
58
|
);
|
package/src/preview/util.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CollectionSize } from "../types";
|
|
2
2
|
import { PreviewSize } from "./PropertyPreviewProps";
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
4
|
+
export const SMALL_THUMBNAIL = 40;
|
|
5
|
+
export const MEDIUM_THUMBNAIL = 100;
|
|
6
|
+
export const LARGE_THUMBNAIL = 200;
|
|
7
7
|
|
|
8
8
|
export function getThumbnailMeasure(size: PreviewSize): number {
|
|
9
|
-
if (size === "
|
|
10
|
-
return TINY_THUMBNAIL;
|
|
11
|
-
else if (size === "small")
|
|
9
|
+
if (size === "small")
|
|
12
10
|
return SMALL_THUMBNAIL;
|
|
13
11
|
else if (size === "medium")
|
|
14
|
-
return
|
|
12
|
+
return MEDIUM_THUMBNAIL;
|
|
13
|
+
else if (size === "large")
|
|
14
|
+
return LARGE_THUMBNAIL;
|
|
15
15
|
else throw Error("Thumbnail size not mapped");
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,12 +19,12 @@ export function getPreviewSizeFrom(size: CollectionSize): PreviewSize {
|
|
|
19
19
|
switch (size) {
|
|
20
20
|
case "xs":
|
|
21
21
|
case "s":
|
|
22
|
-
return "smallest";
|
|
23
|
-
case "m":
|
|
24
22
|
return "small";
|
|
23
|
+
case "m":
|
|
24
|
+
return "medium";
|
|
25
25
|
case "l":
|
|
26
26
|
case "xl":
|
|
27
|
-
return "
|
|
27
|
+
return "large";
|
|
28
28
|
default:
|
|
29
29
|
throw Error("Missing mapping value in getPreviewSizeFrom: " + size);
|
|
30
30
|
}
|