@firecms/collection_editor 3.3.0 → 3.4.0-canary.63041d0

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 CHANGED
@@ -11483,6 +11483,30 @@ function DisplaySettingsForm({
11483
11483
  });
11484
11484
  return result;
11485
11485
  }, [resolvedCollection.properties]);
11486
+ const imageProperties = useMemo(() => {
11487
+ const result_0 = [];
11488
+ if (!resolvedCollection.properties) return result_0;
11489
+ const isImageProperty = (prop_0) => {
11490
+ if (!prop_0 || !("dataType" in prop_0)) return false;
11491
+ if (prop_0.dataType === "string") {
11492
+ return Boolean(prop_0.storage?.acceptedFiles?.includes("image/*")) || prop_0.url === "image";
11493
+ }
11494
+ if (prop_0.dataType === "array" && prop_0.of) {
11495
+ return isImageProperty(prop_0.of);
11496
+ }
11497
+ return false;
11498
+ };
11499
+ Object.entries(resolvedCollection.properties).forEach(([key_0, prop_1]) => {
11500
+ if (isImageProperty(prop_1)) {
11501
+ result_0.push({
11502
+ key: key_0,
11503
+ label: prop_1.name || key_0,
11504
+ property: prop_1
11505
+ });
11506
+ }
11507
+ });
11508
+ return result_0;
11509
+ }, [resolvedCollection.properties]);
11486
11510
  if (typeof values.customId === "object") ;
11487
11511
  else if (values.customId === true) ;
11488
11512
  else if (values.customId === false) ;
@@ -11509,25 +11533,25 @@ function DisplaySettingsForm({
11509
11533
  ")"
11510
11534
  ] });
11511
11535
  }
11512
- const prop_0 = numberProperties.find((p_0) => p_0.key === value_1);
11513
- if (!prop_0) return t("select_a_property");
11514
- const fieldConfig = getFieldConfig(prop_0.property, customizationController.propertyConfigs);
11536
+ const prop_2 = numberProperties.find((p_0) => p_0.key === value_1);
11537
+ if (!prop_2) return t("select_a_property");
11538
+ const fieldConfig = getFieldConfig(prop_2.property, customizationController.propertyConfigs);
11515
11539
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
11516
11540
  /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig }),
11517
- /* @__PURE__ */ jsx("span", { children: prop_0.label })
11541
+ /* @__PURE__ */ jsx("span", { children: prop_2.label })
11518
11542
  ] });
11519
11543
  }, endAdornment: values.orderProperty ? /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (e) => {
11520
11544
  e.stopPropagation();
11521
11545
  setFieldValue("orderProperty", void 0);
11522
- }, children: /* @__PURE__ */ jsx(CloseIcon, { size: "small" }) }) : void 0, children: numberProperties.map((prop_1) => {
11523
- const fieldConfig_0 = getFieldConfig(prop_1.property, customizationController.propertyConfigs);
11524
- return /* @__PURE__ */ jsx(SelectItem, { value: prop_1.key, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11546
+ }, children: /* @__PURE__ */ jsx(CloseIcon, { size: "small" }) }) : void 0, children: numberProperties.map((prop_3) => {
11547
+ const fieldConfig_0 = getFieldConfig(prop_3.property, customizationController.propertyConfigs);
11548
+ return /* @__PURE__ */ jsx(SelectItem, { value: prop_3.key, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11525
11549
  /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig_0 }),
11526
11550
  /* @__PURE__ */ jsxs("div", { children: [
11527
- /* @__PURE__ */ jsx("div", { children: prop_1.label }),
11551
+ /* @__PURE__ */ jsx("div", { children: prop_3.label }),
11528
11552
  /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "secondary", children: fieldConfig_0?.name || t("number") })
11529
11553
  ] })
11530
- ] }) }, prop_1.key);
11554
+ ] }) }, prop_3.key);
11531
11555
  }) }, `order-select-${numberProperties.length}`),
11532
11556
  /* @__PURE__ */ jsx(FieldCaption, { error: orderPropertyMissing, children: orderPropertyMissing ? t("order_property_not_found", {
11533
11557
  property: values.orderProperty ?? ""
@@ -11566,14 +11590,54 @@ function DisplaySettingsForm({
11566
11590
  ] });
11567
11591
  })()
11568
11592
  ] }),
11569
- /* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(Select, { name: "defaultSize", size: "large", fullWidth: true, label: t("default_row_size"), position: "item-aligned", onChange: handleChange, value: values.defaultSize ?? "", renderValue: (value_2) => value_2.toUpperCase(), children: ["xs", "s", "m", "l", "xl"].map((value_3) => /* @__PURE__ */ jsx(SelectItem, { value: value_3, children: value_3.toUpperCase() }, `size-select-${value_3}`)) }) }),
11593
+ /* @__PURE__ */ jsx("div", { className: "col-span-12 mt-4", children: (() => {
11594
+ const imagePropertyMissing = Boolean(values.imageProperty) && !imageProperties.some((p_2) => p_2.key === values.imageProperty);
11595
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
11596
+ /* @__PURE__ */ jsx(Typography, { variant: "label", color: "secondary", className: "ml-3.5", children: t("image_property") }),
11597
+ /* @__PURE__ */ jsx(Select, { name: "imageProperty", size: "large", fullWidth: true, position: "item-aligned", disabled: imageProperties.length === 0, error: imagePropertyMissing, value: values.imageProperty ?? "", onValueChange: (v_0) => {
11598
+ setFieldValue("imageProperty", v_0 || void 0);
11599
+ }, renderValue: (value_2) => {
11600
+ if (imagePropertyMissing) {
11601
+ return /* @__PURE__ */ jsxs("span", { className: "text-red-500", children: [
11602
+ value_2,
11603
+ " (",
11604
+ t("not_found_suffix"),
11605
+ ")"
11606
+ ] });
11607
+ }
11608
+ const prop_4 = imageProperties.find((p_3) => p_3.key === value_2);
11609
+ if (!prop_4) return t("select_a_property");
11610
+ const fieldConfig_1 = getFieldConfig(prop_4.property, customizationController.propertyConfigs);
11611
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
11612
+ /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig_1 }),
11613
+ /* @__PURE__ */ jsx("span", { children: prop_4.label })
11614
+ ] });
11615
+ }, endAdornment: values.imageProperty ? /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (e_0) => {
11616
+ e_0.stopPropagation();
11617
+ setFieldValue("imageProperty", void 0);
11618
+ }, children: /* @__PURE__ */ jsx(CloseIcon, { size: "small" }) }) : void 0, children: imageProperties.map((prop_5) => {
11619
+ const fieldConfig_2 = getFieldConfig(prop_5.property, customizationController.propertyConfigs);
11620
+ return /* @__PURE__ */ jsx(SelectItem, { value: prop_5.key, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11621
+ /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig_2 }),
11622
+ /* @__PURE__ */ jsxs("div", { children: [
11623
+ /* @__PURE__ */ jsx("div", { children: prop_5.label }),
11624
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "secondary", children: fieldConfig_2?.name || prop_5.label })
11625
+ ] })
11626
+ ] }) }, prop_5.key);
11627
+ }) }, `image-select-${imageProperties.length}`),
11628
+ /* @__PURE__ */ jsx(FieldCaption, { error: imagePropertyMissing, children: imagePropertyMissing ? t("image_property_not_found", {
11629
+ property: values.imageProperty ?? ""
11630
+ }) : imageProperties.length === 0 ? t("no_image_properties") : t("image_property_description") })
11631
+ ] });
11632
+ })() }),
11633
+ /* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(Select, { name: "defaultSize", size: "large", fullWidth: true, label: t("default_row_size"), position: "item-aligned", onChange: handleChange, value: values.defaultSize ?? "", renderValue: (value_3) => value_3.toUpperCase(), children: ["xs", "s", "m", "l", "xl"].map((value_4) => /* @__PURE__ */ jsx(SelectItem, { value: value_4, children: value_4.toUpperCase() }, `size-select-${value_4}`)) }) }),
11570
11634
  /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
11571
- /* @__PURE__ */ jsx(TextField, { name: "sideDialogWidth", type: "number", "aria-describedby": "sideDialogWidth-helper", onChange: (e_0) => {
11572
- const value_4 = e_0.target.value;
11573
- if (!value_4) {
11635
+ /* @__PURE__ */ jsx(TextField, { name: "sideDialogWidth", type: "number", "aria-describedby": "sideDialogWidth-helper", onChange: (e_1) => {
11636
+ const value_5 = e_1.target.value;
11637
+ if (!value_5) {
11574
11638
  setFieldValue("sideDialogWidth", null);
11575
- } else if (!isNaN(Number(value_4))) {
11576
- setFieldValue("sideDialogWidth", Number(value_4));
11639
+ } else if (!isNaN(Number(value_5))) {
11640
+ setFieldValue("sideDialogWidth", Number(value_5));
11577
11641
  }
11578
11642
  }, endAdornment: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: () => {
11579
11643
  setFieldValue("sideDialogWidth", null);
@@ -11581,11 +11645,11 @@ function DisplaySettingsForm({
11581
11645
  /* @__PURE__ */ jsx(FieldCaption, { children: t("side_dialog_width_description") })
11582
11646
  ] }),
11583
11647
  /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
11584
- /* @__PURE__ */ jsx(BooleanSwitchWithLabel, { position: "start", size: "large", label: values.inlineEditing === void 0 || values.inlineEditing ? t("inline_editing_enabled") : t("inline_editing_disabled"), onValueChange: (v_0) => setFieldValue("inlineEditing", v_0), value: values.inlineEditing === void 0 ? true : values.inlineEditing }),
11648
+ /* @__PURE__ */ jsx(BooleanSwitchWithLabel, { position: "start", size: "large", label: values.inlineEditing === void 0 || values.inlineEditing ? t("inline_editing_enabled") : t("inline_editing_disabled"), onValueChange: (v_1) => setFieldValue("inlineEditing", v_1), value: values.inlineEditing === void 0 ? true : values.inlineEditing }),
11585
11649
  /* @__PURE__ */ jsx(FieldCaption, { children: t("inline_editing_description") })
11586
11650
  ] }),
11587
11651
  /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
11588
- /* @__PURE__ */ jsx(BooleanSwitchWithLabel, { position: "start", size: "large", label: values.includeJsonView === void 0 || values.includeJsonView ? t("include_json_view") : t("no_json_view"), onValueChange: (v_1) => setFieldValue("includeJsonView", v_1), value: values.includeJsonView === void 0 ? true : values.includeJsonView }),
11652
+ /* @__PURE__ */ jsx(BooleanSwitchWithLabel, { position: "start", size: "large", label: values.includeJsonView === void 0 || values.includeJsonView ? t("include_json_view") : t("no_json_view"), onValueChange: (v_2) => setFieldValue("includeJsonView", v_2), value: values.includeJsonView === void 0 ? true : values.includeJsonView }),
11589
11653
  /* @__PURE__ */ jsx(FieldCaption, { children: t("json_view_description") })
11590
11654
  ] })
11591
11655
  ] }),
@@ -12147,7 +12211,7 @@ function CollectionPropertiesEditorForm({
12147
12211
  /* @__PURE__ */ jsx(Button, { className: "mt-8 w-full", size: "large", onClick: () => setNewPropertyDialogOpen(true), startIcon: /* @__PURE__ */ jsx(AddIcon, {}), children: t("add_new_property") })
12148
12212
  ] }),
12149
12213
  !asDialog && /* @__PURE__ */ jsx("div", { className: "col-span-12 lg:col-span-7 p-4 md:py-8 md:px-4 h-full overflow-auto pb-20 md:pb-20", children: /* @__PURE__ */ jsxs("div", { className: "sticky top-8 min-h-full w-full flex flex-col justify-center", children: [
12150
- selectedPropertyFullId && selectedProperty && !isPropertyBuilder(selectedProperty) && /* @__PURE__ */ jsx(PropertyForm, { inArray: false, existingProperty: !isNewCollection, autoUpdateId: false, allowDataInference: !isNewCollection, autoOpenTypeSelect: false, propertyKey: selectedPropertyKey, propertyNamespace: selectedPropertyNamespace, property: selectedProperty, onPropertyChanged, onDelete: deleteProperty, onError: onPropertyErrorInternal, forceShowErrors: showErrors, initialErrors, getData, propertyConfigs, collectionEditable, collectionProperties: values.properties }, `edit_view_${selectedPropertyIndex}_${generationCounter}`),
12214
+ selectedPropertyFullId && selectedProperty && !isPropertyBuilder(selectedProperty) && /* @__PURE__ */ jsx(PropertyForm, { inArray: false, existingProperty: !isNewCollection, autoUpdateId: false, allowDataInference: !isNewCollection, autoOpenTypeSelect: false, propertyKey: selectedPropertyKey, propertyNamespace: selectedPropertyNamespace, property: selectedProperty, onPropertyChanged, onDelete: deleteProperty, onError: onPropertyErrorInternal, forceShowErrors: showErrors, initialErrors, getData, propertyConfigs, collectionEditable, collectionProperties: values.properties }, `edit_view_${selectedPropertyFullId}_${generationCounter}`),
12151
12215
  !selectedProperty && /* @__PURE__ */ jsxs("div", { className: "w-full flex flex-col items-center justify-center h-full gap-4", children: [
12152
12216
  /* @__PURE__ */ jsx(Typography, { variant: "label", className: "", children: emptyCollection ? t("add_first_property") : t("select_property_to_edit") }),
12153
12217
  /* @__PURE__ */ jsxs(Button, { onClick: () => setNewPropertyDialogOpen(true), children: [
@@ -12157,7 +12221,7 @@ function CollectionPropertiesEditorForm({
12157
12221
  ] }),
12158
12222
  selectedProperty && isPropertyBuilder(selectedProperty) && /* @__PURE__ */ jsx(Typography, { variant: "label", className: "flex items-center justify-center", children: t("property_defined_as_builder") })
12159
12223
  ] }) }),
12160
- asDialog && /* @__PURE__ */ jsx(PropertyFormDialog, { inArray: false, open: selectedPropertyIndex !== void 0, autoUpdateId: !selectedProperty, allowDataInference: !isNewCollection, existingProperty: true, autoOpenTypeSelect: false, propertyKey: selectedPropertyKey, propertyNamespace: selectedPropertyNamespace, property: selectedProperty, onPropertyChanged, onDelete: deleteProperty, onError: onPropertyErrorInternal, forceShowErrors: showErrors, initialErrors, getData, propertyConfigs, collectionEditable, collectionProperties: values.properties, onCancel: closePropertyDialog, onOkClicked: asDialog ? closePropertyDialog : void 0 }, `edit_view_${selectedPropertyIndex}_${generationCounter}`)
12224
+ asDialog && /* @__PURE__ */ jsx(PropertyFormDialog, { inArray: false, open: selectedPropertyIndex !== void 0, autoUpdateId: !selectedProperty, allowDataInference: !isNewCollection, existingProperty: true, autoOpenTypeSelect: false, propertyKey: selectedPropertyKey, propertyNamespace: selectedPropertyNamespace, property: selectedProperty, onPropertyChanged, onDelete: deleteProperty, onError: onPropertyErrorInternal, forceShowErrors: showErrors, initialErrors, getData, propertyConfigs, collectionEditable, collectionProperties: values.properties, onCancel: closePropertyDialog, onOkClicked: asDialog ? closePropertyDialog : void 0 }, `edit_view_${selectedPropertyFullId}_${generationCounter}`)
12161
12225
  ] });
12162
12226
  return /* @__PURE__ */ jsxs(Fragment, { children: [
12163
12227
  body,