@firecms/collection_editor 3.0.0-alpha.34 → 3.0.0-alpha.36

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 (46) hide show
  1. package/dist/index.es.js +1516 -1465
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +1 -1
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/types/collection_editor_controller.d.ts +3 -3
  6. package/dist/types/persisted_collection.d.ts +2 -3
  7. package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
  8. package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +2 -2
  9. package/dist/ui/collection_editor/PropertyEditView.d.ts +1 -1
  10. package/dist/ui/collection_editor/PropertyTree.d.ts +2 -2
  11. package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +2 -2
  12. package/dist/ui/collection_editor/properties/BlockPropertyField.d.ts +2 -2
  13. package/dist/ui/collection_editor/properties/MapPropertyField.d.ts +2 -2
  14. package/dist/ui/collection_editor/properties/RepeatPropertyField.d.ts +2 -2
  15. package/dist/ui/collection_editor/properties/StringPropertyField.d.ts +1 -1
  16. package/dist/ui/collection_editor/properties/UrlPropertyField.d.ts +4 -0
  17. package/dist/ui/collection_editor/templates/blog_template.d.ts +1 -1
  18. package/dist/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -1
  19. package/package.json +5 -5
  20. package/src/ConfigControllerProvider.tsx +6 -6
  21. package/src/types/collection_editor_controller.tsx +2 -2
  22. package/src/types/persisted_collection.ts +2 -2
  23. package/src/ui/EditorCollectionAction.tsx +1 -1
  24. package/src/ui/RootCollectionSuggestions.tsx +1 -1
  25. package/src/ui/collection_editor/CollectionDetailsForm.tsx +52 -1
  26. package/src/ui/collection_editor/CollectionEditorDialog.tsx +85 -33
  27. package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +15 -15
  28. package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +3 -1
  29. package/src/ui/collection_editor/PropertyEditView.tsx +18 -15
  30. package/src/ui/collection_editor/PropertyFieldPreview.tsx +4 -4
  31. package/src/ui/collection_editor/PropertyTree.tsx +3 -2
  32. package/src/ui/collection_editor/SubcollectionsEditTab.tsx +1 -1
  33. package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +9 -11
  34. package/src/ui/collection_editor/properties/BlockPropertyField.tsx +3 -3
  35. package/src/ui/collection_editor/properties/MapPropertyField.tsx +4 -4
  36. package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +1 -0
  37. package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +4 -6
  38. package/src/ui/collection_editor/properties/StringPropertyField.tsx +1 -7
  39. package/src/ui/collection_editor/properties/UrlPropertyField.tsx +89 -0
  40. package/src/ui/collection_editor/templates/blog_template.ts +3 -4
  41. package/src/ui/collection_editor/templates/products_template.ts +3 -5
  42. package/src/ui/collection_editor/templates/users_template.ts +3 -4
  43. package/src/ui/collection_editor/utils/update_property_for_widget.ts +6 -3
  44. package/src/useCollectionEditorPlugin.tsx +10 -5
  45. package/dist/utils/join_collections.d.ts +0 -13
  46. package/src/utils/join_collections.ts +0 -113
@@ -44,7 +44,7 @@ type CollectionEditorFormProps = {
44
44
  getUser: (uid: string) => User | null;
45
45
  getData?: () => Promise<object[]>;
46
46
  doCollectionInference: (collection: PersistedCollection) => Promise<EntityCollection | null> | undefined;
47
- customFields: Record<string, PropertyConfig>;
47
+ propertyConfigs: Record<string, PropertyConfig>;
48
48
  collectionEditable: boolean;
49
49
  };
50
50
 
@@ -59,7 +59,7 @@ export function CollectionPropertiesEditorForm({
59
59
  getUser,
60
60
  getData,
61
61
  doCollectionInference,
62
- customFields,
62
+ propertyConfigs,
63
63
  collectionEditable
64
64
  }: CollectionEditorFormProps) {
65
65
 
@@ -126,7 +126,7 @@ export function CollectionPropertiesEditorForm({
126
126
  if (newPropertyKeys.length === 0) {
127
127
  snackbarController.open({
128
128
  type: "info",
129
- message: "No new properties found"
129
+ message: "No new properties found in existing data"
130
130
  });
131
131
  return;
132
132
  }
@@ -312,7 +312,7 @@ export function CollectionPropertiesEditorForm({
312
312
  placeholder={"Collection name"}
313
313
  size={"small"}
314
314
  required
315
- error={Boolean(errors.name)}/>
315
+ error={Boolean(errors?.name)}/>
316
316
 
317
317
  {owner &&
318
318
  <Typography variant={"body2"}
@@ -327,14 +327,14 @@ export function CollectionPropertiesEditorForm({
327
327
  </div>}
328
328
 
329
329
  <div className="ml-1 mt-2 flex flex-row gap-2">
330
- <Tooltip title={"Get the code for this collection"}>
331
- <IconButton
332
- variant={"filled"}
333
- disabled={inferringProperties}
334
- onClick={() => setCodeDialogOpen(true)}>
335
- <CodeIcon/>
336
- </IconButton>
337
- </Tooltip>
330
+ {/*<Tooltip title={"Get the code for this collection"}>*/}
331
+ {/* <IconButton*/}
332
+ {/* variant={"filled"}*/}
333
+ {/* disabled={inferringProperties}*/}
334
+ {/* onClick={() => setCodeDialogOpen(true)}>*/}
335
+ {/* <CodeIcon/>*/}
336
+ {/* </IconButton>*/}
337
+ {/*</Tooltip>*/}
338
338
  {inferPropertiesFromData && <Tooltip title={"Add new properties based on data"}>
339
339
  <IconButton
340
340
  variant={"filled"}
@@ -406,7 +406,7 @@ export function CollectionPropertiesEditorForm({
406
406
  forceShowErrors={showErrors}
407
407
  initialErrors={initialErrors}
408
408
  getData={getData}
409
- customFields={customFields}
409
+ propertyConfigs={propertyConfigs}
410
410
  collectionEditable={collectionEditable}
411
411
  />}
412
412
 
@@ -441,7 +441,7 @@ export function CollectionPropertiesEditorForm({
441
441
  forceShowErrors={showErrors}
442
442
  initialErrors={initialErrors}
443
443
  getData={getData}
444
- customFields={customFields}
444
+ propertyConfigs={propertyConfigs}
445
445
  collectionEditable={collectionEditable}
446
446
  onOkClicked={asDialog
447
447
  ? closePropertyDialog
@@ -466,7 +466,7 @@ export function CollectionPropertiesEditorForm({
466
466
  onPropertyChanged={onPropertyCreated}
467
467
  getData={getData}
468
468
  allowDataInference={!isNewCollection}
469
- customFields={customFields}
469
+ propertyConfigs={propertyConfigs}
470
470
  collectionEditable={collectionEditable}
471
471
  existingPropertyKeys={values.propertiesOrder as string[]}/>
472
472
 
@@ -2,7 +2,9 @@ import { Button, Dialog, DialogActions, DialogContent, Typography, useFireCMSCon
2
2
  import React from "react";
3
3
 
4
4
  export function EntityCustomViewsSelectDialog({ open, onClose }: { open: boolean, onClose: (selectedViewKey?: string) => void }) {
5
- const { entityViews } = useFireCMSContext();
5
+ const {
6
+ entityViews,
7
+ } = useFireCMSContext();
6
8
 
7
9
  return <Dialog
8
10
  maxWidth={"md"}
@@ -20,7 +20,7 @@ import {
20
20
  isPropertyBuilder,
21
21
  mergeDeep,
22
22
  Property,
23
- PropertyConfig, PropertyOrBuilder,
23
+ PropertyConfig,
24
24
  Select,
25
25
  toSnakeCase,
26
26
  Typography
@@ -41,6 +41,7 @@ import { editableProperty } from "../../utils/entities";
41
41
  import { KeyValuePropertyField } from "./properties/KeyValuePropertyField";
42
42
  import { updatePropertyFromWidget } from "./utils/update_property_for_widget";
43
43
  import { PropertySelectItem } from "./PropertySelectItem";
44
+ import { UrlPropertyField } from "./properties/UrlPropertyField";
44
45
 
45
46
  export type PropertyWithId = Property & {
46
47
  id?: string
@@ -72,7 +73,7 @@ export type PropertyFormProps = {
72
73
  allowDataInference: boolean;
73
74
  getData?: () => Promise<object[]>;
74
75
  getHelpers?: (formikProps: FormikProps<PropertyWithId>) => void;
75
- customFields: Record<string, PropertyConfig>;
76
+ propertyConfigs: Record<string, PropertyConfig>;
76
77
  collectionEditable: boolean;
77
78
  };
78
79
 
@@ -96,7 +97,7 @@ export const PropertyForm = React.memo(
96
97
  allowDataInference,
97
98
  getHelpers,
98
99
  getData,
99
- customFields,
100
+ propertyConfigs,
100
101
  collectionEditable
101
102
  }: PropertyFormProps) {
102
103
 
@@ -106,7 +107,6 @@ export const PropertyForm = React.memo(
106
107
  } as PropertyWithId;
107
108
 
108
109
  const disabled = (Boolean(property && !editableProperty(property)) && !collectionEditable);
109
- console.log("PropertyForm disabled", disabled)
110
110
 
111
111
  const lastSubmittedProperty = useRef<OnPropertyChangedParams | undefined>(property ? {
112
112
  id: propertyKey,
@@ -184,7 +184,7 @@ export const PropertyForm = React.memo(
184
184
  disabled={disabled}
185
185
  getData={getData}
186
186
  allowDataInference={allowDataInference}
187
- customFields={customFields}
187
+ propertyConfigs={propertyConfigs}
188
188
  collectionEditable={collectionEditable}
189
189
  {...props}/>;
190
190
 
@@ -277,7 +277,7 @@ function PropertyEditView({
277
277
  existingPropertyKeys,
278
278
  getData,
279
279
  allowDataInference,
280
- customFields,
280
+ propertyConfigs,
281
281
  collectionEditable
282
282
  }: {
283
283
  includeIdAndTitle?: boolean;
@@ -294,7 +294,7 @@ function PropertyEditView({
294
294
  existingPropertyKeys?: string[];
295
295
  getData?: () => Promise<object[]>;
296
296
  allowDataInference: boolean;
297
- customFields: Record<string, PropertyConfig>;
297
+ propertyConfigs: Record<string, PropertyConfig>;
298
298
  collectionEditable: boolean;
299
299
  } & FormikProps<PropertyWithId>) {
300
300
 
@@ -302,7 +302,7 @@ function PropertyEditView({
302
302
  const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
303
303
  const [selectedFieldConfigId, setSelectedFieldConfigId] = useState<string | undefined>(values?.dataType ? getFieldId(values) : undefined);
304
304
 
305
- const allSupportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).concat(Object.entries(customFields));
305
+ const allSupportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).concat(Object.entries(propertyConfigs));
306
306
 
307
307
  const displayedWidgets = inArray
308
308
  ? allSupportedFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.dataType !== "array")
@@ -351,7 +351,7 @@ function PropertyEditView({
351
351
 
352
352
  const onWidgetSelectChanged = (newSelectedWidgetId: FieldConfigId) => {
353
353
  setSelectedFieldConfigId(newSelectedWidgetId);
354
- setValues(updatePropertyFromWidget(values, newSelectedWidgetId, customFields));
354
+ setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));
355
355
  // Ugly hack to autofocus the name field
356
356
  setTimeout(() => {
357
357
  nameFieldRef.current?.focus();
@@ -362,12 +362,15 @@ function PropertyEditView({
362
362
  if (selectedFieldConfigId === "text_field" ||
363
363
  selectedFieldConfigId === "multiline" ||
364
364
  selectedFieldConfigId === "markdown" ||
365
- selectedFieldConfigId === "url" ||
366
365
  selectedFieldConfigId === "email") {
367
366
  childComponent =
368
367
  <StringPropertyField widgetId={selectedFieldConfigId}
369
368
  disabled={disabled}
370
369
  showErrors={showErrors}/>;
370
+ } else if (selectedFieldConfigId === "url") {
371
+ childComponent =
372
+ <UrlPropertyField disabled={disabled}
373
+ showErrors={showErrors}/>;
371
374
  } else if (selectedFieldConfigId === "select" ||
372
375
  selectedFieldConfigId === "number_select") {
373
376
  childComponent = <EnumPropertyField
@@ -404,12 +407,12 @@ function PropertyEditView({
404
407
  childComponent =
405
408
  <MapPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}
406
409
  collectionEditable={collectionEditable}
407
- customFields={customFields}/>;
410
+ propertyConfigs={propertyConfigs}/>;
408
411
  } else if (selectedFieldConfigId === "block") {
409
412
  childComponent =
410
413
  <BlockPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}
411
414
  collectionEditable={collectionEditable}
412
- customFields={customFields}/>;
415
+ propertyConfigs={propertyConfigs}/>;
413
416
  } else if (selectedFieldConfigId === "reference") {
414
417
  childComponent =
415
418
  <ReferencePropertyField showErrors={showErrors}
@@ -432,7 +435,7 @@ function PropertyEditView({
432
435
  allowDataInference={allowDataInference}
433
436
  disabled={disabled}
434
437
  collectionEditable={collectionEditable}
435
- customFields={customFields}/>;
438
+ propertyConfigs={propertyConfigs}/>;
436
439
  } else if (selectedFieldConfigId === "key_value") {
437
440
  childComponent =
438
441
  <KeyValuePropertyField disabled={disabled}/>;
@@ -467,9 +470,9 @@ function PropertyEditView({
467
470
  widget</em>;
468
471
  }
469
472
  const key = value as FieldConfigId;
470
- const propertyConfig = DEFAULT_FIELD_CONFIGS[key] ?? customFields[key];
473
+ const propertyConfig = DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key];
471
474
  const baseProperty = propertyConfig.property;
472
- const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty) ? getFieldConfig(baseProperty, customFields) : undefined;
475
+ const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty) ? getFieldConfig(baseProperty, propertyConfigs) : undefined;
473
476
  const optionDisabled = isPropertyBuilder(baseProperty) || (existing && baseProperty.dataType !== values?.dataType);
474
477
  const computedFieldConfig = baseFieldConfig ? mergeDeep(baseFieldConfig, propertyConfig) : propertyConfig;
475
478
  return <div
@@ -34,9 +34,9 @@ export function PropertyFieldPreview({
34
34
  onClick?: () => void
35
35
  }) {
36
36
 
37
- const { fields } = useFireCMSContext();
37
+ const { propertyConfigs } = useFireCMSContext();
38
38
 
39
- const propertyConfig = getFieldConfig(property, fields);
39
+ const propertyConfig = getFieldConfig(property, propertyConfigs);
40
40
  const disabled = !editableProperty(property);
41
41
 
42
42
  const borderColorClass = hasError
@@ -116,9 +116,9 @@ export function NonEditablePropertyPreview({
116
116
  property?: PropertyOrBuilder
117
117
  }) {
118
118
 
119
- const { fields } = useFireCMSContext();
119
+ const { propertyConfigs } = useFireCMSContext();
120
120
 
121
- const propertyConfig = !isPropertyBuilder(property) && property ? getFieldConfig(property, fields) : undefined;
121
+ const propertyConfig = !isPropertyBuilder(property) && property ? getFieldConfig(property, propertyConfigs) : undefined;
122
122
 
123
123
  return (
124
124
  <div
@@ -33,7 +33,7 @@ export function PropertyTree<M extends {
33
33
  onPropertyRemove,
34
34
  className,
35
35
  inferredPropertyKeys,
36
- collectionEditable
36
+ collectionEditable,
37
37
  }: {
38
38
  namespace?: string;
39
39
  selectedPropertyKey?: string;
@@ -137,7 +137,7 @@ export function PropertyTreeEntry({
137
137
  onPropertyMove,
138
138
  onPropertyRemove,
139
139
  inferredPropertyKeys,
140
- collectionEditable
140
+ collectionEditable,
141
141
  }: {
142
142
  propertyKey: string;
143
143
  namespace?: string;
@@ -156,6 +156,7 @@ export function PropertyTreeEntry({
156
156
  const isPropertyInferred = inferredPropertyKeys?.includes(namespace ? `${namespace}.${propertyKey}` : propertyKey);
157
157
 
158
158
  const fullId = getFullId(propertyKey, namespace);
159
+
159
160
  let subtree;
160
161
  if (typeof propertyOrBuilder === "object") {
161
162
  const property = propertyOrBuilder;
@@ -179,7 +179,7 @@ export function SubcollectionsEditTab({
179
179
 
180
180
  {totalEntityViews === 0 &&
181
181
  <InfoLabel>
182
- COMING SOON: You can define your own custom views by uploading it with the CLI
182
+ <b>COMING SOON</b> Define your own custom views by uploading it with the CLI
183
183
  </InfoLabel>
184
184
  }
185
185
 
@@ -16,8 +16,7 @@ import {
16
16
  PropertyConfig,
17
17
  Select,
18
18
  Tooltip,
19
- Typography,
20
- useFireCMSContext
19
+ Typography
21
20
  } from "@firecms/core";
22
21
  import React, { useState } from "react";
23
22
  import { OnPropertyChangedParams, PropertyFormDialog, PropertyWithId } from "../PropertyEditView";
@@ -30,12 +29,12 @@ import { buildPropertyFromData } from "@firecms/schema_inference";
30
29
 
31
30
  export function CollectionEditorImportMapping({
32
31
  importConfig,
33
- customFields,
32
+ propertyConfigs,
34
33
  collectionEditable
35
34
  }:
36
35
  {
37
36
  importConfig: ImportConfig,
38
- customFields: Record<string, PropertyConfig>,
37
+ propertyConfigs: Record<string, PropertyConfig>,
39
38
  collectionEditable: boolean
40
39
  }) {
41
40
 
@@ -181,7 +180,7 @@ export function CollectionEditorImportMapping({
181
180
  importKey
182
181
  })}
183
182
  propertyKey={propertyKey}
184
- customFields={customFields}/>}
183
+ propertyConfigs={propertyConfigs}/>}
185
184
  />;
186
185
  }}/>
187
186
  </Container>
@@ -203,7 +202,7 @@ export function CollectionEditorImportMapping({
203
202
  }}
204
203
  autoOpenTypeSelect={false}
205
204
  existingProperty={false}
206
- customFields={customFields}/>
205
+ propertyConfigs={propertyConfigs}/>
207
206
 
208
207
  <div style={{ height: "52px" }}/>
209
208
  </div>
@@ -215,7 +214,7 @@ function PropertySelect({
215
214
  property,
216
215
  onPropertyChanged,
217
216
  propertyKey,
218
- customFields,
217
+ propertyConfigs,
219
218
  disabled
220
219
  }: {
221
220
  property: Property | null,
@@ -226,13 +225,12 @@ function PropertySelect({
226
225
  previousId,
227
226
  namespace
228
227
  }: OnPropertyChangedParams) => void,
229
- customFields: Record<string, PropertyConfig>,
228
+ propertyConfigs: Record<string, PropertyConfig>,
230
229
  disabled?: boolean
231
230
  }) {
232
231
 
233
- const { fields } = useFireCMSContext();
234
232
  const fieldId = property ? getFieldId(property) : null;
235
- const widget = property ? getFieldConfig(property, fields) : null;
233
+ const widget = property ? getFieldConfig(property, propertyConfigs) : null;
236
234
 
237
235
  const [selectOpen, setSelectOpen] = useState(false);
238
236
 
@@ -253,7 +251,7 @@ function PropertySelect({
253
251
  return <FieldConfigBadge propertyConfig={widget}/>
254
252
  }}
255
253
  onValueChange={(newSelectedWidgetId) => {
256
- const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, customFields)
254
+ const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, propertyConfigs)
257
255
  if (!propertyKey) return;
258
256
  onPropertyChanged({
259
257
  id: propertyKey,
@@ -5,11 +5,11 @@ import { PropertyFormDialog } from "../PropertyEditView";
5
5
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
6
6
  import { PropertyTree } from "../PropertyTree";
7
7
 
8
- export function BlockPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
8
+ export function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
9
9
  disabled: boolean;
10
10
  getData?: () => Promise<object[]>;
11
11
  allowDataInference: boolean;
12
- customFields: Record<string, PropertyConfig>,
12
+ propertyConfigs: Record<string, PropertyConfig>,
13
13
  collectionEditable: boolean;
14
14
  }) {
15
15
 
@@ -128,7 +128,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
128
128
  autoOpenTypeSelect={!selectedPropertyKey}
129
129
  onPropertyChanged={onPropertyCreated}
130
130
  existingPropertyKeys={selectedPropertyKey ? undefined : values.oneOf?.propertiesOrder}
131
- customFields={customFields}/>}
131
+ propertyConfigs={propertyConfigs}/>}
132
132
 
133
133
  </>);
134
134
  }
@@ -15,11 +15,11 @@ import { PropertyTree } from "../PropertyTree";
15
15
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
16
16
  import { FieldHelperView } from "./FieldHelperView";
17
17
 
18
- export function MapPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
18
+ export function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
19
19
  disabled: boolean;
20
20
  getData?: () => Promise<object[]>;
21
21
  allowDataInference: boolean;
22
- customFields: Record<string, PropertyConfig>,
22
+ propertyConfigs: Record<string, PropertyConfig>,
23
23
  collectionEditable: boolean;
24
24
  }) {
25
25
 
@@ -105,7 +105,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
105
105
 
106
106
  {empty &&
107
107
  <Typography variant={"label"}
108
- className="h-full flex items-center justify-center p-2">
108
+ className="h-full flex items-center justify-center p-4">
109
109
  Add the first property to this group
110
110
  </Typography>}
111
111
  </Paper>
@@ -150,7 +150,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
150
150
  autoOpenTypeSelect={!selectedPropertyKey}
151
151
  onPropertyChanged={onPropertyCreated}
152
152
  existingPropertyKeys={selectedPropertyKey ? undefined : propertiesOrder}
153
- customFields={customFields}
153
+ propertyConfigs={propertyConfigs}
154
154
  />
155
155
 
156
156
  </>);
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { Field, getIn, useFormikContext } from "formik";
3
3
  import {
4
4
  CircularProgress,
5
+ EntityCollection,
5
6
  getIconForView,
6
7
  NumberProperty,
7
8
  Select,
@@ -21,7 +21,7 @@ export function RepeatPropertyField({
21
21
  disabled,
22
22
  getData,
23
23
  allowDataInference,
24
- customFields,
24
+ propertyConfigs,
25
25
  collectionEditable
26
26
  }: {
27
27
  showErrors: boolean,
@@ -29,12 +29,10 @@ export function RepeatPropertyField({
29
29
  disabled: boolean,
30
30
  getData?: () => Promise<object[]>;
31
31
  allowDataInference: boolean;
32
- customFields: Record<string, PropertyConfig>,
32
+ propertyConfigs: Record<string, PropertyConfig>,
33
33
  collectionEditable: boolean;
34
34
  }) {
35
35
 
36
- const { fields } = useFireCMSContext();
37
-
38
36
  const {
39
37
  values,
40
38
  handleChange,
@@ -52,7 +50,7 @@ export function RepeatPropertyField({
52
50
  setFieldValue("of", property);
53
51
  }, []);
54
52
 
55
- const widget = ofProperty && getFieldConfig(ofProperty, fields);
53
+ const widget = ofProperty && getFieldConfig(ofProperty, propertyConfigs);
56
54
  return (
57
55
  <>
58
56
  <div className={"col-span-12"}>
@@ -97,7 +95,7 @@ export function RepeatPropertyField({
97
95
  includeIdAndName={false}
98
96
  onPropertyChanged={onPropertyChanged}
99
97
  forceShowErrors={showErrors}
100
- customFields={customFields}
98
+ propertyConfigs={propertyConfigs}
101
99
  collectionEditable={collectionEditable}
102
100
  />
103
101
  </Paper>
@@ -10,7 +10,7 @@ export function StringPropertyField({
10
10
  disabled,
11
11
  showErrors
12
12
  }: {
13
- widgetId: "text_field" | "multiline" | "markdown" | "url" | "email";
13
+ widgetId: "text_field" | "multiline" | "markdown" | "email";
14
14
  disabled: boolean;
15
15
  showErrors: boolean;
16
16
  }) {
@@ -51,12 +51,6 @@ export function StringPropertyField({
51
51
  trim={true}
52
52
  uppercase={true}
53
53
  showErrors={showErrors}/>}
54
- {widgetId === "url" &&
55
- <StringPropertyValidation disabled={disabled}
56
- max={true}
57
- min={true}
58
- trim={true}
59
- showErrors={showErrors}/>}
60
54
 
61
55
  {widgetId === "email" &&
62
56
  <StringPropertyValidation disabled={disabled}
@@ -0,0 +1,89 @@
1
+ import React from "react";
2
+ import { StringPropertyValidation } from "./validation/StringPropertyValidation";
3
+ import { ValidationPanel } from "./validation/ValidationPanel";
4
+ import { getIn, useFormikContext } from "formik";
5
+
6
+ import { Select, SelectItem, TextField } from "@firecms/core";
7
+
8
+ export function UrlPropertyField({
9
+ disabled,
10
+ showErrors
11
+ }: {
12
+ disabled: boolean;
13
+ showErrors: boolean;
14
+ }) {
15
+
16
+ const { values, setFieldValue } = useFormikContext();
17
+
18
+ const urlValue = getIn(values, "url");
19
+
20
+ return (
21
+ <>
22
+ <div className={"col-span-12"}>
23
+
24
+ <Select
25
+ disabled={disabled}
26
+ position={"item-aligned"}
27
+ onValueChange={(value: string) => {
28
+ if (value === "[NONE]")
29
+ setFieldValue("url", true);
30
+ else
31
+ setFieldValue("url", value);
32
+ }}
33
+ label={"Preview type"}
34
+ renderValue={(value: string) => {
35
+ switch (value) {
36
+ case "image":
37
+ return "Image";
38
+ case "video":
39
+ return "Video";
40
+ case "audio":
41
+ return "Audio";
42
+ default:
43
+ return "Display URL";
44
+ }
45
+ }}
46
+ value={urlValue ?? "[NONE]"}>
47
+ <SelectItem value={"[NONE]"}>
48
+ Display URL
49
+ </SelectItem>
50
+ <SelectItem value={"image"}>
51
+ Image
52
+ </SelectItem>
53
+ <SelectItem value={"video"}>
54
+ Video
55
+ </SelectItem>
56
+ <SelectItem value={"audio"}>
57
+ Audio
58
+ </SelectItem>
59
+ </Select>
60
+ </div>
61
+
62
+ <div className={"col-span-12"}>
63
+
64
+ <ValidationPanel>
65
+
66
+ <StringPropertyValidation disabled={disabled}
67
+ max={true}
68
+ min={true}
69
+ trim={true}
70
+ showErrors={showErrors}/>
71
+
72
+ </ValidationPanel>
73
+
74
+ </div>
75
+
76
+ <div className={"col-span-12"}>
77
+
78
+ <TextField name={"defaultValue"}
79
+ disabled={disabled}
80
+ onChange={(e: any) => {
81
+ setFieldValue("defaultValue", e.target.value === "" ? undefined : e.target.value);
82
+ }}
83
+ label={"Default value"}
84
+ value={getIn(values, "defaultValue") ?? ""}/>
85
+
86
+ </div>
87
+ </>
88
+ );
89
+ }
@@ -1,14 +1,13 @@
1
- import { EntityCollection } from "@firecms/firebase";
1
+ import { EntityCollection, makePropertiesEditable } from "@firecms/core";
2
2
 
3
3
  export const blogCollectionTemplate:EntityCollection = {
4
4
  path: "blog",
5
5
  name: "Blog",
6
6
  singularName: "Blog entry",
7
- group: "Content",
8
7
  icon: "article",
9
8
  description: "A collection of blog entries",
10
9
  defaultSize: "l",
11
- properties: {
10
+ properties: makePropertiesEditable({
12
11
  name: {
13
12
  name: "Name",
14
13
  validation: { required: true },
@@ -108,7 +107,7 @@ export const blogCollectionTemplate:EntityCollection = {
108
107
  previewAsTag: true
109
108
  }
110
109
  }
111
- },
110
+ }),
112
111
  initialFilter: {
113
112
  status: ["==", "published"]
114
113
  }
@@ -1,13 +1,12 @@
1
- import { EntityCollection } from "@firecms/core";
1
+ import { EntityCollection, makePropertiesEditable } from "@firecms/core";
2
2
 
3
3
  export const productsCollectionTemplate: EntityCollection = {
4
4
  path: "products",
5
5
  name: "Products",
6
6
  singularName: "Product",
7
- group: "Main",
8
7
  icon: "shopping_cart",
9
8
  description: "List of the products currently sold in your shop",
10
- properties: {
9
+ properties: makePropertiesEditable({
11
10
  name: {
12
11
  dataType: "string",
13
12
  name: "Name",
@@ -84,6 +83,5 @@ export const productsCollectionTemplate: EntityCollection = {
84
83
  name: "Added on",
85
84
  autoValue: "on_create"
86
85
  }
87
- }
88
-
86
+ })
89
87
  };