@firecms/core 3.0.0-canary.202 → 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 +4 -2
- package/dist/index.es.js +58 -104
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +58 -104
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +1 -1
- package/src/core/EntityEditView.tsx +7 -23
- package/src/form/EntityForm.tsx +89 -69
- package/src/form/field_bindings/MapFieldBinding.tsx +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Entity, EntityCollection, EntityStatus, FormContext } from "../types";
|
|
2
|
+
import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
|
|
3
3
|
import { FormexController } from "@firecms/formex";
|
|
4
4
|
import { ValidationError } from "yup";
|
|
5
5
|
import { EntityFormActionsProps } from "./EntityFormActions";
|
|
@@ -38,8 +38,10 @@ export type EntityFormProps<M extends Record<string, any>> = {
|
|
|
38
38
|
*/
|
|
39
39
|
showEntityPath?: boolean;
|
|
40
40
|
EntityFormActionsComponent?: React.FC<EntityFormActionsProps>;
|
|
41
|
+
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
42
|
+
children?: React.ReactNode;
|
|
41
43
|
};
|
|
42
|
-
export declare function EntityForm<M extends Record<string, any>>({ path, entityId: entityIdProp, collection, onValuesModified, onIdChange, onSaved, entity, initialDirtyValues, onFormContextReady, forceActionsAtTheBottom, initialStatus, className, onStatusChange, onEntityChange, openEntityMode, formex: formexProp, EntityFormActionsComponent, showDefaultActions, showEntityPath }: EntityFormProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare function EntityForm<M extends Record<string, any>>({ path, entityId: entityIdProp, collection, onValuesModified, onIdChange, onSaved, entity, initialDirtyValues, onFormContextReady, forceActionsAtTheBottom, initialStatus, className, onStatusChange, onEntityChange, openEntityMode, formex: formexProp, Builder, EntityFormActionsComponent, showDefaultActions, showEntityPath, children }: EntityFormProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
43
45
|
export declare function yupToFormErrors(yupError: ValidationError): Record<string, any>;
|
|
44
46
|
export declare function FormLayoutInner({ id, formContext, children, className, forceActionsAtTheBottom, pluginActions, EntityFormActionsComponent, showDefaultActions, }: {
|
|
45
47
|
id?: string;
|
package/dist/index.es.js
CHANGED
|
@@ -15723,7 +15723,7 @@ function ArrayContainerItem(t0) {
|
|
|
15723
15723
|
const t1 = provided.innerRef;
|
|
15724
15724
|
const t2 = provided.draggableProps;
|
|
15725
15725
|
const t3 = provided.draggableProps.style;
|
|
15726
|
-
const t4 =
|
|
15726
|
+
const t4 = `relative ${!isDragging ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 dark:hover:bg-opacity-20" : ""} rounded-md opacity-100`;
|
|
15727
15727
|
let t5;
|
|
15728
15728
|
if ($[0] !== internalId || $[1] !== updateItemCustomProps) {
|
|
15729
15729
|
t5 = (props) => updateItemCustomProps(internalId, props);
|
|
@@ -16296,9 +16296,11 @@ function EntityForm({
|
|
|
16296
16296
|
onEntityChange,
|
|
16297
16297
|
openEntityMode = "full_screen",
|
|
16298
16298
|
formex: formexProp,
|
|
16299
|
+
Builder,
|
|
16299
16300
|
EntityFormActionsComponent = EntityFormActions,
|
|
16300
16301
|
showDefaultActions = true,
|
|
16301
|
-
showEntityPath = true
|
|
16302
|
+
showEntityPath = true,
|
|
16303
|
+
children
|
|
16302
16304
|
}) {
|
|
16303
16305
|
if (collection.customId && collection.formAutoSave) {
|
|
16304
16306
|
console.warn(`The collection ${collection.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);
|
|
@@ -16609,48 +16611,53 @@ function EntityForm({
|
|
|
16609
16611
|
}
|
|
16610
16612
|
}, [formex.isSubmitting, autoSave, underlyingChanges, entity, formex.values, formex.touched, formex.setFieldValue]);
|
|
16611
16613
|
const formFieldKeys = getFormFieldKeys(resolvedCollection);
|
|
16612
|
-
const formFields = () =>
|
|
16613
|
-
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
const
|
|
16618
|
-
if (
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
if (!Builder && !additionalField.value) {
|
|
16637
|
-
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
16614
|
+
const formFields = () => {
|
|
16615
|
+
if (Builder) {
|
|
16616
|
+
return /* @__PURE__ */ jsx(Builder, { collection, entity, modifiedValues: formex.values, formContext });
|
|
16617
|
+
}
|
|
16618
|
+
return /* @__PURE__ */ jsx(FormLayout, { children: formFieldKeys.map((key_1) => {
|
|
16619
|
+
const property_0 = resolvedCollection.properties[key_1];
|
|
16620
|
+
if (property_0) {
|
|
16621
|
+
const underlyingValueHasChanged = !!underlyingChanges && Object.keys(underlyingChanges).includes(key_1) && formex.touched[key_1];
|
|
16622
|
+
const disabled = !autoSave && formex.isSubmitting || isReadOnly(property_0) || Boolean(property_0.disabled);
|
|
16623
|
+
const hidden = isHidden(property_0);
|
|
16624
|
+
if (hidden) return null;
|
|
16625
|
+
const widthPercentage = property_0.widthPercentage ?? 100;
|
|
16626
|
+
const cmsFormFieldProps = {
|
|
16627
|
+
propertyKey: key_1,
|
|
16628
|
+
disabled,
|
|
16629
|
+
property: property_0,
|
|
16630
|
+
includeDescription: property_0.description || property_0.longDescription,
|
|
16631
|
+
underlyingValueHasChanged: underlyingValueHasChanged && !autoSave,
|
|
16632
|
+
context: formContext,
|
|
16633
|
+
partOfArray: false,
|
|
16634
|
+
minimalistView: false,
|
|
16635
|
+
autoFocus: false
|
|
16636
|
+
};
|
|
16637
|
+
return /* @__PURE__ */ jsx(FormEntry, { propertyKey: key_1, widthPercentage, children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...cmsFormFieldProps }) }, `field_${key_1}`);
|
|
16638
16638
|
}
|
|
16639
|
-
const
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
/* @__PURE__ */ jsx(
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
|
|
16639
|
+
const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_1);
|
|
16640
|
+
if (additionalField && entity) {
|
|
16641
|
+
const Builder_0 = additionalField.Builder;
|
|
16642
|
+
if (!Builder_0 && !additionalField.value) {
|
|
16643
|
+
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
16644
|
+
}
|
|
16645
|
+
const child = Builder_0 ? /* @__PURE__ */ jsx(Builder_0, { entity, context }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: additionalField.value?.({
|
|
16646
|
+
entity,
|
|
16647
|
+
context
|
|
16648
|
+
})?.toString() });
|
|
16649
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
16650
|
+
/* @__PURE__ */ jsx(LabelWithIconAndTooltip, { propertyKey: key_1, icon: /* @__PURE__ */ jsx(NotesIcon, { size: "small" }), title: additionalField.name, className: "text-text-secondary dark:text-text-secondary-dark ml-3.5" }),
|
|
16651
|
+
/* @__PURE__ */ jsx("div", { className: cls(paperMixin, "w-full min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar"), children: /* @__PURE__ */ jsx(ErrorBoundary, { children: child }) })
|
|
16652
|
+
] }, `additional_${key_1}`);
|
|
16653
|
+
}
|
|
16654
|
+
console.warn(`Property ${key_1} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
|
|
16655
|
+
return null;
|
|
16656
|
+
}).filter(Boolean) });
|
|
16657
|
+
};
|
|
16651
16658
|
const formRef = useRef(null);
|
|
16652
16659
|
const formView = /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16653
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full py-2 flex flex-col items-start
|
|
16660
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full py-2 flex flex-col items-start my-4 lg:my-6", children: [
|
|
16654
16661
|
/* @__PURE__ */ jsx(Typography, { className: "py-4 flex-grow line-clamp-1 " + (collection.hideIdFromForm ? "mb-2" : "mb-0"), variant: "h4", children: title ?? collection.singularName ?? collection.name }),
|
|
16655
16662
|
showEntityPath && /* @__PURE__ */ jsx(Alert, { color: "base", className: "w-full", size: "small", children: /* @__PURE__ */ jsxs("code", { className: "text-xs select-all text-text-secondary dark:text-text-secondary-dark", children: [
|
|
16656
16663
|
entity?.path ?? path,
|
|
@@ -16658,6 +16665,7 @@ function EntityForm({
|
|
|
16658
16665
|
entityId
|
|
16659
16666
|
] }) })
|
|
16660
16667
|
] }),
|
|
16668
|
+
children,
|
|
16661
16669
|
!collection.hideIdFromForm && /* @__PURE__ */ jsx(CustomIdField, { customId: collection.customId, entityId, status, onChange: setEntityId, error: entityIdError, loading: customIdLoading, entity }),
|
|
16662
16670
|
entityId && formContext && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "mt-12 flex flex-col gap-8", ref: formRef, children: [
|
|
16663
16671
|
formFields(),
|
|
@@ -18803,7 +18811,7 @@ function MapFieldBinding(t0) {
|
|
|
18803
18811
|
});
|
|
18804
18812
|
}
|
|
18805
18813
|
};
|
|
18806
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...fieldBindingProps }) }) }, `map-${propertyKey}-${index}`);
|
|
18814
|
+
return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...fieldBindingProps }) }) }, `map-${propertyKey}-${index}`);
|
|
18807
18815
|
};
|
|
18808
18816
|
$[14] = autoFocus;
|
|
18809
18817
|
$[15] = context;
|
|
@@ -21747,52 +21755,6 @@ function EntityEditView(t0) {
|
|
|
21747
21755
|
}
|
|
21748
21756
|
return t5;
|
|
21749
21757
|
}
|
|
21750
|
-
function SecondaryForm(t0) {
|
|
21751
|
-
const $ = c(12);
|
|
21752
|
-
const {
|
|
21753
|
-
collection,
|
|
21754
|
-
className,
|
|
21755
|
-
customView,
|
|
21756
|
-
entity,
|
|
21757
|
-
formContext,
|
|
21758
|
-
forceActionsAtTheBottom
|
|
21759
|
-
} = t0;
|
|
21760
|
-
if (!customView.Builder) {
|
|
21761
|
-
console.error("customView.Builder is not defined");
|
|
21762
|
-
return null;
|
|
21763
|
-
}
|
|
21764
|
-
let t1;
|
|
21765
|
-
if ($[0] !== collection || $[1] !== customView.Builder || $[2] !== entity || $[3] !== formContext) {
|
|
21766
|
-
t1 = formContext && /* @__PURE__ */ jsx(customView.Builder, { collection, entity, modifiedValues: formContext.formex.values ?? entity?.values, formContext });
|
|
21767
|
-
$[0] = collection;
|
|
21768
|
-
$[1] = customView.Builder;
|
|
21769
|
-
$[2] = entity;
|
|
21770
|
-
$[3] = formContext;
|
|
21771
|
-
$[4] = t1;
|
|
21772
|
-
} else {
|
|
21773
|
-
t1 = $[4];
|
|
21774
|
-
}
|
|
21775
|
-
let t2;
|
|
21776
|
-
if ($[5] !== t1) {
|
|
21777
|
-
t2 = /* @__PURE__ */ jsx(ErrorBoundary, { children: t1 });
|
|
21778
|
-
$[5] = t1;
|
|
21779
|
-
$[6] = t2;
|
|
21780
|
-
} else {
|
|
21781
|
-
t2 = $[6];
|
|
21782
|
-
}
|
|
21783
|
-
let t3;
|
|
21784
|
-
if ($[7] !== className || $[8] !== forceActionsAtTheBottom || $[9] !== formContext || $[10] !== t2) {
|
|
21785
|
-
t3 = /* @__PURE__ */ jsx(FormLayoutInner, { className, forceActionsAtTheBottom, formContext, EntityFormActionsComponent: EntityEditViewFormActions, children: t2 });
|
|
21786
|
-
$[7] = className;
|
|
21787
|
-
$[8] = forceActionsAtTheBottom;
|
|
21788
|
-
$[9] = formContext;
|
|
21789
|
-
$[10] = t2;
|
|
21790
|
-
$[11] = t3;
|
|
21791
|
-
} else {
|
|
21792
|
-
t3 = $[11];
|
|
21793
|
-
}
|
|
21794
|
-
return t3;
|
|
21795
|
-
}
|
|
21796
21758
|
function EntityEditViewInner({
|
|
21797
21759
|
path,
|
|
21798
21760
|
entityId,
|
|
@@ -21829,7 +21791,6 @@ function EntityEditViewInner({
|
|
|
21829
21791
|
setSelectedTab(selectedTabProp ?? MAIN_TAB_VALUE);
|
|
21830
21792
|
}
|
|
21831
21793
|
}, [selectedTabProp]);
|
|
21832
|
-
const mainViewVisible = selectedTab === MAIN_TAB_VALUE;
|
|
21833
21794
|
const subcollections = (collection.subcollections ?? []).filter((c2) => !c2.hideFromNavigation);
|
|
21834
21795
|
const subcollectionsCount = subcollections?.length ?? 0;
|
|
21835
21796
|
const customViews = collection.entityViews;
|
|
@@ -21837,25 +21798,19 @@ function EntityEditViewInner({
|
|
|
21837
21798
|
const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;
|
|
21838
21799
|
const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter(Boolean) : [];
|
|
21839
21800
|
const selectedEntityView = resolvedEntityViews.find((e_0) => e_0.key === selectedTab);
|
|
21801
|
+
const selectedSecondaryForm = formContext && customViews && resolvedEntityViews.filter((e_1) => e_1.includeActions).find((e_2) => e_2.key === selectedTab);
|
|
21840
21802
|
const actionsAtTheBottom = !largeLayout || layout === "side_panel" || selectedEntityView?.includeActions === "bottom";
|
|
21841
|
-
const
|
|
21842
|
-
|
|
21843
|
-
if (!customView
|
|
21844
|
-
|
|
21845
|
-
return null;
|
|
21846
|
-
}
|
|
21847
|
-
return /* @__PURE__ */ jsx(SecondaryForm, { className: selectedTab !== customView.key ? "hidden" : "", customView, formContext, collection, forceActionsAtTheBottom: !largeLayout || layout === "side_panel" || customView.includeActions === "bottom", entity: usedEntity }, `custom_view_${customView.key}`);
|
|
21848
|
-
}).filter(Boolean);
|
|
21849
|
-
const customViewsView = customViews && resolvedEntityViews.filter((e_2) => !e_2.includeActions).map((customView_0) => {
|
|
21850
|
-
if (!customView_0) return null;
|
|
21851
|
-
const Builder = customView_0.Builder;
|
|
21803
|
+
const mainViewVisible = selectedTab === MAIN_TAB_VALUE || Boolean(selectedSecondaryForm);
|
|
21804
|
+
const customViewsView = customViews && resolvedEntityViews.filter((e_3) => !e_3.includeActions).map((customView) => {
|
|
21805
|
+
if (!customView) return null;
|
|
21806
|
+
const Builder = customView.Builder;
|
|
21852
21807
|
if (!Builder) {
|
|
21853
21808
|
console.error("customView.Builder is not defined");
|
|
21854
21809
|
return null;
|
|
21855
21810
|
}
|
|
21856
21811
|
return /* @__PURE__ */ jsx("div", { className: cls(defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
|
|
21857
|
-
"hidden": selectedTab !==
|
|
21858
|
-
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${
|
|
21812
|
+
"hidden": selectedTab !== customView.key
|
|
21813
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
|
|
21859
21814
|
}).filter(Boolean);
|
|
21860
21815
|
const globalLoading = dataLoading && !usedEntity;
|
|
21861
21816
|
const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
|
|
@@ -21894,7 +21849,7 @@ function EntityEditViewInner({
|
|
|
21894
21849
|
};
|
|
21895
21850
|
onSaved?.(res);
|
|
21896
21851
|
formProps?.onSaved?.(res);
|
|
21897
|
-
} });
|
|
21852
|
+
}, Builder: selectedSecondaryForm?.Builder });
|
|
21898
21853
|
const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
|
|
21899
21854
|
const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
|
|
21900
21855
|
const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
|
|
@@ -21912,7 +21867,6 @@ function EntityEditViewInner({
|
|
|
21912
21867
|
] })
|
|
21913
21868
|
] }),
|
|
21914
21869
|
globalLoading ? /* @__PURE__ */ jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsx(CircularProgressCenter, {}) }) : entityView,
|
|
21915
|
-
secondaryForms,
|
|
21916
21870
|
customViewsView,
|
|
21917
21871
|
subCollectionsViews
|
|
21918
21872
|
] });
|