@firecms/core 3.0.0-canary.90 → 3.0.0-canary.91
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/components/common/useColumnsIds.d.ts +2 -1
- package/dist/index.es.js +78 -37
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +77 -36
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/core/EntityEditView.tsx +74 -45
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ResolvedEntityCollection, ResolvedProperty } from "../../types";
|
|
1
|
+
import { EntityCollection, ResolvedEntityCollection, ResolvedProperty } from "../../types";
|
|
2
2
|
import { PropertyColumnConfig } from "../EntityCollectionTable/EntityCollectionTableProps";
|
|
3
3
|
export declare function useColumnIds<M extends Record<string, any>>(collection: ResolvedEntityCollection<M>, includeSubcollections: boolean): PropertyColumnConfig[];
|
|
4
4
|
export declare function getColumnKeysForProperty(property: ResolvedProperty, key: string, disabled?: boolean): PropertyColumnConfig[];
|
|
5
|
+
export declare function getFormFieldKeys(collection: EntityCollection): string[];
|
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ import React__default, { useRef, useEffect, useContext, useCallback, useMemo, us
|
|
|
4
4
|
import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
|
|
5
5
|
import hash from "object-hash";
|
|
6
6
|
import { useCreateFormex, Formex, setIn, Field, getIn, useFormex } from "@firecms/formex";
|
|
7
|
-
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, ErrorIcon, Typography, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, IconButton, ContentCopyIcon, OpenInNewIcon, DescriptionIcon, cls, Skeleton, Chip, defaultBorderMixin, KeyboardTabIcon, Checkbox, Markdown, TextareaAutosize, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, paperMixin, ErrorOutlineIcon, EditIcon, Button, RemoveCircleIcon, Menu, MoreVertIcon, MenuItem, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, AssignmentIcon, CenteredView, Label, TextField, ClearIcon, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogContent, DialogActions, FileCopyIcon, ArchiveIcon, DeleteIcon, AddIcon, ExpandablePanel, Card, ArrowForwardIcon, cardMixin, cardClickableMixin, focusedMixin, StarIcon, StarBorderIcon, Collapse, Container, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, LogoutIcon, fieldBackgroundHoverMixin, HandleIcon, RemoveIcon, debounce, InfoIcon, CloseIcon, fieldBackgroundMixin, fieldBackgroundDisabledMixin, ArrowDropDownIcon, useInjectStyles, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, EmailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Tab, Tabs, Alert, Sheet, useLocaleConfig, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
|
|
7
|
+
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, ErrorIcon, Typography, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, IconButton, ContentCopyIcon, OpenInNewIcon, DescriptionIcon, cls, Skeleton, Chip, defaultBorderMixin, KeyboardTabIcon, Checkbox, Markdown, TextareaAutosize, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, paperMixin, ErrorOutlineIcon, EditIcon, Button, RemoveCircleIcon, Menu, MoreVertIcon, MenuItem, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, AssignmentIcon, CenteredView, Label, TextField, ClearIcon, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogContent, DialogActions, FileCopyIcon, ArchiveIcon, DeleteIcon, AddIcon, ExpandablePanel, Card, ArrowForwardIcon, cardMixin, cardClickableMixin, focusedMixin, StarIcon, StarBorderIcon, Collapse, Container, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, LogoutIcon, fieldBackgroundHoverMixin, HandleIcon, RemoveIcon, debounce, InfoIcon, CloseIcon, fieldBackgroundMixin, fieldBackgroundDisabledMixin, ArrowDropDownIcon, useInjectStyles, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, EmailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, NotesIcon, Tab, Tabs, Alert, Sheet, useLocaleConfig, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
|
|
8
8
|
import equal from "react-fast-compare";
|
|
9
9
|
import { Link, useNavigate, useLocation, UNSAFE_NavigationContext, NavLink, Route, Routes } from "react-router-dom";
|
|
10
10
|
import { format } from "date-fns";
|
|
@@ -8533,6 +8533,18 @@ function getColumnKeysForProperty(property, key, disabled) {
|
|
|
8533
8533
|
disabled: disabled || Boolean(property.disabled) || Boolean(property.readOnly)
|
|
8534
8534
|
}];
|
|
8535
8535
|
}
|
|
8536
|
+
function getFormFieldKeys(collection) {
|
|
8537
|
+
const propertyKeys = Object.keys(collection.properties);
|
|
8538
|
+
const additionalFields = collection.additionalFields ?? [];
|
|
8539
|
+
const allKeys = [
|
|
8540
|
+
...propertyKeys,
|
|
8541
|
+
...additionalFields.map((field) => field.key)
|
|
8542
|
+
];
|
|
8543
|
+
if (collection.propertiesOrder) {
|
|
8544
|
+
return collection.propertiesOrder.filter((key) => allKeys.includes(key));
|
|
8545
|
+
}
|
|
8546
|
+
return allKeys;
|
|
8547
|
+
}
|
|
8536
8548
|
function buildIdColumn(largeLayout) {
|
|
8537
8549
|
return {
|
|
8538
8550
|
key: "id_ewcfedcswdf3",
|
|
@@ -18161,46 +18173,74 @@ function EntityEditViewInner({
|
|
|
18161
18173
|
});
|
|
18162
18174
|
}
|
|
18163
18175
|
}, [formex.isSubmitting, autoSave, underlyingChanges, entity, formex.values, formex.touched, formex.setFieldValue]);
|
|
18164
|
-
const formFields = /* @__PURE__ */ jsx(Fragment, { children: (resolvedCollection
|
|
18176
|
+
const formFields = /* @__PURE__ */ jsx(Fragment, { children: getFormFieldKeys(resolvedCollection).map((key) => {
|
|
18165
18177
|
const property = resolvedCollection.properties[key];
|
|
18166
|
-
if (
|
|
18167
|
-
|
|
18168
|
-
|
|
18178
|
+
if (property) {
|
|
18179
|
+
const underlyingValueHasChanged = !!underlyingChanges && Object.keys(underlyingChanges).includes(key) && !!formex.touched[key];
|
|
18180
|
+
const disabled2 = !autoSave && formex.isSubmitting || isReadOnly(property) || Boolean(property.disabled);
|
|
18181
|
+
const hidden = isHidden(property);
|
|
18182
|
+
if (hidden) return null;
|
|
18183
|
+
const cmsFormFieldProps = {
|
|
18184
|
+
propertyKey: key,
|
|
18185
|
+
disabled: disabled2,
|
|
18186
|
+
property,
|
|
18187
|
+
includeDescription: property.description || property.longDescription,
|
|
18188
|
+
underlyingValueHasChanged: underlyingValueHasChanged && !autoSave,
|
|
18189
|
+
context: formContext,
|
|
18190
|
+
tableMode: false,
|
|
18191
|
+
partOfArray: false,
|
|
18192
|
+
partOfBlock: false,
|
|
18193
|
+
autoFocus: false
|
|
18194
|
+
};
|
|
18195
|
+
return /* @__PURE__ */ jsx(
|
|
18196
|
+
"div",
|
|
18197
|
+
{
|
|
18198
|
+
id: `form_field_${key}`,
|
|
18199
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(
|
|
18200
|
+
Tooltip,
|
|
18201
|
+
{
|
|
18202
|
+
title: /* @__PURE__ */ jsx(PropertyIdCopyTooltipContent, { propertyId: key }),
|
|
18203
|
+
delayDuration: 800,
|
|
18204
|
+
side: "left",
|
|
18205
|
+
align: "start",
|
|
18206
|
+
sideOffset: 16,
|
|
18207
|
+
children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...cmsFormFieldProps })
|
|
18208
|
+
}
|
|
18209
|
+
) })
|
|
18210
|
+
},
|
|
18211
|
+
`field_${resolvedCollection.name}_${key}`
|
|
18212
|
+
);
|
|
18169
18213
|
}
|
|
18170
|
-
const
|
|
18171
|
-
|
|
18172
|
-
|
|
18173
|
-
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
|
|
18177
|
-
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
18181
|
-
|
|
18182
|
-
|
|
18183
|
-
partOfBlock: false,
|
|
18184
|
-
autoFocus: false
|
|
18185
|
-
};
|
|
18186
|
-
return /* @__PURE__ */ jsx(
|
|
18187
|
-
"div",
|
|
18188
|
-
{
|
|
18189
|
-
id: `form_field_${key}`,
|
|
18190
|
-
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(
|
|
18191
|
-
Tooltip,
|
|
18214
|
+
const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key);
|
|
18215
|
+
if (additionalField && entity) {
|
|
18216
|
+
const Builder = additionalField.Builder;
|
|
18217
|
+
if (!Builder && !additionalField.value) {
|
|
18218
|
+
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
18219
|
+
}
|
|
18220
|
+
const child = Builder ? /* @__PURE__ */ jsx(Builder, { entity, context }) : /* @__PURE__ */ jsx(Fragment, { children: additionalField.value?.({
|
|
18221
|
+
entity,
|
|
18222
|
+
context
|
|
18223
|
+
}) });
|
|
18224
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
18225
|
+
/* @__PURE__ */ jsx(
|
|
18226
|
+
LabelWithIcon,
|
|
18192
18227
|
{
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
align: "start",
|
|
18197
|
-
sideOffset: 16,
|
|
18198
|
-
children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...cmsFormFieldProps })
|
|
18228
|
+
icon: /* @__PURE__ */ jsx(NotesIcon, { size: "small" }),
|
|
18229
|
+
title: additionalField.name,
|
|
18230
|
+
className: "text-text-secondary dark:text-text-secondary-dark ml-3.5"
|
|
18199
18231
|
}
|
|
18200
|
-
)
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
|
|
18232
|
+
),
|
|
18233
|
+
/* @__PURE__ */ jsx(
|
|
18234
|
+
"div",
|
|
18235
|
+
{
|
|
18236
|
+
className: cls(paperMixin, "min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar"),
|
|
18237
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: child })
|
|
18238
|
+
}
|
|
18239
|
+
)
|
|
18240
|
+
] });
|
|
18241
|
+
}
|
|
18242
|
+
console.warn(`Property ${key} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
|
|
18243
|
+
return null;
|
|
18204
18244
|
}).filter(Boolean) });
|
|
18205
18245
|
const disabled = formex.isSubmitting || !modified && status === "existing";
|
|
18206
18246
|
const formRef = React__default.useRef(null);
|
|
@@ -20110,6 +20150,7 @@ export {
|
|
|
20110
20150
|
getEntityTitlePropertyKey,
|
|
20111
20151
|
getFieldConfig,
|
|
20112
20152
|
getFieldId,
|
|
20153
|
+
getFormFieldKeys,
|
|
20113
20154
|
getHashValue,
|
|
20114
20155
|
getIcon,
|
|
20115
20156
|
getIconForProperty,
|