@firecms/core 3.0.0-canary.215 → 3.0.0-canary.217

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
@@ -206,7 +206,7 @@
206
206
  function isObject(item) {
207
207
  return item && typeof item === "object" && !Array.isArray(item);
208
208
  }
209
- function mergeDeep(target, source) {
209
+ function mergeDeep(target, source, ignoreUndefined = false) {
210
210
  const targetIsObject = isObject(target);
211
211
  const output = targetIsObject ? {
212
212
  ...target
@@ -214,6 +214,9 @@
214
214
  if (targetIsObject && isObject(source)) {
215
215
  Object.keys(source).forEach((key) => {
216
216
  const sourceElement = source[key];
217
+ if (ignoreUndefined && sourceElement === void 0) {
218
+ return;
219
+ }
217
220
  if (sourceElement instanceof Date) {
218
221
  Object.assign(output, {
219
222
  [key]: new Date(sourceElement.getTime())
@@ -856,8 +859,8 @@
856
859
  return entityView;
857
860
  }
858
861
  }
859
- function resolvedSelectedEntityView(customViews, customizationController, selectedTab) {
860
- const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter(Boolean) : [];
862
+ function resolvedSelectedEntityView(customViews, customizationController, selectedTab, canEdit) {
863
+ const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter((e) => Boolean(e)).filter((e) => canEdit || !e.includeActions) : [];
861
864
  const selectedEntityView = resolvedEntityViews.find((e) => e.key === selectedTab);
862
865
  const selectedSecondaryForm = customViews && resolvedEntityViews.filter((e) => e.includeActions).find((e) => e.key === selectedTab);
863
866
  return {
@@ -3499,7 +3502,7 @@
3499
3502
  if (property) propertiesMerged[key] = mergePropertyOrBuilder(property, source.properties[key]);
3500
3503
  else propertiesMerged[key] = source.properties[key];
3501
3504
  });
3502
- const mergedCollection = mergeDeep(target, source);
3505
+ const mergedCollection = mergeDeep(target, source, true);
3503
3506
  const targetPropertiesOrder = getCollectionKeys(target);
3504
3507
  const sourcePropertiesOrder = getCollectionKeys(source);
3505
3508
  const mergedPropertiesOrder = [.../* @__PURE__ */ new Set([...sourcePropertiesOrder, ...targetPropertiesOrder])];
@@ -7444,6 +7447,7 @@
7444
7447
  const storage = property.dataType === "string" ? property.storage : property.dataType === "array" && property.of.dataType === "string" ? property.of.storage : void 0;
7445
7448
  const multipleFilesSupported = property.dataType === "array";
7446
7449
  if (!storage) throw Error("Storage meta must be specified");
7450
+ const processFile = storage?.processFile;
7447
7451
  const metadata = storage?.metadata;
7448
7452
  const size = multipleFilesSupported ? "medium" : "large";
7449
7453
  const compression = storage?.imageCompression;
@@ -7520,29 +7524,42 @@
7520
7524
  }, [internalValue, multipleFilesSupported, onChange, storage, storageSource]);
7521
7525
  const onFilesAdded = React.useCallback(async (acceptedFiles) => {
7522
7526
  if (!acceptedFiles.length || disabled) return;
7527
+ if (processFile) {
7528
+ try {
7529
+ acceptedFiles = await Promise.all(acceptedFiles.map(async (file_1) => {
7530
+ const processedFile = await processFile(file_1);
7531
+ if (!processedFile) {
7532
+ return file_1;
7533
+ }
7534
+ return processedFile;
7535
+ }));
7536
+ } catch (e_1) {
7537
+ console.error("Error processing file with custom code. Attempting to continue uploading.", e_1);
7538
+ }
7539
+ }
7523
7540
  let newInternalValue;
7524
7541
  if (multipleFilesSupported) {
7525
- newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (file_1) => {
7526
- if (compression && compressionFormat(file_1)) {
7527
- file_1 = await resizeAndCompressImage(file_1, compression);
7542
+ newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (file_2) => {
7543
+ if (compression && compressionFormat(file_2)) {
7544
+ file_2 = await resizeAndCompressImage(file_2, compression);
7528
7545
  }
7529
7546
  return {
7530
7547
  id: getRandomId$2(),
7531
- file: file_1,
7532
- fileName: await fileNameBuilder(file_1),
7548
+ file: file_2,
7549
+ fileName: await fileNameBuilder(file_2),
7533
7550
  metadata,
7534
7551
  size
7535
7552
  };
7536
7553
  }))];
7537
7554
  } else {
7538
- let file_2 = acceptedFiles[0];
7539
- if (compression && compressionFormat(file_2)) {
7540
- file_2 = await resizeAndCompressImage(file_2, compression);
7555
+ let file_3 = acceptedFiles[0];
7556
+ if (compression && compressionFormat(file_3)) {
7557
+ file_3 = await resizeAndCompressImage(file_3, compression);
7541
7558
  }
7542
7559
  newInternalValue = [{
7543
7560
  id: getRandomId$2(),
7544
- file: file_2,
7545
- fileName: await fileNameBuilder(file_2),
7561
+ file: file_3,
7562
+ fileName: await fileNameBuilder(file_3),
7546
7563
  metadata,
7547
7564
  size
7548
7565
  }];
@@ -9387,7 +9404,7 @@
9387
9404
  ] }, index_0)) }),
9388
9405
  selectionEnabled && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { size: largeLayout ? "medium" : "small", checked: Boolean(isSelected), onCheckedChange }) })
9389
9406
  ] }),
9390
- !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center flex items-center gap-1", onClick: (event_1) => {
9407
+ !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center justify-center flex items-center gap-1", onClick: (event_1) => {
9391
9408
  event_1.stopPropagation();
9392
9409
  }, children: [
9393
9410
  hasDraft && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local unsaved changes", className: "inline", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { colorScheme: "orangeDarker", className: "p-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: 12 }) }) }),
@@ -14311,11 +14328,11 @@
14311
14328
  throw Error("INTERNAL: Collection and path must be defined in form context");
14312
14329
  }
14313
14330
  const dialogActions = /* @__PURE__ */ jsxRuntime.jsx(EntityFormActionsComponent, { collection: resolvedCollection, path, entity, layout: forceActionsAtTheBottom ? "bottom" : "side", savingError, formex: formex$1, disabled: disabled_0, status, pluginActions, openEntityMode, showDefaultActions });
14314
- return /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formContext.formex, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: formContext.formex.handleSubmit, onReset: () => formex$1.resetForm({
14331
+ return /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: formex$1.handleSubmit, onReset: () => formex$1.resetForm({
14315
14332
  values: getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs)
14316
14333
  }), noValidate: true, className: ui.cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", className), children: [
14317
14334
  /* @__PURE__ */ jsxRuntime.jsx("div", { id: `form_${path}`, className: ui.cls("relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10"), children: [
14318
- formContext.formex.dirty ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local 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" }) }) }),
14335
+ formex$1.dirty ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local 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" }) }) }),
14319
14336
  formView
14320
14337
  ] }) }),
14321
14338
  dialogActions
@@ -21098,7 +21115,7 @@
21098
21115
  t4 = $[4];
21099
21116
  }
21100
21117
  React.useEffect(t3, t4);
21101
- const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.vsLight;
21118
+ const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.github;
21102
21119
  let t6;
21103
21120
  if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
21104
21121
  t6 = (t72) => {
@@ -21110,8 +21127,8 @@
21110
21127
  } = t72;
21111
21128
  return /* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, style: {
21112
21129
  ...style,
21113
- background: "inherit"
21114
- }, className: "container mx-auto p-8 rounded text-sm", children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...getLineProps({
21130
+ backgroundColor: "inherit"
21131
+ }, className: "max-w-6xl mx-auto p-8 rounded text-sm", children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...getLineProps({
21115
21132
  line
21116
21133
  }), className: "text-wrap", children: line.map((token, key) => /* @__PURE__ */ jsxRuntime.jsx("span", { ...getTokenProps({
21117
21134
  token
@@ -21132,128 +21149,100 @@
21132
21149
  }
21133
21150
  return t7;
21134
21151
  }
21152
+ function createFormexStub(values) {
21153
+ const errorMessage = "You are in a read-only context. You cannot modify the formex controller.";
21154
+ return {
21155
+ values,
21156
+ initialValues: values,
21157
+ touched: {},
21158
+ dirty: false,
21159
+ errors: {},
21160
+ submitCount: 0,
21161
+ isSubmitting: false,
21162
+ isValidating: false,
21163
+ version: 0,
21164
+ canUndo: false,
21165
+ canRedo: false,
21166
+ setValues: () => {
21167
+ throw new Error(errorMessage);
21168
+ },
21169
+ setFieldValue: () => {
21170
+ throw new Error(errorMessage);
21171
+ },
21172
+ setFieldTouched: () => {
21173
+ throw new Error(errorMessage);
21174
+ },
21175
+ setDirty: () => {
21176
+ throw new Error(errorMessage);
21177
+ },
21178
+ setSubmitCount: () => {
21179
+ throw new Error(errorMessage);
21180
+ },
21181
+ setFieldError: () => {
21182
+ throw new Error(errorMessage);
21183
+ },
21184
+ handleChange: () => {
21185
+ throw new Error(errorMessage);
21186
+ },
21187
+ handleBlur: () => {
21188
+ throw new Error(errorMessage);
21189
+ },
21190
+ handleSubmit: () => {
21191
+ throw new Error(errorMessage);
21192
+ },
21193
+ validate: () => {
21194
+ throw new Error(errorMessage);
21195
+ },
21196
+ resetForm: () => {
21197
+ throw new Error(errorMessage);
21198
+ },
21199
+ setSubmitting: () => {
21200
+ throw new Error(errorMessage);
21201
+ },
21202
+ undo: () => {
21203
+ throw new Error(errorMessage);
21204
+ },
21205
+ redo: () => {
21206
+ throw new Error(errorMessage);
21207
+ }
21208
+ };
21209
+ }
21135
21210
  const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
21136
21211
  const JSON_TAB_VALUE = "__json";
21137
- function EntityEditView(t0) {
21138
- const $ = reactCompilerRuntime.c(28);
21139
- let entityId;
21140
- let props;
21141
- if ($[0] !== t0) {
21142
- ({
21143
- entityId,
21144
- ...props
21145
- } = t0);
21146
- $[0] = t0;
21147
- $[1] = entityId;
21148
- $[2] = props;
21149
- } else {
21150
- entityId = $[1];
21151
- props = $[2];
21152
- }
21153
- let t1;
21154
- if ($[3] !== entityId || $[4] !== props.collection || $[5] !== props.databaseId || $[6] !== props.path) {
21155
- t1 = {
21156
- path: props.path,
21157
- entityId,
21158
- collection: props.collection,
21159
- databaseId: props.databaseId,
21160
- useCache: false
21161
- };
21162
- $[3] = entityId;
21163
- $[4] = props.collection;
21164
- $[5] = props.databaseId;
21165
- $[6] = props.path;
21166
- $[7] = t1;
21167
- } else {
21168
- t1 = $[7];
21169
- }
21212
+ function EntityEditView({
21213
+ entityId,
21214
+ ...props
21215
+ }) {
21170
21216
  const {
21171
21217
  entity,
21172
- dataLoading
21173
- } = useEntityFetch(t1);
21174
- let t2;
21175
- if ($[8] !== entityId || $[9] !== props.path) {
21176
- t2 = entityId ? getEntityFromCache(props.path + "/" + entityId) : getEntityFromCache(props.path + "#new");
21177
- $[8] = entityId;
21178
- $[9] = props.path;
21179
- $[10] = t2;
21180
- } else {
21181
- t2 = $[10];
21182
- }
21183
- const cachedValues = t2;
21218
+ dataLoading,
21219
+ // eslint-disable-next-line no-unused-vars
21220
+ dataLoadingError
21221
+ } = useEntityFetch({
21222
+ path: props.path,
21223
+ entityId,
21224
+ collection: props.collection,
21225
+ databaseId: props.databaseId,
21226
+ useCache: false
21227
+ });
21228
+ const cachedValues = entityId ? getEntityFromCache(props.path + "/" + entityId) : getEntityFromCache(props.path + "#new");
21184
21229
  const authController = useAuthController();
21185
21230
  const initialStatus = props.copy ? "copy" : entityId ? "existing" : "new";
21186
21231
  const [status, setStatus] = React.useState(initialStatus);
21187
- let t3;
21188
- if (status === "new" || status === "copy") {
21189
- t3 = true;
21190
- } else {
21191
- t3 = entity ? canEditEntity(props.collection, authController, props.path, entity ?? null) : void 0;
21192
- }
21193
- const canEdit = t3;
21194
- if (dataLoading && !cachedValues || (!entity || canEdit === void 0) && (status === "existing" || status === "copy")) {
21195
- let t42;
21196
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
21197
- t42 = /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {});
21198
- $[11] = t42;
21232
+ const canEdit = React.useMemo(() => {
21233
+ if (status === "new" || status === "copy") {
21234
+ return true;
21199
21235
  } else {
21200
- t42 = $[11];
21236
+ return entity ? canEditEntity(props.collection, authController, props.path, entity ?? null) : void 0;
21201
21237
  }
21202
- return t42;
21238
+ }, [authController, entity, status]);
21239
+ if (dataLoading && !cachedValues || (!entity || canEdit === void 0) && (status === "existing" || status === "copy")) {
21240
+ return /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {});
21203
21241
  }
21204
21242
  if (entityId && !entity && !cachedValues) {
21205
21243
  console.error(`Entity with id ${entityId} not found in collection ${props.path}`);
21206
21244
  }
21207
- if (!canEdit) {
21208
- const t42 = props.collection.singularName ?? props.collection.name;
21209
- let t52;
21210
- if ($[12] !== t42) {
21211
- t52 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: t42 });
21212
- $[12] = t42;
21213
- $[13] = t52;
21214
- } else {
21215
- t52 = $[13];
21216
- }
21217
- const t6 = entity;
21218
- let t7;
21219
- if ($[14] !== props.collection || $[15] !== props.path || $[16] !== t6) {
21220
- t7 = /* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-8", entity: t6, path: props.path, collection: props.collection });
21221
- $[14] = props.collection;
21222
- $[15] = props.path;
21223
- $[16] = t6;
21224
- $[17] = t7;
21225
- } else {
21226
- t7 = $[17];
21227
- }
21228
- let t8;
21229
- if ($[18] !== t52 || $[19] !== t7) {
21230
- t8 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
21231
- t52,
21232
- t7
21233
- ] });
21234
- $[18] = t52;
21235
- $[19] = t7;
21236
- $[20] = t8;
21237
- } else {
21238
- t8 = $[20];
21239
- }
21240
- return t8;
21241
- }
21242
- const t4 = cachedValues;
21243
- let t5;
21244
- if ($[21] !== dataLoading || $[22] !== entity || $[23] !== entityId || $[24] !== props || $[25] !== status || $[26] !== t4) {
21245
- t5 = /* @__PURE__ */ jsxRuntime.jsx(EntityEditViewInner, { ...props, entityId, entity, cachedDirtyValues: t4, dataLoading, status, setStatus });
21246
- $[21] = dataLoading;
21247
- $[22] = entity;
21248
- $[23] = entityId;
21249
- $[24] = props;
21250
- $[25] = status;
21251
- $[26] = t4;
21252
- $[27] = t5;
21253
- } else {
21254
- t5 = $[27];
21255
- }
21256
- return t5;
21245
+ return /* @__PURE__ */ jsxRuntime.jsx(EntityEditViewInner, { ...props, entityId, entity, cachedDirtyValues: cachedValues, dataLoading, status, setStatus, canEdit });
21257
21246
  }
21258
21247
  function EntityEditViewInner({
21259
21248
  path,
@@ -21271,7 +21260,8 @@
21271
21260
  barActions,
21272
21261
  status,
21273
21262
  setStatus,
21274
- formProps
21263
+ formProps,
21264
+ canEdit
21275
21265
  }) {
21276
21266
  const context = useFireCMSContext();
21277
21267
  const [usedEntity, setUsedEntity] = React.useState(entity);
@@ -21287,8 +21277,8 @@
21287
21277
  }), []);
21288
21278
  const [selectedTab, setSelectedTab] = React.useState(selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);
21289
21279
  React.useEffect(() => {
21290
- if ((selectedTabProp ?? MAIN_TAB_VALUE) !== selectedTab) {
21291
- setSelectedTab(selectedTabProp ?? MAIN_TAB_VALUE);
21280
+ if ((selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE) !== selectedTab) {
21281
+ setSelectedTab(selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);
21292
21282
  }
21293
21283
  }, [selectedTabProp]);
21294
21284
  const subcollections = (collection.subcollections ?? []).filter((c) => !c.hideFromNavigation);
@@ -21301,24 +21291,55 @@
21301
21291
  resolvedEntityViews,
21302
21292
  selectedEntityView,
21303
21293
  selectedSecondaryForm
21304
- } = resolvedSelectedEntityView(customViews, customizationController, selectedTab);
21294
+ } = resolvedSelectedEntityView(customViews, customizationController, selectedTab, canEdit);
21305
21295
  const actionsAtTheBottom = !largeLayout || layout === "side_panel" || selectedEntityView?.includeActions === "bottom";
21306
21296
  const mainViewVisible = selectedTab === MAIN_TAB_VALUE || Boolean(selectedSecondaryForm);
21297
+ const authController = useAuthController();
21307
21298
  const customViewsView = customViews && resolvedEntityViews.filter((e) => !e.includeActions).map((customView) => {
21308
21299
  if (!customView) return null;
21309
21300
  const Builder = customView.Builder;
21310
21301
  if (!Builder) {
21311
- console.error("customView.Builder is not defined");
21302
+ console.error("INTERNAL: customView.Builder is not defined");
21303
+ return null;
21304
+ }
21305
+ if (!entityId) {
21306
+ console.error("INTERNAL: entityId is not defined");
21312
21307
  return null;
21313
21308
  }
21309
+ const formexStub = createFormexStub(usedEntity?.values ?? {});
21310
+ const usedFormContext = formContext ?? {
21311
+ entityId,
21312
+ openEntityMode: layout,
21313
+ status,
21314
+ values: usedEntity?.values ?? {},
21315
+ setFieldValue: (key, value) => {
21316
+ throw new Error("You can't update values in read only mode");
21317
+ },
21318
+ save: () => {
21319
+ throw new Error("You can't save in read only mode");
21320
+ },
21321
+ collection: resolveCollection({
21322
+ collection,
21323
+ path,
21324
+ entityId,
21325
+ values: usedEntity?.values ?? {},
21326
+ previousValues: usedEntity?.values ?? {},
21327
+ propertyConfigs: customizationController.propertyConfigs,
21328
+ authController
21329
+ }),
21330
+ path,
21331
+ entity: usedEntity,
21332
+ savingError: void 0,
21333
+ formex: formexStub
21334
+ };
21314
21335
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
21315
21336
  "hidden": selectedTab !== customView.key
21316
- }), 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}`);
21337
+ }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
21317
21338
  }).filter(Boolean);
21318
21339
  const globalLoading = dataLoading && !usedEntity;
21319
21340
  const jsonView = /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("relative flex-1 h-full overflow-auto w-full", {
21320
21341
  "hidden": selectedTab !== JSON_TAB_VALUE
21321
- }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityJsonPreview, { values: formContext?.values ?? {} }) }) }, "json_view");
21342
+ }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityJsonPreview, { values: formContext?.values ?? entity?.values ?? {} }) }) }, "json_view");
21322
21343
  const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
21323
21344
  const subcollectionId = subcollection.id ?? subcollection.path;
21324
21345
  const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
@@ -21328,18 +21349,21 @@
21328
21349
  !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" }) }))
21329
21350
  ] }, `subcol_${subcollectionId}`);
21330
21351
  }).filter(Boolean);
21331
- const onSideTabClick = (value) => {
21332
- setSelectedTab(value);
21352
+ const onSideTabClick = (value_0) => {
21353
+ setSelectedTab(value_0);
21333
21354
  if (status === "existing") {
21334
21355
  onTabChange?.({
21335
21356
  path,
21336
21357
  entityId,
21337
- selectedTab: value === MAIN_TAB_VALUE ? void 0 : value,
21358
+ selectedTab: value_0 === MAIN_TAB_VALUE ? void 0 : value_0,
21338
21359
  collection
21339
21360
  });
21340
21361
  }
21341
21362
  };
21342
- const entityView = /* @__PURE__ */ jsxRuntime.jsx(EntityForm, { collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues: cachedDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: ui.cls(!mainViewVisible ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, ...formProps, onEntityChange: (entity_0) => {
21363
+ const entityView = !canEdit ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", !mainViewVisible ? "hidden" : ""), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("relative flex flex-col max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit"), children: [
21364
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
21365
+ /* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection })
21366
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(EntityForm, { collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues: cachedDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: ui.cls(!mainViewVisible ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, ...formProps, onEntityChange: (entity_0) => {
21343
21367
  setUsedEntity(entity_0);
21344
21368
  formProps?.onEntityChange?.(entity_0);
21345
21369
  }, onStatusChange: (status_0) => {
@@ -21363,8 +21387,8 @@
21363
21387
  barActions,
21364
21388
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow" }),
21365
21389
  globalLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "self-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CircularProgress, { size: "small" }) }),
21366
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_0) => {
21367
- onSideTabClick(value_0);
21390
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_1) => {
21391
+ onSideTabClick(value_1);
21368
21392
  }, children: [
21369
21393
  /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CodeIcon, { size: "small" }) }),
21370
21394
  /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
@@ -23239,7 +23263,6 @@
23239
23263
  return blocked.current;
23240
23264
  });
23241
23265
  } catch (e) {
23242
- console.warn("Blocker not available, navigation will not be blocked");
23243
23266
  }
23244
23267
  const lastCollectionEntry = navigationEntries.findLast((entry_1) => entry_1.type === "collection");
23245
23268
  if (isNew && !lastCollectionEntry) {