@firecms/core 3.0.0-canary.174 → 3.0.0-canary.176

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.umd.js CHANGED
@@ -11523,6 +11523,61 @@
11523
11523
  }
11524
11524
  return t4;
11525
11525
  }
11526
+ function FormLayout(t0) {
11527
+ const $ = reactCompilerRuntime.c(12);
11528
+ const {
11529
+ id,
11530
+ formex: formex2,
11531
+ children,
11532
+ className
11533
+ } = t0;
11534
+ let t1;
11535
+ if ($[0] !== className) {
11536
+ t1 = ui.cls("relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl w-full h-fit", className);
11537
+ $[0] = className;
11538
+ $[1] = t1;
11539
+ } else {
11540
+ t1 = $[1];
11541
+ }
11542
+ let t2;
11543
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
11544
+ t2 = ui.cls("flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10");
11545
+ $[2] = t2;
11546
+ } else {
11547
+ t2 = $[2];
11548
+ }
11549
+ let t3;
11550
+ if ($[3] !== formex2.dirty) {
11551
+ t3 = formex2.dirty ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Unsaved changes", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", colorScheme: "orangeDarker", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: "smallest" }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "In sync with the database", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CheckIcon, { size: "smallest" }) }) });
11552
+ $[3] = formex2.dirty;
11553
+ $[4] = t3;
11554
+ } else {
11555
+ t3 = $[4];
11556
+ }
11557
+ let t4;
11558
+ if ($[5] !== children || $[6] !== t3) {
11559
+ t4 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t2, children: [
11560
+ t3,
11561
+ children
11562
+ ] });
11563
+ $[5] = children;
11564
+ $[6] = t3;
11565
+ $[7] = t4;
11566
+ } else {
11567
+ t4 = $[7];
11568
+ }
11569
+ let t5;
11570
+ if ($[8] !== id || $[9] !== t1 || $[10] !== t4) {
11571
+ t5 = /* @__PURE__ */ jsxRuntime.jsx("div", { role: "tabpanel", id, className: t1, children: t4 });
11572
+ $[8] = id;
11573
+ $[9] = t1;
11574
+ $[10] = t4;
11575
+ $[11] = t5;
11576
+ } else {
11577
+ t5 = $[11];
11578
+ }
11579
+ return t5;
11580
+ }
11526
11581
  function EntityEditViewInner({
11527
11582
  path,
11528
11583
  entityId: entityIdProp,
@@ -11811,25 +11866,33 @@
11811
11866
  };
11812
11867
  const resolvedEntityViews = customViews ? customViews.map((e_4) => resolveEntityView(e_4, customizationController.entityViews)).filter(Boolean) : [];
11813
11868
  const selectedEntityView = resolvedEntityViews.find((e_5) => e_5.key === selectedTab);
11814
- const shouldShowEntityActions = !autoSave && (selectedTab === MAIN_TAB_VALUE || selectedEntityView?.includeActions);
11815
- const customViewsView = customViews && resolvedEntityViews.map((customView, colIndex) => {
11869
+ const shouldShowEntityActions = selectedTab === MAIN_TAB_VALUE || selectedEntityView?.includeActions;
11870
+ const secondaryForms = customViews && resolvedEntityViews.filter((e_6) => e_6.includeActions).map((customView, colIndex) => {
11816
11871
  if (!customView) return null;
11817
11872
  const Builder = customView.Builder;
11818
11873
  if (!Builder) {
11819
11874
  console.error("customView.Builder is not defined");
11820
11875
  return null;
11821
11876
  }
11877
+ return /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { className: selectedTab !== customView.key ? "hidden" : "", formex: formex$1, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: formex$1.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
11878
+ }).filter(Boolean);
11879
+ const customViewsView = customViews && resolvedEntityViews.filter((e_7) => !e_7.includeActions).map((customView_0, colIndex_0) => {
11880
+ if (!customView_0) return null;
11881
+ const Builder_0 = customView_0.Builder;
11882
+ if (!Builder_0) {
11883
+ console.error("customView.Builder is not defined");
11884
+ return null;
11885
+ }
11822
11886
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "relative flex-grow w-full h-full overflow-auto", {
11823
- "hidden": selectedTab !== customView.key
11824
- }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: formex$1.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
11887
+ "hidden": selectedTab !== customView_0.key
11888
+ }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder_0, { collection, entity: usedEntity, modifiedValues: formex$1.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView_0.key}`);
11825
11889
  }).filter(Boolean);
11826
11890
  const globalLoading = dataLoading && !usedEntity || (!usedEntity || readOnly === void 0) && (status === "existing" || status === "copy");
11827
- const subCollectionsViews = subcollections && subcollections.map((subcollection, colIndex_0) => {
11891
+ const subCollectionsViews = subcollections && subcollections.map((subcollection, colIndex_1) => {
11828
11892
  const subcollectionId = subcollection.id ?? subcollection.path;
11829
11893
  const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
11830
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("relative flex-grow h-full overflow-auto w-full", {
11831
- "hidden": selectedTab !== subcollectionId
11832
- }), role: "tabpanel", children: [
11894
+ if (selectedTab !== subcollectionId) return null;
11895
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-grow h-full overflow-auto w-full", role: "tabpanel", children: [
11833
11896
  globalLoading || saving && /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {}),
11834
11897
  !globalLoading && (usedEntity && fullPath ? /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionView, { fullPath, parentCollectionIds: [...parentCollectionIds, collection.id], isSubCollection: true, updateUrl: false, ...subcollection, openEntityMode: layout }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center w-full h-full p-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "label", children: "You need to save your entity before adding additional collections" }) }))
11835
11898
  ] }, `subcol_${subcollectionId}`);
@@ -11890,9 +11953,9 @@
11890
11953
  context
11891
11954
  });
11892
11955
  setEntityId(updatedId);
11893
- } catch (e_6) {
11894
- onIdUpdateError?.(e_6);
11895
- console.error(e_6);
11956
+ } catch (e_8) {
11957
+ onIdUpdateError?.(e_8);
11958
+ console.error(e_8);
11896
11959
  }
11897
11960
  setCustomIdLoading(false);
11898
11961
  }
@@ -11966,11 +12029,11 @@
11966
12029
  }
11967
12030
  const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_1);
11968
12031
  if (additionalField && entity) {
11969
- const Builder_0 = additionalField.Builder;
11970
- if (!Builder_0 && !additionalField.value) {
12032
+ const Builder_1 = additionalField.Builder;
12033
+ if (!Builder_1 && !additionalField.value) {
11971
12034
  throw new Error("When using additional fields you need to provide a Builder or a value");
11972
12035
  }
11973
- const child = Builder_0 ? /* @__PURE__ */ jsxRuntime.jsx(Builder_0, { entity, context }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: additionalField.value?.({
12036
+ const child = Builder_1 ? /* @__PURE__ */ jsxRuntime.jsx(Builder_1, { entity, context }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: additionalField.value?.({
11974
12037
  entity,
11975
12038
  context
11976
12039
  })?.toString() });
@@ -12017,8 +12080,7 @@
12017
12080
  pluginActions,
12018
12081
  layout
12019
12082
  });
12020
- const entityView = readOnly === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: [
12021
- formex$1.dirty ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Unsaved changes", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", colorScheme: "orangeDarker", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: "smallest" }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "In sync with the database", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CheckIcon, { size: "smallest" }) }) }),
12083
+ const entityView = readOnly === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12022
12084
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full py-2 flex flex-col items-start mt-4 lg:mt-8 mb-8", children: [
12023
12085
  /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-4 flex-grow line-clamp-1 " + inputCollection.hideIdFromForm ? "mb-2" : "mb-0", variant: "h4", children: title ?? inputCollection.singularName ?? inputCollection.name }),
12024
12086
  /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { color: "base", className: "w-full", size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs("code", { className: "text-xs select-all text-text-secondary dark:text-text-secondary-dark", children: [
@@ -12028,13 +12090,11 @@
12028
12090
  ] }) })
12029
12091
  ] }),
12030
12092
  !collection.hideIdFromForm && /* @__PURE__ */ jsxRuntime.jsx(CustomIdField, { customId: inputCollection.customId, entityId, status, onChange: setEntityId, error: entityIdError, loading: customIdLoading, entity }),
12031
- entityId && formContext && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12032
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-12 flex flex-col gap-8", ref: formRef, children: [
12033
- formFields,
12034
- /* @__PURE__ */ jsxRuntime.jsx(ErrorFocus, { containerRef: formRef })
12035
- ] }),
12036
- actionsAtTheBottom && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16" })
12037
- ] })
12093
+ entityId && formContext && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-12 flex flex-col gap-8", ref: formRef, children: [
12094
+ formFields,
12095
+ /* @__PURE__ */ jsxRuntime.jsx(ErrorFocus, { containerRef: formRef })
12096
+ ] }) }),
12097
+ actionsAtTheBottom && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16" })
12038
12098
  ] }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12039
12099
  /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
12040
12100
  /* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-12", entity: usedEntity, path, collection })
@@ -12065,13 +12125,12 @@
12065
12125
  });
12066
12126
  return onDiscard();
12067
12127
  }, noValidate: true, className: "flex-1 flex flex-row w-full overflow-y-auto justify-center", children: [
12068
- /* @__PURE__ */ jsxRuntime.jsx("div", { role: "tabpanel", hidden: !mainViewVisible, id: `form_${path}`, className: ui.cls("relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-5xl w-full h-fit", {
12069
- "hidden": !mainViewVisible
12070
- }), children: globalLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {}) }) : entityView }),
12071
- customViewsView,
12072
- subCollectionsViews,
12128
+ /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { className: !mainViewVisible ? "hidden" : "", id: `form_${path}`, formex: formex$1, children: globalLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {}) }) : entityView }),
12129
+ secondaryForms,
12073
12130
  shouldShowEntityActions && dialogActions
12074
- ] })
12131
+ ] }),
12132
+ customViewsView,
12133
+ subCollectionsViews
12075
12134
  ] });
12076
12135
  if (plugins) {
12077
12136
  plugins.forEach((plugin_0) => {
@@ -12168,7 +12227,7 @@
12168
12227
  setPendingClose,
12169
12228
  pluginActions
12170
12229
  }) {
12171
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("overflow-auto h-full flex flex-col gap-2 w-96 px-4 py-16 sticky top-0 border-l", ui.defaultBorderMixin), children: [
12230
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("overflow-auto h-full flex flex-col gap-2 w-80 xl:w-96 px-4 py-16 sticky top-0 border-l", ui.defaultBorderMixin), children: [
12172
12231
  /* @__PURE__ */ jsxRuntime.jsxs(ui.LoadingButton, { fullWidth: true, variant: "filled", color: "primary", type: "submit", size: "large", disabled: disabled || isSubmitting, onClick: () => {
12173
12232
  setPendingClose?.(false);
12174
12233
  }, children: [
@@ -17220,12 +17279,13 @@
17220
17279
  showError,
17221
17280
  disabled,
17222
17281
  isSubmitting,
17223
- minimalistView,
17282
+ minimalistView: minimalistViewProp,
17224
17283
  property,
17225
17284
  includeDescription,
17226
17285
  setValue,
17227
17286
  setFieldValue
17228
17287
  }) {
17288
+ const minimalistView = minimalistViewProp || property.minimalistView;
17229
17289
  const ofProperty = property.of;
17230
17290
  if (ofProperty.dataType !== "reference") {
17231
17291
  throw Error("ArrayOfReferencesField expected a property containing references");
@@ -18639,7 +18699,7 @@
18639
18699
  error,
18640
18700
  disabled,
18641
18701
  property,
18642
- minimalistView,
18702
+ minimalistView: minimalistViewProp,
18643
18703
  includeDescription,
18644
18704
  underlyingValueHasChanged,
18645
18705
  autoFocus,
@@ -18648,6 +18708,7 @@
18648
18708
  } = t0;
18649
18709
  const pickOnlySomeKeys = property.pickOnlySomeKeys || false;
18650
18710
  const expanded = property.expanded === void 0 ? true : property.expanded;
18711
+ const minimalistView = minimalistViewProp || property.minimalistView;
18651
18712
  if (!property.properties) {
18652
18713
  throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property ${propertyKey}`);
18653
18714
  }
@@ -19579,21 +19640,34 @@
19579
19640
  let underlyingValueHasChanged;
19580
19641
  let value;
19581
19642
  if ($[0] !== t0) {
19582
- ({
19583
- propertyKey,
19584
- value,
19585
- error,
19586
- showError,
19587
- isSubmitting,
19588
- setValue,
19589
- setFieldValue,
19590
- minimalistView,
19591
- property,
19592
- includeDescription,
19593
- underlyingValueHasChanged,
19594
- context,
19595
- disabled
19596
- } = t0);
19643
+ const {
19644
+ propertyKey: t19,
19645
+ value: t22,
19646
+ error: t32,
19647
+ showError: t42,
19648
+ isSubmitting: t52,
19649
+ setValue: t62,
19650
+ setFieldValue: t72,
19651
+ minimalistView: minimalistViewProp,
19652
+ property: t82,
19653
+ includeDescription: t92,
19654
+ underlyingValueHasChanged: t102,
19655
+ context: t112,
19656
+ disabled: t122
19657
+ } = t0;
19658
+ propertyKey = t19;
19659
+ value = t22;
19660
+ error = t32;
19661
+ showError = t42;
19662
+ isSubmitting = t52;
19663
+ setValue = t62;
19664
+ setFieldValue = t72;
19665
+ property = t82;
19666
+ includeDescription = t92;
19667
+ underlyingValueHasChanged = t102;
19668
+ context = t112;
19669
+ disabled = t122;
19670
+ minimalistView = minimalistViewProp || property.minimalistView;
19597
19671
  if (!property.of) {
19598
19672
  throw Error("RepeatFieldBinding misconfiguration. Property `of` not set");
19599
19673
  }
@@ -19822,13 +19896,14 @@
19822
19896
  isSubmitting,
19823
19897
  setValue,
19824
19898
  setFieldValue,
19825
- minimalistView,
19899
+ minimalistView: minimalistViewProp,
19826
19900
  property,
19827
19901
  includeDescription,
19828
19902
  underlyingValueHasChanged,
19829
19903
  context,
19830
19904
  disabled
19831
19905
  }) {
19906
+ const minimalistView = minimalistViewProp || property.minimalistView;
19832
19907
  if (!property.oneOf) throw Error("ArrayOneOfField misconfiguration. Property `oneOf` not set");
19833
19908
  const expanded = property.expanded === void 0 ? true : property.expanded;
19834
19909
  useClearRestoreValue({
@@ -20266,13 +20341,14 @@
20266
20341
  error,
20267
20342
  showError,
20268
20343
  setValue,
20269
- minimalistView,
20344
+ minimalistView: minimalistViewProp,
20270
20345
  property,
20271
20346
  includeDescription,
20272
20347
  underlyingValueHasChanged,
20273
20348
  context,
20274
20349
  disabled
20275
20350
  } = t0;
20351
+ const minimalistView = minimalistViewProp || property.minimalistView;
20276
20352
  let resolvedProperties = "resolvedProperties" in property ? property.resolvedProperties : void 0;
20277
20353
  if (!resolvedProperties) {
20278
20354
  let t12;
@@ -23025,10 +23101,10 @@
23025
23101
  }
23026
23102
  const lastCollectionEntry = navigationEntries.findLast((entry_1) => entry_1.type === "collection");
23027
23103
  if (isNew && !lastCollectionEntry) {
23028
- throw new Error("No collection found in the navigation");
23104
+ throw new Error("INTERNAL: No collection found in the navigation");
23029
23105
  }
23030
23106
  if (!isNew && !lastEntityEntry) {
23031
- throw new Error("No entity found in the navigation");
23107
+ return /* @__PURE__ */ jsxRuntime.jsx(NotFoundPage, {});
23032
23108
  }
23033
23109
  const collection = isNew ? lastCollectionEntry.collection : lastEntityEntry.parentCollection;
23034
23110
  const collectionPath = navigation.resolveIdsFrom(isNew ? lastCollectionEntry.path : lastEntityEntry.path);