@firecms/core 3.0.0-canary.105 → 3.0.0-canary.107

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.
Files changed (35) hide show
  1. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  2. package/dist/form/field_bindings/MultiSelectBinding.d.ts +1 -1
  3. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  4. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  5. package/dist/index.es.js +50 -38
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.umd.js +50 -38
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/preview/PropertyPreviewProps.d.ts +1 -1
  10. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  11. package/dist/types/fields.d.ts +8 -0
  12. package/package.json +5 -5
  13. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
  14. package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
  15. package/src/components/EntityPreview.tsx +7 -7
  16. package/src/form/PropertyFieldBinding.tsx +11 -4
  17. package/src/form/field_bindings/MultiSelectBinding.tsx +2 -0
  18. package/src/form/field_bindings/ReferenceFieldBinding.tsx +3 -3
  19. package/src/form/field_bindings/SelectFieldBinding.tsx +5 -3
  20. package/src/form/field_bindings/SwitchFieldBinding.tsx +2 -2
  21. package/src/form/field_bindings/TextFieldBinding.tsx +3 -1
  22. package/src/preview/PropertyPreviewProps.tsx +1 -1
  23. package/src/preview/components/BooleanPreview.tsx +1 -1
  24. package/src/preview/components/EnumValuesChip.tsx +1 -1
  25. package/src/preview/components/ImagePreview.tsx +1 -1
  26. package/src/preview/components/UrlComponentPreview.tsx +1 -1
  27. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
  28. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
  29. package/src/preview/property_previews/ArrayOneOfPreview.tsx +1 -1
  30. package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
  31. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  32. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  33. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  34. package/src/preview/util.ts +2 -2
  35. package/src/types/fields.tsx +10 -0
@@ -2,7 +2,7 @@ import { CMSType, Property, ResolvedProperty } from "../types";
2
2
  /**
3
3
  * @group Preview components
4
4
  */
5
- export type PreviewSize = "medium" | "small" | "tiny";
5
+ export type PreviewSize = "medium" | "small" | "smallest";
6
6
  /**
7
7
  * @group Preview components
8
8
  */
@@ -3,7 +3,7 @@ import { EnumValues } from "../../types";
3
3
  export interface EnumValuesChipProps {
4
4
  enumValues?: EnumValues;
5
5
  enumKey: string | number;
6
- size: "tiny" | "small" | "medium";
6
+ size: "smallest" | "small" | "medium";
7
7
  className?: string;
8
8
  children?: React.ReactNode;
9
9
  }
@@ -86,6 +86,10 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
86
86
  * Flag to indicate if this field should be disabled
87
87
  */
88
88
  disabled?: boolean;
89
+ /**
90
+ * Size of the field
91
+ */
92
+ size?: "smallest" | "small" | "medium";
89
93
  }
90
94
  /**
91
95
  * Context passed to custom fields
@@ -175,4 +179,8 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
175
179
  * Only used when the field is part of an array.
176
180
  */
177
181
  index?: number;
182
+ /**
183
+ * The size of the field
184
+ */
185
+ size?: "smallest" | "small" | "medium";
178
186
  }
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.105",
4
+ "version": "3.0.0-canary.107",
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.105",
50
- "@firecms/formex": "^3.0.0-canary.105",
51
- "@firecms/ui": "^3.0.0-canary.105",
49
+ "@firecms/editor": "^3.0.0-canary.107",
50
+ "@firecms/formex": "^3.0.0-canary.107",
51
+ "@firecms/ui": "^3.0.0-canary.107",
52
52
  "@hello-pangea/dnd": "^16.6.0",
53
53
  "@radix-ui/react-portal": "^1.1.1",
54
54
  "clsx": "^2.1.1",
@@ -100,7 +100,7 @@
100
100
  "dist",
101
101
  "src"
102
102
  ],
103
- "gitHead": "e5b79b1a4af2fd750b9e8c8f73052322aa3e86ab",
103
+ "gitHead": "07f66833d1cc898c000b92029a8c33992a1dea55",
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
@@ -124,7 +124,7 @@ export const TableReferenceFieldSuccess = React.memo(
124
124
  key={`preview_array_ref_${name}_${index}`}>
125
125
  <ReferencePreview
126
126
  onClick={disabled ? undefined : handleOpen}
127
- size={"tiny"}
127
+ size={"smallest"}
128
128
  reference={reference}
129
129
  hover={!disabled}
130
130
  disabled={!path}
@@ -419,7 +419,7 @@ export const EntityCollectionView = React.memo(
419
419
  <ReferencePreview
420
420
  key={reference.path + "/" + reference.id}
421
421
  reference={reference}
422
- size={"tiny"}/>
422
+ size={"smallest"}/>
423
423
  );
424
424
  })}
425
425
  </div>
@@ -77,17 +77,17 @@ export function EntityPreview({
77
77
  hover={disabled ? undefined : hover}
78
78
  size={size}>
79
79
  {imageProperty && (
80
- <div className={cls("w-10 h-10 mr-2 shrink-0 grow-0", size === "tiny" ? "my-0.5" : "m-2 self-start")}>
80
+ <div className={cls("w-10 h-10 mr-2 shrink-0 grow-0", size === "smallest" ? "my-0.5" : "m-2 self-start")}>
81
81
  <PropertyPreview property={imageProperty}
82
82
  propertyKey={imagePropertyKey as string}
83
- size={"tiny"}
83
+ size={"smallest"}
84
84
  value={getValueInPath(entity.values, imagePropertyKey as string)}/>
85
85
  </div>
86
86
  )}
87
87
 
88
88
  <div className={"flex flex-col flex-grow w-full m-1"}>
89
89
 
90
- {size !== "tiny" && includeId && (
90
+ {size !== "smallest" && includeId && (
91
91
  entity
92
92
  ? <div className={`${
93
93
  size !== "medium"
@@ -131,10 +131,10 @@ export function EntityPreview({
131
131
  propertyKey={key as string}
132
132
  value={getValueInPath(entity.values, key)}
133
133
  property={childProperty as ResolvedProperty}
134
- size={"tiny"}/>
134
+ size={"smallest"}/>
135
135
  : <SkeletonPropertyComponent
136
136
  property={childProperty as ResolvedProperty}
137
- size={"tiny"}/>
137
+ size={"smallest"}/>
138
138
  }
139
139
  </div>
140
140
  );
@@ -144,7 +144,7 @@ export function EntityPreview({
144
144
 
145
145
  {entity && includeEntityLink &&
146
146
  <Tooltip title={`See details for ${entity.id}`}
147
- className={size !== "tiny" ? "self-start" : ""}>
147
+ className={size !== "smallest" ? "self-start" : ""}>
148
148
  <IconButton
149
149
  color={"inherit"}
150
150
  size={"small"}
@@ -203,7 +203,7 @@ const EntityPreviewContainerInner = React.forwardRef<HTMLDivElement, EntityPrevi
203
203
  fullwidth ? "w-full" : "",
204
204
  "items-center",
205
205
  hover ? "hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800" : "",
206
- size === "tiny" ? "p-1" : "p-2",
206
+ size === "smallest" ? "p-1" : "p-2",
207
207
  "flex border rounded-lg",
208
208
  onClick ? "cursor-pointer" : "",
209
209
  defaultBorderMixin,
@@ -54,6 +54,10 @@ export const PropertyFieldBinding = React.memo(PropertyFieldBindingInternal, (a:
54
54
  if (a.index !== b.index) {
55
55
  return false;
56
56
  }
57
+
58
+ if (a.size !== b.size) {
59
+ return false;
60
+ }
57
61
  const aIsBuilder = isPropertyBuilder(a.property) || a.property.fromBuilder;
58
62
  const bIsBuilder = isPropertyBuilder(b.property) || b.property.fromBuilder;
59
63
 
@@ -82,6 +86,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
82
86
  minimalistView,
83
87
  autoFocus,
84
88
  index,
89
+ size
85
90
  }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
86
91
 
87
92
  const customizationController = useCustomizationController();
@@ -151,7 +156,8 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
151
156
  disabled,
152
157
  partOfArray,
153
158
  minimalistView,
154
- autoFocus
159
+ autoFocus,
160
+ size
155
161
  };
156
162
 
157
163
  return <FieldInternal
@@ -182,7 +188,8 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
182
188
  minimalistView,
183
189
  autoFocus,
184
190
  context,
185
- disabled
191
+ disabled,
192
+ size
186
193
  },
187
194
  fieldProps
188
195
  }:
@@ -229,7 +236,6 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
229
236
  const cmsFieldProps: FieldProps<T, CustomProps, M> = {
230
237
  propertyKey,
231
238
  value: value as T,
232
- // initialValue,
233
239
  setValue,
234
240
  setFieldValue,
235
241
  error,
@@ -244,7 +250,8 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
244
250
  minimalistView: minimalistView ?? false,
245
251
  autoFocus: autoFocus ?? false,
246
252
  customProps: customFieldProps,
247
- context
253
+ context,
254
+ size
248
255
  };
249
256
 
250
257
  return (
@@ -23,6 +23,7 @@ export function MultiSelectBinding({
23
23
  disabled,
24
24
  property,
25
25
  includeDescription,
26
+ size = "medium",
26
27
  autoFocus
27
28
  }: FieldProps<EnumType[], any, any>) {
28
29
 
@@ -81,6 +82,7 @@ export function MultiSelectBinding({
81
82
  return (
82
83
  <div className="mt-0.5 ml-0.5 mt-2">
83
84
  <MultiSelect
85
+ size={size === "medium" ? "medium" : "small"}
84
86
  value={validValue ? value.map((v) => v.toString()) : []}
85
87
  disabled={disabled}
86
88
  label={<LabelWithIcon icon={getIconForProperty(property, "small")}
@@ -40,7 +40,7 @@ function ReferenceFieldBindingInternal({
40
40
  autoFocus,
41
41
  property,
42
42
  includeDescription,
43
- context
43
+ size = "medium"
44
44
  }: FieldProps<EntityReference>) {
45
45
  if (!property.path) {
46
46
  throw new Error("Property path is required for ReferenceFieldBinding");
@@ -98,7 +98,7 @@ function ReferenceFieldBindingInternal({
98
98
  disabled={!property.path}
99
99
  previewProperties={property.previewProperties}
100
100
  hover={!disabled}
101
- size={"medium"}
101
+ size={size}
102
102
  onClick={disabled || isSubmitting ? undefined : onEntryClick}
103
103
  reference={value}
104
104
  includeEntityLink={property.includeEntityLink}
@@ -106,7 +106,7 @@ function ReferenceFieldBindingInternal({
106
106
  />}
107
107
 
108
108
  {!value && <div className="justify-center text-left">
109
- <EntityPreviewContainer className={cls("p-6 text-sm font-medium flex items-center gap-6",
109
+ <EntityPreviewContainer className={cls("px-6 h-16 text-sm font-medium flex items-center gap-6",
110
110
  disabled || isSubmitting
111
111
  ? "text-slate-500"
112
112
  : "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
@@ -27,7 +27,8 @@ export function SelectFieldBinding<T extends EnumType>({
27
27
  autoFocus,
28
28
  touched,
29
29
  property,
30
- includeDescription
30
+ includeDescription,
31
+ size = "medium"
31
32
  }: SelectProps<T>) {
32
33
 
33
34
  const enumValues = property.enumValues;
@@ -48,6 +49,7 @@ export function SelectFieldBinding<T extends EnumType>({
48
49
  <>
49
50
 
50
51
  <Select
52
+ size={size === "medium" ? "medium" : "small"}
51
53
  value={value !== undefined && value != null ? value.toString() : ""}
52
54
  disabled={disabled}
53
55
  position="item-aligned"
@@ -73,7 +75,7 @@ export function SelectFieldBinding<T extends EnumType>({
73
75
  return <EnumValuesChip
74
76
  enumKey={enumKey}
75
77
  enumValues={enumValues}
76
- size={"medium"}/>;
78
+ size={size}/>;
77
79
  }}
78
80
  >
79
81
  {enumValues && enumValues.map((option) => {
@@ -83,7 +85,7 @@ export function SelectFieldBinding<T extends EnumType>({
83
85
  <EnumValuesChip
84
86
  enumKey={String(option.id)}
85
87
  enumValues={enumValues}
86
- size={"medium"}/>
88
+ size={size}/>
87
89
  </SelectItem>
88
90
  })}
89
91
  </Select>
@@ -23,7 +23,7 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
23
23
  showError,
24
24
  autoFocus,
25
25
  disabled,
26
- touched,
26
+ size = "medium",
27
27
  property,
28
28
  includeDescription
29
29
  }: SwitchFieldProps, ref) {
@@ -46,7 +46,7 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
46
46
  title={property.name}/>}
47
47
  disabled={disabled}
48
48
  autoFocus={autoFocus}
49
- size={"large"}
49
+ size={size}
50
50
  />
51
51
 
52
52
  <FieldHelperText includeDescription={includeDescription}
@@ -28,6 +28,7 @@ export function TextFieldBinding<T extends string | number>({
28
28
  autoFocus,
29
29
  property,
30
30
  includeDescription,
31
+ size = "medium"
31
32
  }: TextFieldBindingProps<T>) {
32
33
 
33
34
  let multiline: boolean | undefined;
@@ -70,6 +71,7 @@ export function TextFieldBinding<T extends string | number>({
70
71
  return (
71
72
  <>
72
73
  <TextField
74
+ size={size}
73
75
  value={value}
74
76
  onChange={onChange}
75
77
  autoFocus={autoFocus}
@@ -100,7 +102,7 @@ export function TextFieldBinding<T extends string | number>({
100
102
  <PropertyPreview
101
103
  value={value}
102
104
  property={property}
103
- size={"medium"}/>
105
+ size={size}/>
104
106
  </Collapse>}
105
107
 
106
108
  </>
@@ -3,7 +3,7 @@ import { CMSType, Property, ResolvedProperty } from "../types";
3
3
  /**
4
4
  * @group Preview components
5
5
  */
6
- export type PreviewSize = "medium" | "small" | "tiny";
6
+ export type PreviewSize = "medium" | "small" | "smallest";
7
7
 
8
8
  /**
9
9
  * @group Preview components
@@ -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 === "tiny" ? "text-sm" : "")}>{property.name}</span>}
24
+ className={cls("text-text-secondary dark:text-text-secondary-dark", size === "smallest" ? "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: "tiny" | "small" | "medium";
9
+ size: "smallest" | "small" | "medium";
10
10
  className?: string;
11
11
  children?: React.ReactNode;
12
12
  }
@@ -22,7 +22,7 @@ export function ImagePreview({
22
22
 
23
23
  const imageSize = useMemo(() => getThumbnailMeasure(size), [size]);
24
24
 
25
- if (size === "tiny") {
25
+ if (size === "smallest") {
26
26
  return (
27
27
  <img src={url}
28
28
  className={"rounded-md"}
@@ -84,7 +84,7 @@ function VideoPreview({
84
84
  }: { size: PreviewSize, src: string, interactive: boolean }) {
85
85
 
86
86
  const imageSize = useMemo(() => {
87
- if (size === "tiny")
87
+ if (size === "smallest")
88
88
  return "140px";
89
89
  else if (size === "small")
90
90
  return "240px";
@@ -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" ? "small" : "tiny";
31
+ const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
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" ? "small" : "tiny";
36
+ const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
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" ? "small" : "tiny";
40
+ const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
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" ? "small" : "tiny";
40
+ const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
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 === "tiny")
37
+ if (size === "smallest")
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) => (
@@ -87,7 +87,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
87
87
  mapPropertyKeys = (property.previewProperties || Object.keys(property.properties)) as string[];
88
88
  if (size === "small")
89
89
  mapPropertyKeys = mapPropertyKeys.slice(0, 3);
90
- else if (size === "tiny")
90
+ else if (size === "smallest")
91
91
  mapPropertyKeys = mapPropertyKeys.slice(0, 1);
92
92
  }
93
93
 
@@ -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 === "tiny" ? 40 : size === "small" ? 100 : 200;
229
+ const imageSize = size === "smallest" ? 40 : size === "small" ? 100 : 200;
230
230
  return (
231
231
  <Skeleton width={imageSize}
232
232
  height={imageSize}/>
@@ -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 === "tiny" ? "text-sm" : "")}>
48
+ ? <div className={cls("overflow-x-scroll", size === "smallest" ? "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 === "tiny"
55
+ : (size === "smallest"
56
56
  ? <span className={"text-sm"}>{value}</span>
57
57
  : <>{value}</>
58
58
  );
@@ -6,7 +6,7 @@ export const SMALL_THUMBNAIL = 100;
6
6
  export const REGULAR_THUMBNAIL = 200;
7
7
 
8
8
  export function getThumbnailMeasure(size: PreviewSize): number {
9
- if (size === "tiny")
9
+ if (size === "smallest")
10
10
  return TINY_THUMBNAIL;
11
11
  else if (size === "small")
12
12
  return SMALL_THUMBNAIL;
@@ -19,7 +19,7 @@ export function getPreviewSizeFrom(size: CollectionSize): PreviewSize {
19
19
  switch (size) {
20
20
  case "xs":
21
21
  case "s":
22
- return "tiny";
22
+ return "smallest";
23
23
  case "m":
24
24
  return "small";
25
25
  case "l":
@@ -105,6 +105,11 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
105
105
  */
106
106
  disabled?: boolean;
107
107
 
108
+ /**
109
+ * Size of the field
110
+ */
111
+ size?: "smallest" | "small" | "medium";
112
+
108
113
  }
109
114
 
110
115
  /**
@@ -213,4 +218,9 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
213
218
  * Only used when the field is part of an array.
214
219
  */
215
220
  index?: number;
221
+
222
+ /**
223
+ * The size of the field
224
+ */
225
+ size?: "smallest" | "small" | "medium",
216
226
  }