@firecms/core 3.0.0-canary.174 → 3.0.0-canary.175
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/PropertyFieldBinding.d.ts +1 -1
- package/dist/index.es.js +90 -31
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +89 -30
- package/dist/index.umd.js.map +1 -1
- package/dist/types/properties.d.ts +2 -2
- package/dist/util/builders.d.ts +1 -1
- package/package.json +17 -17
- package/src/core/EntityEditView.tsx +91 -39
- package/src/form/PropertyFieldBinding.tsx +2 -2
- package/src/routes/FireCMSRoute.tsx +3 -3
- package/src/types/properties.ts +2 -2
- package/src/util/builders.ts +5 -3
|
@@ -26,5 +26,5 @@ import { CMSType, PropertyFieldBindingProps } from "../types";
|
|
|
26
26
|
* @group Form custom fields
|
|
27
27
|
*/
|
|
28
28
|
export declare const PropertyFieldBinding: typeof PropertyFieldBindingInternal;
|
|
29
|
-
declare function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Record<string, any> =
|
|
29
|
+
declare function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Record<string, any> = any>({ propertyKey, property, context, includeDescription, underlyingValueHasChanged, disabled: disabledProp, partOfArray, minimalistView, autoFocus, index, size, onPropertyChange }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>>;
|
|
30
30
|
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { forwardRef, useState, useRef, useEffect, useContext, useCallback, useMemo, createRef, createContext, useLayoutEffect, useDeferredValue, createElement } from "react";
|
|
5
|
-
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, IconButton, InfoIcon, Typography, ContentCopyIcon, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, ErrorIcon, cls, defaultBorderMixin, OpenInNewIcon, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, Skeleton, paperMixin, EditIcon, KeyboardTabIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, Checkbox, Chip, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, DeleteIcon, AddIcon, ExpandablePanel, Markdown, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Collapse, Container, NotesIcon,
|
|
5
|
+
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, IconButton, InfoIcon, Typography, ContentCopyIcon, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, ErrorIcon, cls, defaultBorderMixin, OpenInNewIcon, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, Skeleton, paperMixin, EditIcon, KeyboardTabIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, Checkbox, Chip, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, DeleteIcon, AddIcon, ExpandablePanel, Markdown, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Collapse, Container, NotesIcon, Alert, Tab, Tabs, LoadingButton, CheckIcon, FilterListOffIcon, SearchIcon, Avatar, DarkModeIcon, LightModeIcon, LogoutIcon, HandleIcon, RemoveIcon, KeyboardArrowUpIcon, KeyboardArrowDownIcon, debounce, DescriptionIcon, fieldBackgroundMixin, fieldBackgroundHoverMixin, fieldBackgroundDisabledMixin, ArrowDropDownIcon, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, MailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Sheet, OpenInFullIcon, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
|
|
6
6
|
import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
|
|
7
7
|
import hash from "object-hash";
|
|
8
8
|
import { useFormex, setIn, getIn, useCreateFormex, Formex, Field } from "@firecms/formex";
|
|
@@ -11521,6 +11521,61 @@ function EntityEditView(t0) {
|
|
|
11521
11521
|
}
|
|
11522
11522
|
return t4;
|
|
11523
11523
|
}
|
|
11524
|
+
function FormLayout(t0) {
|
|
11525
|
+
const $ = c(12);
|
|
11526
|
+
const {
|
|
11527
|
+
id,
|
|
11528
|
+
formex,
|
|
11529
|
+
children,
|
|
11530
|
+
className
|
|
11531
|
+
} = t0;
|
|
11532
|
+
let t1;
|
|
11533
|
+
if ($[0] !== className) {
|
|
11534
|
+
t1 = cls("relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-5xl w-full h-fit", className);
|
|
11535
|
+
$[0] = className;
|
|
11536
|
+
$[1] = t1;
|
|
11537
|
+
} else {
|
|
11538
|
+
t1 = $[1];
|
|
11539
|
+
}
|
|
11540
|
+
let t2;
|
|
11541
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
11542
|
+
t2 = cls("flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10");
|
|
11543
|
+
$[2] = t2;
|
|
11544
|
+
} else {
|
|
11545
|
+
t2 = $[2];
|
|
11546
|
+
}
|
|
11547
|
+
let t3;
|
|
11548
|
+
if ($[3] !== formex.dirty) {
|
|
11549
|
+
t3 = formex.dirty ? /* @__PURE__ */ jsx(Tooltip, { title: "Unsaved changes", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsx(Chip, { size: "small", colorScheme: "orangeDarker", children: /* @__PURE__ */ jsx(EditIcon, { size: "smallest" }) }) }) : /* @__PURE__ */ jsx(Tooltip, { title: "In sync with the database", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsx(Chip, { size: "small", children: /* @__PURE__ */ jsx(CheckIcon, { size: "smallest" }) }) });
|
|
11550
|
+
$[3] = formex.dirty;
|
|
11551
|
+
$[4] = t3;
|
|
11552
|
+
} else {
|
|
11553
|
+
t3 = $[4];
|
|
11554
|
+
}
|
|
11555
|
+
let t4;
|
|
11556
|
+
if ($[5] !== children || $[6] !== t3) {
|
|
11557
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: t2, children: [
|
|
11558
|
+
t3,
|
|
11559
|
+
children
|
|
11560
|
+
] });
|
|
11561
|
+
$[5] = children;
|
|
11562
|
+
$[6] = t3;
|
|
11563
|
+
$[7] = t4;
|
|
11564
|
+
} else {
|
|
11565
|
+
t4 = $[7];
|
|
11566
|
+
}
|
|
11567
|
+
let t5;
|
|
11568
|
+
if ($[8] !== id || $[9] !== t1 || $[10] !== t4) {
|
|
11569
|
+
t5 = /* @__PURE__ */ jsx("div", { role: "tabpanel", id, className: t1, children: t4 });
|
|
11570
|
+
$[8] = id;
|
|
11571
|
+
$[9] = t1;
|
|
11572
|
+
$[10] = t4;
|
|
11573
|
+
$[11] = t5;
|
|
11574
|
+
} else {
|
|
11575
|
+
t5 = $[11];
|
|
11576
|
+
}
|
|
11577
|
+
return t5;
|
|
11578
|
+
}
|
|
11524
11579
|
function EntityEditViewInner({
|
|
11525
11580
|
path,
|
|
11526
11581
|
entityId: entityIdProp,
|
|
@@ -11810,24 +11865,32 @@ function EntityEditViewInner({
|
|
|
11810
11865
|
const resolvedEntityViews = customViews ? customViews.map((e_4) => resolveEntityView(e_4, customizationController.entityViews)).filter(Boolean) : [];
|
|
11811
11866
|
const selectedEntityView = resolvedEntityViews.find((e_5) => e_5.key === selectedTab);
|
|
11812
11867
|
const shouldShowEntityActions = !autoSave && (selectedTab === MAIN_TAB_VALUE || selectedEntityView?.includeActions);
|
|
11813
|
-
const
|
|
11868
|
+
const secondaryForms = customViews && resolvedEntityViews.filter((e_6) => e_6.includeActions).map((customView, colIndex) => {
|
|
11814
11869
|
if (!customView) return null;
|
|
11815
11870
|
const Builder = customView.Builder;
|
|
11816
11871
|
if (!Builder) {
|
|
11817
11872
|
console.error("customView.Builder is not defined");
|
|
11818
11873
|
return null;
|
|
11819
11874
|
}
|
|
11875
|
+
return /* @__PURE__ */ jsx(FormLayout, { className: selectedTab !== customView.key ? "hidden" : "", formex, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(Builder, { collection, entity: usedEntity, modifiedValues: formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
|
|
11876
|
+
}).filter(Boolean);
|
|
11877
|
+
const customViewsView = customViews && resolvedEntityViews.filter((e_7) => !e_7.includeActions).map((customView_0, colIndex_0) => {
|
|
11878
|
+
if (!customView_0) return null;
|
|
11879
|
+
const Builder_0 = customView_0.Builder;
|
|
11880
|
+
if (!Builder_0) {
|
|
11881
|
+
console.error("customView.Builder is not defined");
|
|
11882
|
+
return null;
|
|
11883
|
+
}
|
|
11820
11884
|
return /* @__PURE__ */ jsx("div", { className: cls(defaultBorderMixin, "relative flex-grow w-full h-full overflow-auto", {
|
|
11821
|
-
"hidden": selectedTab !==
|
|
11822
|
-
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(
|
|
11885
|
+
"hidden": selectedTab !== customView_0.key
|
|
11886
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(Builder_0, { collection, entity: usedEntity, modifiedValues: formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView_0.key}`);
|
|
11823
11887
|
}).filter(Boolean);
|
|
11824
11888
|
const globalLoading = dataLoading && !usedEntity || (!usedEntity || readOnly === void 0) && (status === "existing" || status === "copy");
|
|
11825
|
-
const subCollectionsViews = subcollections && subcollections.map((subcollection,
|
|
11889
|
+
const subCollectionsViews = subcollections && subcollections.map((subcollection, colIndex_1) => {
|
|
11826
11890
|
const subcollectionId = subcollection.id ?? subcollection.path;
|
|
11827
11891
|
const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
}), role: "tabpanel", children: [
|
|
11892
|
+
if (selectedTab !== subcollectionId) return null;
|
|
11893
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex-grow h-full overflow-auto w-full", role: "tabpanel", children: [
|
|
11831
11894
|
globalLoading || saving && /* @__PURE__ */ jsx(CircularProgressCenter, {}),
|
|
11832
11895
|
!globalLoading && (usedEntity && fullPath ? /* @__PURE__ */ jsx(EntityCollectionView, { fullPath, parentCollectionIds: [...parentCollectionIds, collection.id], isSubCollection: true, updateUrl: false, ...subcollection, openEntityMode: layout }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-full h-full p-3", children: /* @__PURE__ */ jsx(Typography, { variant: "label", children: "You need to save your entity before adding additional collections" }) }))
|
|
11833
11896
|
] }, `subcol_${subcollectionId}`);
|
|
@@ -11888,9 +11951,9 @@ function EntityEditViewInner({
|
|
|
11888
11951
|
context
|
|
11889
11952
|
});
|
|
11890
11953
|
setEntityId(updatedId);
|
|
11891
|
-
} catch (
|
|
11892
|
-
onIdUpdateError?.(
|
|
11893
|
-
console.error(
|
|
11954
|
+
} catch (e_8) {
|
|
11955
|
+
onIdUpdateError?.(e_8);
|
|
11956
|
+
console.error(e_8);
|
|
11894
11957
|
}
|
|
11895
11958
|
setCustomIdLoading(false);
|
|
11896
11959
|
}
|
|
@@ -11964,11 +12027,11 @@ function EntityEditViewInner({
|
|
|
11964
12027
|
}
|
|
11965
12028
|
const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_1);
|
|
11966
12029
|
if (additionalField && entity) {
|
|
11967
|
-
const
|
|
11968
|
-
if (!
|
|
12030
|
+
const Builder_1 = additionalField.Builder;
|
|
12031
|
+
if (!Builder_1 && !additionalField.value) {
|
|
11969
12032
|
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
11970
12033
|
}
|
|
11971
|
-
const child =
|
|
12034
|
+
const child = Builder_1 ? /* @__PURE__ */ jsx(Builder_1, { entity, context }) : /* @__PURE__ */ jsx(Fragment, { children: additionalField.value?.({
|
|
11972
12035
|
entity,
|
|
11973
12036
|
context
|
|
11974
12037
|
})?.toString() });
|
|
@@ -12015,8 +12078,7 @@ function EntityEditViewInner({
|
|
|
12015
12078
|
pluginActions,
|
|
12016
12079
|
layout
|
|
12017
12080
|
});
|
|
12018
|
-
const entityView = readOnly === void 0 ? /* @__PURE__ */ jsx(Fragment, {}) : !readOnly ? /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(
|
|
12019
|
-
formex.dirty ? /* @__PURE__ */ jsx(Tooltip, { title: "Unsaved changes", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsx(Chip, { size: "small", colorScheme: "orangeDarker", children: /* @__PURE__ */ jsx(EditIcon, { size: "smallest" }) }) }) : /* @__PURE__ */ jsx(Tooltip, { title: "In sync with the database", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsx(Chip, { size: "small", children: /* @__PURE__ */ jsx(CheckIcon, { size: "smallest" }) }) }),
|
|
12081
|
+
const entityView = readOnly === void 0 ? /* @__PURE__ */ jsx(Fragment, {}) : !readOnly ? /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12020
12082
|
/* @__PURE__ */ jsxs("div", { className: "w-full py-2 flex flex-col items-start mt-4 lg:mt-8 mb-8", children: [
|
|
12021
12083
|
/* @__PURE__ */ jsx(Typography, { className: "mt-4 flex-grow line-clamp-1 " + inputCollection.hideIdFromForm ? "mb-2" : "mb-0", variant: "h4", children: title ?? inputCollection.singularName ?? inputCollection.name }),
|
|
12022
12084
|
/* @__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: [
|
|
@@ -12026,13 +12088,11 @@ function EntityEditViewInner({
|
|
|
12026
12088
|
] }) })
|
|
12027
12089
|
] }),
|
|
12028
12090
|
!collection.hideIdFromForm && /* @__PURE__ */ jsx(CustomIdField, { customId: inputCollection.customId, entityId, status, onChange: setEntityId, error: entityIdError, loading: customIdLoading, entity }),
|
|
12029
|
-
entityId && formContext && /* @__PURE__ */
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
actionsAtTheBottom && /* @__PURE__ */ jsx("div", { className: "h-16" })
|
|
12035
|
-
] })
|
|
12091
|
+
entityId && formContext && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "mt-12 flex flex-col gap-8", ref: formRef, children: [
|
|
12092
|
+
formFields,
|
|
12093
|
+
/* @__PURE__ */ jsx(ErrorFocus, { containerRef: formRef })
|
|
12094
|
+
] }) }),
|
|
12095
|
+
actionsAtTheBottom && /* @__PURE__ */ jsx("div", { className: "h-16" })
|
|
12036
12096
|
] }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12037
12097
|
/* @__PURE__ */ jsx(Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
|
|
12038
12098
|
/* @__PURE__ */ jsx(EntityView, { className: "px-12", entity: usedEntity, path, collection })
|
|
@@ -12063,13 +12123,12 @@ function EntityEditViewInner({
|
|
|
12063
12123
|
});
|
|
12064
12124
|
return onDiscard();
|
|
12065
12125
|
}, noValidate: true, className: "flex-1 flex flex-row w-full overflow-y-auto justify-center", children: [
|
|
12066
|
-
/* @__PURE__ */ jsx(
|
|
12067
|
-
|
|
12068
|
-
}), children: globalLoading ? /* @__PURE__ */ jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsx(CircularProgressCenter, {}) }) : entityView }),
|
|
12069
|
-
customViewsView,
|
|
12070
|
-
subCollectionsViews,
|
|
12126
|
+
/* @__PURE__ */ jsx(FormLayout, { className: !mainViewVisible ? "hidden" : "", id: `form_${path}`, formex, children: globalLoading ? /* @__PURE__ */ jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsx(CircularProgressCenter, {}) }) : entityView }),
|
|
12127
|
+
secondaryForms,
|
|
12071
12128
|
shouldShowEntityActions && dialogActions
|
|
12072
|
-
] })
|
|
12129
|
+
] }),
|
|
12130
|
+
customViewsView,
|
|
12131
|
+
subCollectionsViews
|
|
12073
12132
|
] });
|
|
12074
12133
|
if (plugins) {
|
|
12075
12134
|
plugins.forEach((plugin_0) => {
|
|
@@ -23023,10 +23082,10 @@ function EntityFullScreenRoute({
|
|
|
23023
23082
|
}
|
|
23024
23083
|
const lastCollectionEntry = navigationEntries.findLast((entry_1) => entry_1.type === "collection");
|
|
23025
23084
|
if (isNew && !lastCollectionEntry) {
|
|
23026
|
-
throw new Error("No collection found in the navigation");
|
|
23085
|
+
throw new Error("INTERNAL: No collection found in the navigation");
|
|
23027
23086
|
}
|
|
23028
23087
|
if (!isNew && !lastEntityEntry) {
|
|
23029
|
-
|
|
23088
|
+
return /* @__PURE__ */ jsx(NotFoundPage, {});
|
|
23030
23089
|
}
|
|
23031
23090
|
const collection = isNew ? lastCollectionEntry.collection : lastEntityEntry.parentCollection;
|
|
23032
23091
|
const collectionPath = navigation.resolveIdsFrom(isNew ? lastCollectionEntry.path : lastEntityEntry.path);
|