@firecms/core 3.0.0-canary.203 → 3.0.0-canary.204
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/form/EntityForm.d.ts +3 -2
- package/dist/index.es.js +52 -100
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +52 -100
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/core/EntityEditView.tsx +7 -23
- package/src/form/EntityForm.tsx +82 -67
package/dist/index.umd.js
CHANGED
|
@@ -16298,6 +16298,7 @@
|
|
|
16298
16298
|
onEntityChange,
|
|
16299
16299
|
openEntityMode = "full_screen",
|
|
16300
16300
|
formex: formexProp,
|
|
16301
|
+
Builder,
|
|
16301
16302
|
EntityFormActionsComponent = EntityFormActions,
|
|
16302
16303
|
showDefaultActions = true,
|
|
16303
16304
|
showEntityPath = true,
|
|
@@ -16612,45 +16613,50 @@
|
|
|
16612
16613
|
}
|
|
16613
16614
|
}, [formex$1.isSubmitting, autoSave, underlyingChanges, entity, formex$1.values, formex$1.touched, formex$1.setFieldValue]);
|
|
16614
16615
|
const formFieldKeys = getFormFieldKeys(resolvedCollection);
|
|
16615
|
-
const formFields = () =>
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
const
|
|
16621
|
-
if (
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
if (!Builder && !additionalField.value) {
|
|
16640
|
-
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
16616
|
+
const formFields = () => {
|
|
16617
|
+
if (Builder) {
|
|
16618
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity, modifiedValues: formex$1.values, formContext });
|
|
16619
|
+
}
|
|
16620
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { children: formFieldKeys.map((key_1) => {
|
|
16621
|
+
const property_0 = resolvedCollection.properties[key_1];
|
|
16622
|
+
if (property_0) {
|
|
16623
|
+
const underlyingValueHasChanged = !!underlyingChanges && Object.keys(underlyingChanges).includes(key_1) && formex$1.touched[key_1];
|
|
16624
|
+
const disabled = !autoSave && formex$1.isSubmitting || isReadOnly(property_0) || Boolean(property_0.disabled);
|
|
16625
|
+
const hidden = isHidden(property_0);
|
|
16626
|
+
if (hidden) return null;
|
|
16627
|
+
const widthPercentage = property_0.widthPercentage ?? 100;
|
|
16628
|
+
const cmsFormFieldProps = {
|
|
16629
|
+
propertyKey: key_1,
|
|
16630
|
+
disabled,
|
|
16631
|
+
property: property_0,
|
|
16632
|
+
includeDescription: property_0.description || property_0.longDescription,
|
|
16633
|
+
underlyingValueHasChanged: underlyingValueHasChanged && !autoSave,
|
|
16634
|
+
context: formContext,
|
|
16635
|
+
partOfArray: false,
|
|
16636
|
+
minimalistView: false,
|
|
16637
|
+
autoFocus: false
|
|
16638
|
+
};
|
|
16639
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormEntry, { propertyKey: key_1, widthPercentage, children: /* @__PURE__ */ jsxRuntime.jsx(PropertyFieldBinding, { ...cmsFormFieldProps }) }, `field_${key_1}`);
|
|
16641
16640
|
}
|
|
16642
|
-
const
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16649
|
-
|
|
16650
|
-
|
|
16651
|
-
|
|
16652
|
-
|
|
16653
|
-
|
|
16641
|
+
const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_1);
|
|
16642
|
+
if (additionalField && entity) {
|
|
16643
|
+
const Builder_0 = additionalField.Builder;
|
|
16644
|
+
if (!Builder_0 && !additionalField.value) {
|
|
16645
|
+
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
16646
|
+
}
|
|
16647
|
+
const child = Builder_0 ? /* @__PURE__ */ jsxRuntime.jsx(Builder_0, { entity, context }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: additionalField.value?.({
|
|
16648
|
+
entity,
|
|
16649
|
+
context
|
|
16650
|
+
})?.toString() });
|
|
16651
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
16652
|
+
/* @__PURE__ */ jsxRuntime.jsx(LabelWithIconAndTooltip, { propertyKey: key_1, icon: /* @__PURE__ */ jsxRuntime.jsx(ui.NotesIcon, { size: "small" }), title: additionalField.name, className: "text-text-secondary dark:text-text-secondary-dark ml-3.5" }),
|
|
16653
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.paperMixin, "w-full min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar"), children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: child }) })
|
|
16654
|
+
] }, `additional_${key_1}`);
|
|
16655
|
+
}
|
|
16656
|
+
console.warn(`Property ${key_1} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
|
|
16657
|
+
return null;
|
|
16658
|
+
}).filter(Boolean) });
|
|
16659
|
+
};
|
|
16654
16660
|
const formRef = React.useRef(null);
|
|
16655
16661
|
const formView = /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
16656
16662
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full py-2 flex flex-col items-start my-4 lg:my-6", children: [
|
|
@@ -21751,52 +21757,6 @@
|
|
|
21751
21757
|
}
|
|
21752
21758
|
return t5;
|
|
21753
21759
|
}
|
|
21754
|
-
function SecondaryForm(t0) {
|
|
21755
|
-
const $ = reactCompilerRuntime.c(12);
|
|
21756
|
-
const {
|
|
21757
|
-
collection,
|
|
21758
|
-
className,
|
|
21759
|
-
customView,
|
|
21760
|
-
entity,
|
|
21761
|
-
formContext,
|
|
21762
|
-
forceActionsAtTheBottom
|
|
21763
|
-
} = t0;
|
|
21764
|
-
if (!customView.Builder) {
|
|
21765
|
-
console.error("customView.Builder is not defined");
|
|
21766
|
-
return null;
|
|
21767
|
-
}
|
|
21768
|
-
let t1;
|
|
21769
|
-
if ($[0] !== collection || $[1] !== customView.Builder || $[2] !== entity || $[3] !== formContext) {
|
|
21770
|
-
t1 = formContext && /* @__PURE__ */ jsxRuntime.jsx(customView.Builder, { collection, entity, modifiedValues: formContext.formex.values ?? entity?.values, formContext });
|
|
21771
|
-
$[0] = collection;
|
|
21772
|
-
$[1] = customView.Builder;
|
|
21773
|
-
$[2] = entity;
|
|
21774
|
-
$[3] = formContext;
|
|
21775
|
-
$[4] = t1;
|
|
21776
|
-
} else {
|
|
21777
|
-
t1 = $[4];
|
|
21778
|
-
}
|
|
21779
|
-
let t2;
|
|
21780
|
-
if ($[5] !== t1) {
|
|
21781
|
-
t2 = /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: t1 });
|
|
21782
|
-
$[5] = t1;
|
|
21783
|
-
$[6] = t2;
|
|
21784
|
-
} else {
|
|
21785
|
-
t2 = $[6];
|
|
21786
|
-
}
|
|
21787
|
-
let t3;
|
|
21788
|
-
if ($[7] !== className || $[8] !== forceActionsAtTheBottom || $[9] !== formContext || $[10] !== t2) {
|
|
21789
|
-
t3 = /* @__PURE__ */ jsxRuntime.jsx(FormLayoutInner, { className, forceActionsAtTheBottom, formContext, EntityFormActionsComponent: EntityEditViewFormActions, children: t2 });
|
|
21790
|
-
$[7] = className;
|
|
21791
|
-
$[8] = forceActionsAtTheBottom;
|
|
21792
|
-
$[9] = formContext;
|
|
21793
|
-
$[10] = t2;
|
|
21794
|
-
$[11] = t3;
|
|
21795
|
-
} else {
|
|
21796
|
-
t3 = $[11];
|
|
21797
|
-
}
|
|
21798
|
-
return t3;
|
|
21799
|
-
}
|
|
21800
21760
|
function EntityEditViewInner({
|
|
21801
21761
|
path,
|
|
21802
21762
|
entityId,
|
|
@@ -21833,7 +21793,6 @@
|
|
|
21833
21793
|
setSelectedTab(selectedTabProp ?? MAIN_TAB_VALUE);
|
|
21834
21794
|
}
|
|
21835
21795
|
}, [selectedTabProp]);
|
|
21836
|
-
const mainViewVisible = selectedTab === MAIN_TAB_VALUE;
|
|
21837
21796
|
const subcollections = (collection.subcollections ?? []).filter((c) => !c.hideFromNavigation);
|
|
21838
21797
|
const subcollectionsCount = subcollections?.length ?? 0;
|
|
21839
21798
|
const customViews = collection.entityViews;
|
|
@@ -21841,25 +21800,19 @@
|
|
|
21841
21800
|
const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;
|
|
21842
21801
|
const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter(Boolean) : [];
|
|
21843
21802
|
const selectedEntityView = resolvedEntityViews.find((e_0) => e_0.key === selectedTab);
|
|
21803
|
+
const selectedSecondaryForm = formContext && customViews && resolvedEntityViews.filter((e_1) => e_1.includeActions).find((e_2) => e_2.key === selectedTab);
|
|
21844
21804
|
const actionsAtTheBottom = !largeLayout || layout === "side_panel" || selectedEntityView?.includeActions === "bottom";
|
|
21845
|
-
const
|
|
21846
|
-
|
|
21847
|
-
if (!customView
|
|
21848
|
-
|
|
21849
|
-
return null;
|
|
21850
|
-
}
|
|
21851
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SecondaryForm, { className: selectedTab !== customView.key ? "hidden" : "", customView, formContext, collection, forceActionsAtTheBottom: !largeLayout || layout === "side_panel" || customView.includeActions === "bottom", entity: usedEntity }, `custom_view_${customView.key}`);
|
|
21852
|
-
}).filter(Boolean);
|
|
21853
|
-
const customViewsView = customViews && resolvedEntityViews.filter((e_2) => !e_2.includeActions).map((customView_0) => {
|
|
21854
|
-
if (!customView_0) return null;
|
|
21855
|
-
const Builder = customView_0.Builder;
|
|
21805
|
+
const mainViewVisible = selectedTab === MAIN_TAB_VALUE || Boolean(selectedSecondaryForm);
|
|
21806
|
+
const customViewsView = customViews && resolvedEntityViews.filter((e_3) => !e_3.includeActions).map((customView) => {
|
|
21807
|
+
if (!customView) return null;
|
|
21808
|
+
const Builder = customView.Builder;
|
|
21856
21809
|
if (!Builder) {
|
|
21857
21810
|
console.error("customView.Builder is not defined");
|
|
21858
21811
|
return null;
|
|
21859
21812
|
}
|
|
21860
21813
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
|
|
21861
|
-
"hidden": selectedTab !==
|
|
21862
|
-
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${
|
|
21814
|
+
"hidden": selectedTab !== customView.key
|
|
21815
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
|
|
21863
21816
|
}).filter(Boolean);
|
|
21864
21817
|
const globalLoading = dataLoading && !usedEntity;
|
|
21865
21818
|
const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
|
|
@@ -21898,7 +21851,7 @@
|
|
|
21898
21851
|
};
|
|
21899
21852
|
onSaved?.(res);
|
|
21900
21853
|
formProps?.onSaved?.(res);
|
|
21901
|
-
} });
|
|
21854
|
+
}, Builder: selectedSecondaryForm?.Builder });
|
|
21902
21855
|
const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
|
|
21903
21856
|
const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
|
|
21904
21857
|
const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
|
|
@@ -21916,7 +21869,6 @@
|
|
|
21916
21869
|
] })
|
|
21917
21870
|
] }),
|
|
21918
21871
|
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,
|
|
21919
|
-
secondaryForms,
|
|
21920
21872
|
customViewsView,
|
|
21921
21873
|
subCollectionsViews
|
|
21922
21874
|
] });
|