@firecms/core 3.0.0-beta.13 → 3.0.0-beta.14

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.
Files changed (71) hide show
  1. package/dist/components/ArrayContainer.d.ts +7 -12
  2. package/dist/components/EntityPreview.d.ts +4 -2
  3. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  4. package/dist/components/VirtualTable/VirtualTableProps.d.ts +0 -4
  5. package/dist/components/index.d.ts +1 -0
  6. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  7. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -9
  8. package/dist/hooks/useBuildNavigationController.d.ts +2 -9
  9. package/dist/index.es.js +1183 -705
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +1191 -716
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/collections.d.ts +20 -2
  14. package/dist/types/firecms.d.ts +2 -1
  15. package/dist/types/navigation.d.ts +5 -0
  16. package/dist/types/plugins.d.ts +12 -0
  17. package/dist/types/side_entity_controller.d.ts +4 -0
  18. package/dist/util/callbacks.d.ts +2 -0
  19. package/dist/util/index.d.ts +1 -0
  20. package/package.json +8 -6
  21. package/src/components/ArrayContainer.tsx +409 -294
  22. package/src/components/ClearFilterSortButton.tsx +1 -1
  23. package/src/components/ConfirmationDialog.tsx +9 -9
  24. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +1 -1
  25. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +1 -1
  26. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +13 -2
  27. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +53 -27
  28. package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +9 -9
  29. package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -0
  30. package/src/components/EntityPreview.tsx +18 -14
  31. package/src/components/ErrorView.tsx +1 -1
  32. package/src/components/HomePage/DefaultHomePage.tsx +2 -1
  33. package/src/components/HomePage/NavigationCardBinding.tsx +3 -1
  34. package/src/components/SelectableTable/SelectableTable.tsx +140 -143
  35. package/src/components/VirtualTable/VirtualTable.tsx +8 -30
  36. package/src/components/VirtualTable/VirtualTableProps.tsx +0 -5
  37. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +0 -1
  38. package/src/components/index.tsx +2 -0
  39. package/src/core/EntityEditView.tsx +26 -14
  40. package/src/core/EntitySidePanel.tsx +15 -20
  41. package/src/core/FireCMS.tsx +7 -1
  42. package/src/form/EntityForm.tsx +1 -1
  43. package/src/form/PropertyFieldBinding.tsx +0 -1
  44. package/src/form/components/CustomIdField.tsx +3 -1
  45. package/src/form/components/LabelWithIcon.tsx +1 -1
  46. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +3 -2
  47. package/src/form/field_bindings/MapFieldBinding.tsx +5 -4
  48. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +1 -1
  49. package/src/form/field_bindings/RepeatFieldBinding.tsx +1 -0
  50. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -1
  51. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +222 -154
  52. package/src/hooks/data/save.ts +0 -6
  53. package/src/hooks/useBuildNavigationController.tsx +30 -16
  54. package/src/internal/useBuildSideEntityController.tsx +1 -1
  55. package/src/preview/components/ImagePreview.tsx +2 -2
  56. package/src/preview/components/ReferencePreview.tsx +1 -1
  57. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  58. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  59. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +1 -1
  60. package/src/preview/property_previews/StringPropertyPreview.tsx +1 -1
  61. package/src/types/collections.ts +24 -2
  62. package/src/types/firecms.tsx +2 -2
  63. package/src/types/navigation.ts +6 -0
  64. package/src/types/plugins.tsx +16 -0
  65. package/src/types/side_entity_controller.tsx +5 -5
  66. package/src/util/callbacks.ts +119 -0
  67. package/src/util/index.ts +1 -0
  68. package/src/util/navigation_utils.ts +70 -55
  69. package/src/util/objects.ts +53 -20
  70. package/dist/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.d.ts +0 -5
  71. package/src/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.tsx +0 -59
package/dist/index.es.js CHANGED
@@ -14,7 +14,10 @@ import * as locales from "date-fns/locale";
14
14
  import useMeasure from "react-use-measure";
15
15
  import * as yup from "yup";
16
16
  import { FixedSizeList } from "react-window";
17
- import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
17
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from "@dnd-kit/core";
18
+ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
19
+ import { sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
20
+ import { CSS } from "@dnd-kit/utilities";
18
21
  import { useDropzone } from "react-dropzone";
19
22
  import Resizer from "react-image-file-resizer";
20
23
  import { FireCMSEditor } from "@firecms/editor";
@@ -68,49 +71,66 @@ function getLastSegment(path) {
68
71
  return cleanPath;
69
72
  }
70
73
  function resolveCollectionPathIds(path, allCollections) {
71
- const cleanPath = removeInitialAndTrailingSlashes(path);
72
- const subpaths = cleanPath.split("/");
73
- if (subpaths.length % 2 === 0) {
74
- throw Error(`resolveCollectionPathIds: Collection paths must have an odd number of segments: ${path}`);
75
- }
76
- const exactMatch = allCollections.find((col) => col.path === cleanPath);
77
- if (exactMatch) {
78
- return exactMatch.path;
79
- }
80
- if (subpaths.length === 1) {
81
- const aliasedCollection = allCollections.find((col) => col.id === subpaths[0]);
82
- return aliasedCollection?.path ?? subpaths[0];
83
- }
84
- let matchingCollection;
85
- let entityIndex = 1;
86
- for (const collection of allCollections) {
87
- const pathSegments = collection.path.split("/");
88
- if (pathSegments.length > 1 && subpaths.slice(0, pathSegments.length).join("/") === collection.path) {
89
- matchingCollection = collection;
90
- entityIndex = pathSegments.length;
74
+ let remainingPath = removeInitialAndTrailingSlashes(path);
75
+ if (!remainingPath) {
76
+ return "";
77
+ }
78
+ let currentCollections = allCollections;
79
+ const resolvedPathParts = [];
80
+ while (remainingPath.length > 0) {
81
+ if (!currentCollections || currentCollections.length === 0) {
82
+ console.warn(`resolveCollectionPathIds: Path structure implies subcollections, but none found before segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
83
+ resolvedPathParts.push(remainingPath);
84
+ remainingPath = "";
91
85
  break;
92
86
  }
93
- }
94
- if (!matchingCollection) {
95
- const matchingCollections = allCollections.filter((col) => col.id === subpaths[0] || col.path === subpaths[0]);
96
- if (!matchingCollections.length) {
97
- return cleanPath;
87
+ let foundMatch = false;
88
+ const potentialMatches = currentCollections.flatMap((col) => [{
89
+ col,
90
+ match: col.path
91
+ }, {
92
+ col,
93
+ match: col.id
94
+ }]).filter((p) => p.match && remainingPath.startsWith(p.match)).sort((a, b) => b.match.length - a.match.length);
95
+ if (potentialMatches.length > 0) {
96
+ const {
97
+ col: foundCollection,
98
+ match: matchString
99
+ } = potentialMatches[0];
100
+ resolvedPathParts.push(foundCollection.path);
101
+ remainingPath = removeInitialSlash(remainingPath.substring(matchString.length));
102
+ if (remainingPath.length === 0) {
103
+ foundMatch = true;
104
+ break;
105
+ }
106
+ const idSeparatorIndex = remainingPath.indexOf("/");
107
+ let entityId;
108
+ if (idSeparatorIndex > -1) {
109
+ entityId = remainingPath.substring(0, idSeparatorIndex);
110
+ remainingPath = remainingPath.substring(idSeparatorIndex + 1);
111
+ } else {
112
+ entityId = remainingPath;
113
+ remainingPath = "";
114
+ console.warn(`resolveCollectionPathIds: Path seems to end with an entity ID "${entityId}" instead of a collection segment in original path "${path}". This might indicate an invalid input path.`);
115
+ }
116
+ resolvedPathParts.push(entityId);
117
+ currentCollections = foundCollection.subcollections;
118
+ foundMatch = true;
119
+ if (!currentCollections && remainingPath.length > 0) {
120
+ console.warn(`resolveCollectionPathIds: Path continues after entity ID "${entityId}", but no subcollections are defined for the preceding collection "${foundCollection.path}" in path "${path}". Appending remaining original path.`);
121
+ resolvedPathParts.push(remainingPath);
122
+ remainingPath = "";
123
+ break;
124
+ }
98
125
  }
99
- matchingCollection = matchingCollections[0];
100
- }
101
- const entityId = subpaths[entityIndex];
102
- const remainingPath = subpaths.slice(entityIndex + 1);
103
- if (remainingPath.length > 0) {
104
- const subcollectionId = remainingPath[0];
105
- const subcollection = matchingCollection.subcollections?.find((subcol) => subcol.id === subcollectionId);
106
- if (subcollection) {
107
- return `${matchingCollection.path}/${entityId}/${subcollection.path}`;
126
+ if (!foundMatch) {
127
+ console.warn(`resolveCollectionPathIds: Collection definition not found for segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
128
+ resolvedPathParts.push(remainingPath);
129
+ remainingPath = "";
130
+ break;
108
131
  }
109
132
  }
110
- if (remainingPath.length === 0) {
111
- return `${matchingCollection.path}/${entityId}`;
112
- }
113
- return `${matchingCollection.path}/${entityId}/${remainingPath.join("/")}`;
133
+ return resolvedPathParts.join("/");
114
134
  }
115
135
  function getCollectionByPathOrId(pathOrId, collections) {
116
136
  const subpaths = removeInitialAndTrailingSlashes(pathOrId).split("/");
@@ -231,31 +251,36 @@ function isObject(item) {
231
251
  return item && typeof item === "object" && !Array.isArray(item);
232
252
  }
233
253
  function mergeDeep(target, source, ignoreUndefined = false) {
234
- const targetIsObject = isObject(target);
235
- const output = targetIsObject ? {
254
+ if (!isObject(target)) {
255
+ return target;
256
+ }
257
+ const output = {
236
258
  ...target
237
- } : target;
238
- if (targetIsObject && isObject(source)) {
239
- Object.keys(source).forEach((key) => {
240
- const sourceElement = source[key];
241
- if (ignoreUndefined && sourceElement === void 0) {
242
- return;
259
+ };
260
+ if (!isObject(source)) {
261
+ return output;
262
+ }
263
+ for (const key in source) {
264
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
265
+ const sourceValue = source[key];
266
+ const outputValue = output[key];
267
+ if (ignoreUndefined && sourceValue === void 0) {
268
+ continue;
243
269
  }
244
- if (sourceElement instanceof Date) {
245
- Object.assign(output, {
246
- [key]: new Date(sourceElement.getTime())
247
- });
248
- } else if (isObject(sourceElement)) {
249
- if (!(key in target)) Object.assign(output, {
250
- [key]: sourceElement
251
- });
252
- else output[key] = mergeDeep(target[key], sourceElement);
270
+ if (sourceValue instanceof Date) {
271
+ output[key] = new Date(sourceValue.getTime());
272
+ } else if (Array.isArray(sourceValue)) {
273
+ output[key] = [...sourceValue];
274
+ } else if (isObject(sourceValue)) {
275
+ if (isObject(outputValue)) {
276
+ output[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
277
+ } else {
278
+ output[key] = sourceValue;
279
+ }
253
280
  } else {
254
- Object.assign(output, {
255
- [key]: sourceElement
256
- });
281
+ output[key] = sourceValue;
257
282
  }
258
- });
283
+ }
259
284
  }
260
285
  return output;
261
286
  }
@@ -3747,6 +3772,108 @@ function replacePlaceholders({
3747
3772
  if (!result) result = randomString() + "_" + file.name;
3748
3773
  return result;
3749
3774
  }
3775
+ const mergeCallbacks = (baseCallbacks = {}, pluginCallbacks = {}) => {
3776
+ if (!baseCallbacks && !pluginCallbacks) {
3777
+ return void 0;
3778
+ }
3779
+ const mergedCallbacks = {};
3780
+ if (baseCallbacks.onFetch || pluginCallbacks.onFetch) {
3781
+ mergedCallbacks.onFetch = async (props) => {
3782
+ let entity = props.entity;
3783
+ if (baseCallbacks.onFetch) {
3784
+ entity = await Promise.resolve(baseCallbacks.onFetch(props));
3785
+ }
3786
+ if (pluginCallbacks.onFetch) {
3787
+ entity = await Promise.resolve(pluginCallbacks.onFetch({
3788
+ ...props,
3789
+ entity
3790
+ }));
3791
+ }
3792
+ return entity;
3793
+ };
3794
+ }
3795
+ if (baseCallbacks.onSaveSuccess || pluginCallbacks.onSaveSuccess) {
3796
+ mergedCallbacks.onSaveSuccess = async (props) => {
3797
+ if (baseCallbacks.onSaveSuccess) {
3798
+ await Promise.resolve(baseCallbacks.onSaveSuccess(props));
3799
+ }
3800
+ if (pluginCallbacks.onSaveSuccess) {
3801
+ await Promise.resolve(pluginCallbacks.onSaveSuccess(props));
3802
+ }
3803
+ };
3804
+ }
3805
+ if (baseCallbacks.onSaveFailure || pluginCallbacks.onSaveFailure) {
3806
+ mergedCallbacks.onSaveFailure = async (props) => {
3807
+ if (baseCallbacks.onSaveFailure) {
3808
+ await Promise.resolve(baseCallbacks.onSaveFailure(props));
3809
+ }
3810
+ if (pluginCallbacks.onSaveFailure) {
3811
+ await Promise.resolve(pluginCallbacks.onSaveFailure(props));
3812
+ }
3813
+ };
3814
+ }
3815
+ if (baseCallbacks.onPreSave || pluginCallbacks.onPreSave) {
3816
+ mergedCallbacks.onPreSave = async (props) => {
3817
+ let values = {
3818
+ ...props.values
3819
+ };
3820
+ if (baseCallbacks.onPreSave) {
3821
+ const baseValues = await Promise.resolve(baseCallbacks.onPreSave(props));
3822
+ values = {
3823
+ ...values,
3824
+ ...baseValues
3825
+ };
3826
+ }
3827
+ if (pluginCallbacks.onPreSave) {
3828
+ const pluginValues = await Promise.resolve(pluginCallbacks.onPreSave({
3829
+ ...props,
3830
+ values
3831
+ }));
3832
+ values = {
3833
+ ...values,
3834
+ ...pluginValues
3835
+ };
3836
+ }
3837
+ return values;
3838
+ };
3839
+ }
3840
+ if (baseCallbacks.onPreDelete || pluginCallbacks.onPreDelete) {
3841
+ mergedCallbacks.onPreDelete = (props) => {
3842
+ if (baseCallbacks.onPreDelete) {
3843
+ baseCallbacks.onPreDelete(props);
3844
+ }
3845
+ if (pluginCallbacks.onPreDelete) {
3846
+ pluginCallbacks.onPreDelete(props);
3847
+ }
3848
+ };
3849
+ }
3850
+ if (baseCallbacks.onDelete || pluginCallbacks.onDelete) {
3851
+ mergedCallbacks.onDelete = (props) => {
3852
+ if (baseCallbacks.onDelete) {
3853
+ baseCallbacks.onDelete(props);
3854
+ }
3855
+ if (pluginCallbacks.onDelete) {
3856
+ pluginCallbacks.onDelete(props);
3857
+ }
3858
+ };
3859
+ }
3860
+ if (baseCallbacks.onIdUpdate || pluginCallbacks.onIdUpdate) {
3861
+ mergedCallbacks.onIdUpdate = async (props) => {
3862
+ let id = props.entityId || "";
3863
+ if (baseCallbacks.onIdUpdate) {
3864
+ id = await Promise.resolve(baseCallbacks.onIdUpdate(props));
3865
+ }
3866
+ if (pluginCallbacks.onIdUpdate) {
3867
+ id = await Promise.resolve(pluginCallbacks.onIdUpdate({
3868
+ ...props,
3869
+ entityId: id
3870
+ }));
3871
+ }
3872
+ return id;
3873
+ };
3874
+ }
3875
+ return Object.keys(mergedCallbacks).length > 0 ? mergedCallbacks : void 0;
3876
+ };
3750
3877
  const CONTAINER_FULL_WIDTH = "100vw";
3751
3878
  const ADDITIONAL_TAB_WIDTH = "55vw";
3752
3879
  const FORM_CONTAINER_WIDTH = "768px";
@@ -4188,7 +4315,7 @@ function useEntityFetch(t0) {
4188
4315
  }
4189
4316
  } else {
4190
4317
  onEntityUpdate(void 0);
4191
- return _temp3$4;
4318
+ return _temp3$5;
4192
4319
  }
4193
4320
  }
4194
4321
  };
@@ -4229,7 +4356,7 @@ function useEntityFetch(t0) {
4229
4356
  }
4230
4357
  return t5;
4231
4358
  }
4232
- function _temp3$4() {
4359
+ function _temp3$5() {
4233
4360
  }
4234
4361
  function _temp2$d() {
4235
4362
  }
@@ -4284,11 +4411,6 @@ async function saveEntityWithCallbacks({
4284
4411
  } else {
4285
4412
  updatedValues = values;
4286
4413
  }
4287
- console.debug("Saving entity", {
4288
- entityId,
4289
- updatedValues,
4290
- collection
4291
- });
4292
4414
  return dataSource.saveEntity({
4293
4415
  collection,
4294
4416
  path: resolvedPath,
@@ -4323,7 +4445,6 @@ async function saveEntityWithCallbacks({
4323
4445
  }
4324
4446
  if (onSaveSuccess) onSaveSuccess(entity);
4325
4447
  }).catch((e) => {
4326
- console.error("!!!", e);
4327
4448
  if (callbacks?.onSaveFailure) {
4328
4449
  const resolvedCollection = resolveCollection({
4329
4450
  collection,
@@ -4639,7 +4760,6 @@ function ErrorView(t0) {
4639
4760
  tooltip
4640
4761
  } = t0;
4641
4762
  const component = error instanceof Error ? error.message : error;
4642
- console.warn("ErrorView", error);
4643
4763
  let t1;
4644
4764
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
4645
4765
  t1 = /* @__PURE__ */ jsx(ErrorIcon, { className: "mx-2", size: "small", color: "error" });
@@ -4805,7 +4925,7 @@ function ImagePreview(t0) {
4805
4925
  }
4806
4926
  let t7;
4807
4927
  if ($[13] !== url) {
4808
- t7 = navigator && /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Copy url to clipboard", side: "bottom", children: /* @__PURE__ */ jsx(IconButton, { variant: "filled", size: "small", onClick: (e) => {
4928
+ t7 = navigator && /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Copy url to clipboard", side: "bottom", children: /* @__PURE__ */ jsx(IconButton, { variant: "filled", size: "smallest", onClick: (e) => {
4809
4929
  e.stopPropagation();
4810
4930
  e.preventDefault();
4811
4931
  return navigator.clipboard.writeText(url);
@@ -4824,7 +4944,7 @@ function ImagePreview(t0) {
4824
4944
  }
4825
4945
  let t9;
4826
4946
  if ($[16] !== url) {
4827
- t9 = /* @__PURE__ */ jsx(Tooltip, { title: "Open image in new tab", side: "bottom", children: /* @__PURE__ */ jsx(IconButton, { className: "invisible group-hover:visible", variant: "filled", component: "a", href: url, rel: "noopener noreferrer", target: "_blank", size: "small", onClick: _temp$q, children: t8 }) });
4947
+ t9 = /* @__PURE__ */ jsx(Tooltip, { title: "Open image in new tab", side: "bottom", children: /* @__PURE__ */ jsx(IconButton, { className: "invisible group-hover:visible", variant: "filled", component: "a", href: url, rel: "noopener noreferrer", target: "_blank", size: "smallest", onClick: _temp$q, children: t8 }) });
4828
4948
  $[16] = url;
4829
4949
  $[17] = t9;
4830
4950
  } else {
@@ -5177,9 +5297,9 @@ function SkeletonPropertyComponent(t0) {
5177
5297
  } else {
5178
5298
  if (arrayProperty.of.dataType === "map" && arrayProperty.of.properties) {
5179
5299
  let t1;
5180
- if ($[10] !== arrayProperty.of.previewProperties || $[11] !== arrayProperty.of.properties || $[12] !== size) {
5181
- t1 = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.previewProperties);
5182
- $[10] = arrayProperty.of.previewProperties;
5300
+ if ($[10] !== arrayProperty.of.previewKeys || $[11] !== arrayProperty.of.properties || $[12] !== size) {
5301
+ t1 = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.previewKeys);
5302
+ $[10] = arrayProperty.of.previewKeys;
5183
5303
  $[11] = arrayProperty.of.properties;
5184
5304
  $[12] = size;
5185
5305
  $[13] = t1;
@@ -5583,7 +5703,7 @@ function StringPropertyPreview(t0) {
5583
5703
  let t1;
5584
5704
  if ($[17] !== size || $[18] !== value) {
5585
5705
  const lines = value.split("\n");
5586
- t1 = value && value.includes("\n") ? /* @__PURE__ */ jsx("div", { className: cls("overflow-x-scroll", size === "small" ? "text-sm" : ""), children: lines.map((str, index) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
5706
+ t1 = value && value.includes("\n") ? /* @__PURE__ */ jsx("div", { className: cls("overflow-x-scroll overflow-hidden", size === "small" ? "text-sm" : ""), children: lines.map((str, index) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
5587
5707
  /* @__PURE__ */ jsx("span", { children: str }),
5588
5708
  index !== lines.length - 1 && /* @__PURE__ */ jsx("br", {})
5589
5709
  ] }, `string_preview_${index}`)) }) : size === "small" ? /* @__PURE__ */ jsx("span", { className: "text-sm", children: value }) : /* @__PURE__ */ jsx(Fragment, { children: value });
@@ -5666,11 +5786,13 @@ function EntityPreview({
5666
5786
  disabled,
5667
5787
  hover,
5668
5788
  collection: collectionProp,
5669
- previewProperties,
5789
+ previewKeys,
5670
5790
  onClick,
5671
5791
  size,
5672
5792
  includeId = true,
5793
+ includeTitle = true,
5673
5794
  includeEntityLink = true,
5795
+ includeImage = true,
5674
5796
  entity
5675
5797
  }) {
5676
5798
  const authController = useAuthController();
@@ -5689,9 +5811,9 @@ function EntityPreview({
5689
5811
  propertyConfigs: customizationController.propertyConfigs,
5690
5812
  authController
5691
5813
  }), [collection]);
5692
- const listProperties = useMemo(() => getEntityPreviewKeys(authController, resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "medium" || size === "large" ? 3 : 1), [previewProperties, resolvedCollection, size]);
5693
- const titleProperty = getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs);
5694
- const imagePropertyKey = getEntityImagePreviewPropertyKey(resolvedCollection);
5814
+ const listProperties = useMemo(() => previewKeys ?? getEntityPreviewKeys(authController, resolvedCollection, customizationController.propertyConfigs, previewKeys, size === "medium" || size === "large" ? 3 : 1), [previewKeys, resolvedCollection, size]);
5815
+ const titleProperty = includeTitle ? getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs) : void 0;
5816
+ const imagePropertyKey = includeImage ? getEntityImagePreviewPropertyKey(resolvedCollection) : void 0;
5695
5817
  const imageProperty = imagePropertyKey ? resolvedCollection.properties[imagePropertyKey] : void 0;
5696
5818
  const usedImageProperty = imageProperty && "of" in imageProperty ? imageProperty.of : imageProperty;
5697
5819
  const restProperties = listProperties.filter((p) => p !== titleProperty && p !== imagePropertyKey);
@@ -5702,18 +5824,17 @@ function EntityPreview({
5702
5824
  usedImageProperty && usedImageValue && /* @__PURE__ */ jsx(PropertyPreview, { property: usedImageProperty, propertyKey: imagePropertyKey, size: "small", value: usedImageValue }),
5703
5825
  (!usedImageProperty || !usedImageValue) && /* @__PURE__ */ jsx(IconForView, { collectionOrView: collection, color: "primary", size, className: "m-auto p-1" })
5704
5826
  ] }),
5705
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col grow-1 w-full m-1 shrink-1", style: {
5706
- "maxWidth": "calc(100% - 96px)"
5707
- }, children: [
5827
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col grow w-full m-1 shrink min-w-0", children: [
5708
5828
  size !== "small" && includeId && (entity ? /* @__PURE__ */ jsx("div", { className: "block whitespace-nowrap overflow-hidden truncate", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "disabled", className: "font-mono", children: entity.id }) }) : /* @__PURE__ */ jsx(Skeleton, {})),
5709
5829
  titleProperty && /* @__PURE__ */ jsx("div", { className: "truncate my-0.5 text-sm font-medium", children: entity ? /* @__PURE__ */ jsx(PropertyPreview, { propertyKey: titleProperty, value: getValueInPath(entity.values, titleProperty), property: resolvedCollection.properties[titleProperty], size: "large" }) : /* @__PURE__ */ jsx(SkeletonPropertyComponent, { property: resolvedCollection.properties[titleProperty], size: "large" }) }),
5710
5830
  restProperties && restProperties.map((key) => {
5711
- const childProperty = resolvedCollection.properties[key];
5831
+ const childProperty = getPropertyInPath(resolvedCollection.properties, key);
5712
5832
  if (!childProperty) return null;
5713
- return /* @__PURE__ */ jsx("div", { className: cls("truncate", restProperties.length > 1 ? "my-0.5" : "my-0"), children: entity ? /* @__PURE__ */ jsx(PropertyPreview, { propertyKey: key, value: getValueInPath(entity.values, key), property: childProperty, size: "small" }) : /* @__PURE__ */ jsx(SkeletonPropertyComponent, { property: childProperty, size: "small" }) }, "ref_prev_" + key);
5833
+ const valueInPath = getValueInPath(entity.values, key);
5834
+ return /* @__PURE__ */ jsx("div", { className: cls("truncate", restProperties.length > 1 ? "my-0.5" : "my-0"), children: entity ? /* @__PURE__ */ jsx(PropertyPreview, { propertyKey: key, value: valueInPath, property: childProperty, size: "small" }) : /* @__PURE__ */ jsx(SkeletonPropertyComponent, { property: childProperty, size: "small" }) }, "ref_prev_" + key);
5714
5835
  })
5715
5836
  ] }),
5716
- entity && includeEntityLink && /* @__PURE__ */ jsx(Tooltip, { title: `See details for ${entity.id}`, className: "shrink-0", children: /* @__PURE__ */ jsx(IconButton, { color: "inherit", size: "medium", className: size !== "small" ? "self-start" : "", onClick: (e) => {
5837
+ entity && includeEntityLink && /* @__PURE__ */ jsx(Tooltip, { title: `See details for ${entity.id}`, className: "shrink-0", children: /* @__PURE__ */ jsx(IconButton, { color: "inherit", size: "small", className: size !== "small" ? "self-start" : "", onClick: (e) => {
5717
5838
  e.stopPropagation();
5718
5839
  analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
5719
5840
  path: entity.path,
@@ -5725,7 +5846,7 @@ function EntityPreview({
5725
5846
  collection,
5726
5847
  updateUrl: true
5727
5848
  });
5728
- }, children: /* @__PURE__ */ jsx(KeyboardTabIcon, { size: "medium" }) }) }),
5849
+ }, children: /* @__PURE__ */ jsx(KeyboardTabIcon, { size: "small" }) }) }),
5729
5850
  actions
5730
5851
  ] });
5731
5852
  }
@@ -6061,7 +6182,7 @@ function ReferencePreviewExisting(t0) {
6061
6182
  }
6062
6183
  let t3;
6063
6184
  if ($[25] !== collection || $[26] !== disabled || $[27] !== hover || $[28] !== includeEntityLink || $[29] !== includeId || $[30] !== onClick || $[31] !== previewProperties || $[32] !== size || $[33] !== usedEntity) {
6064
- t3 = /* @__PURE__ */ jsx(EntityPreview, { size, previewProperties, disabled, entity: usedEntity, collection, onClick, includeEntityLink, includeId, hover });
6185
+ t3 = /* @__PURE__ */ jsx(EntityPreview, { size, previewKeys: previewProperties, disabled, entity: usedEntity, collection, onClick, includeEntityLink, includeId, hover });
6065
6186
  $[25] = collection;
6066
6187
  $[26] = disabled;
6067
6188
  $[27] = hover;
@@ -6496,7 +6617,7 @@ function _temp$n(t0) {
6496
6617
  return /* @__PURE__ */ jsxs("div", { className: cls(defaultBorderMixin, "last:border-b-0 border-b"), children: [
6497
6618
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row pt-0.5 pb-0.5 gap-2", children: [
6498
6619
  /* @__PURE__ */ jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-mono break-words", color: "secondary", children: key }) }, `table-cell-title-${key}-${key}`),
6499
- /* @__PURE__ */ jsx("div", { className: "flex-grow max-w-[75%]", children: childValue && /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: childValue.toString() }) }) })
6620
+ /* @__PURE__ */ jsx("div", { className: "flex-grow max-w-[75%]", children: childValue && typeof childValue !== "object" && /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: childValue.toString() }) }) })
6500
6621
  ] }),
6501
6622
  typeof childValue === "object" && /* @__PURE__ */ jsx("div", { className: cls(defaultBorderMixin, "border-l pl-4"), children: /* @__PURE__ */ jsx(KeyValuePreview, { value: childValue }) })
6502
6623
  ] }, `map_preview_table_${key}}`);
@@ -6909,7 +7030,7 @@ function ArrayOfMapsPreview(t0) {
6909
7030
  throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property ${propertyKey}`);
6910
7031
  }
6911
7032
  const values = value;
6912
- const previewProperties = mapProperty.previewProperties;
7033
+ const previewProperties = mapProperty.previewKeys;
6913
7034
  if (!values) {
6914
7035
  t4 = null;
6915
7036
  break bb0;
@@ -7148,7 +7269,6 @@ function VirtualTableInput(props) {
7148
7269
  width: "100%",
7149
7270
  color: "unset",
7150
7271
  fontWeight: "unset",
7151
- lineHeight: 1.7142857,
7152
7272
  fontSize: "unset",
7153
7273
  fontFamily: "unset",
7154
7274
  background: "unset",
@@ -8735,7 +8855,7 @@ const TableCellInner = (t0) => {
8735
8855
  return t8;
8736
8856
  };
8737
8857
  const EntityTableCell = React__default.memo(function EntityTableCell2(t0) {
8738
- const $ = c(45);
8858
+ const $ = c(48);
8739
8859
  const {
8740
8860
  children,
8741
8861
  actions,
@@ -8964,11 +9084,11 @@ const EntityTableCell = React__default.memo(function EntityTableCell2(t0) {
8964
9084
  }
8965
9085
  let t25;
8966
9086
  if ($[37] !== actions || $[38] !== onFocus || $[39] !== t16 || $[40] !== t19 || $[41] !== t20 || $[42] !== t23 || $[43] !== t24) {
8967
- t25 = /* @__PURE__ */ jsxs("div", { className: t16, ref, style: t19, tabIndex: t20, onFocus, onMouseEnter: setOnHoverTrue, onMouseMove: setOnHoverTrue, onMouseLeave: setOnHoverFalse, children: [
9087
+ t25 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: t16, ref, style: t19, tabIndex: t20, onFocus, onMouseEnter: setOnHoverTrue, onMouseMove: setOnHoverTrue, onMouseLeave: setOnHoverFalse, children: [
8968
9088
  t23,
8969
9089
  actions,
8970
9090
  t24
8971
- ] });
9091
+ ] }) });
8972
9092
  $[37] = actions;
8973
9093
  $[38] = onFocus;
8974
9094
  $[39] = t16;
@@ -8980,7 +9100,21 @@ const EntityTableCell = React__default.memo(function EntityTableCell2(t0) {
8980
9100
  } else {
8981
9101
  t25 = $[44];
8982
9102
  }
8983
- return t25;
9103
+ const result = t25;
9104
+ if (showError) {
9105
+ const t26 = error?.message ?? "Error";
9106
+ let t27;
9107
+ if ($[45] !== result || $[46] !== t26) {
9108
+ t27 = /* @__PURE__ */ jsx(ErrorTooltip, { align: "start", title: t26, children: result });
9109
+ $[45] = result;
9110
+ $[46] = t26;
9111
+ $[47] = t27;
9112
+ } else {
9113
+ t27 = $[47];
9114
+ }
9115
+ return t27;
9116
+ }
9117
+ return result;
8984
9118
  }, (a, b) => {
8985
9119
  return a.error === b.error && a.value === b.value && a.disabled === b.disabled && a.saved === b.saved && a.allowScroll === b.allowScroll && a.align === b.align && a.size === b.size && a.disabledTooltip === b.disabledTooltip && a.width === b.width && a.showExpandIcon === b.showExpandIcon && a.removePadding === b.removePadding && a.fullHeight === b.fullHeight && a.selected === b.selected;
8986
9120
  });
@@ -9229,7 +9363,7 @@ const PropertyTableCell = React__default.memo(function PropertyTableCell2({
9229
9363
  }
9230
9364
  } else if (arrayProperty.of.dataType === "reference") {
9231
9365
  if (typeof arrayProperty.of.path === "string") {
9232
- innerComponent = /* @__PURE__ */ jsx(TableReferenceField, { name: propertyKey, disabled, internalValue, updateValue, size, multiselect: true, path: arrayProperty.of.path, previewProperties: arrayProperty.of.previewProperties, title: arrayProperty.name, forceFilter: arrayProperty.of.forceFilter, includeId: arrayProperty.of.includeId, includeEntityLink: arrayProperty.of.includeEntityLink });
9366
+ innerComponent = /* @__PURE__ */ jsx(TableReferenceField, { name: propertyKey, disabled, internalValue, updateValue, size, multiselect: true, path: arrayProperty.of.path, previewProperties: arrayProperty.of.previewKeys, title: arrayProperty.name, forceFilter: arrayProperty.of.forceFilter, includeId: arrayProperty.of.includeId, includeEntityLink: arrayProperty.of.includeEntityLink });
9233
9367
  }
9234
9368
  allowScroll = false;
9235
9369
  }
@@ -9492,7 +9626,7 @@ function CollectionTableToolbar(t0) {
9492
9626
  }
9493
9627
  let t6;
9494
9628
  if ($[6] !== t3 || $[7] !== t4) {
9495
- t6 = /* @__PURE__ */ jsx(Tooltip, { title: "Table row size", side: "right", sideOffset: 4, children: /* @__PURE__ */ jsx(Select, { value: t3, className: "w-16 h-10", size: "small", onValueChange: t4, renderValue: _temp$j, children: t5 }) });
9629
+ t6 = /* @__PURE__ */ jsx(Tooltip, { title: "Table row size", side: "right", sideOffset: 4, children: /* @__PURE__ */ jsx(Select, { value: t3, className: "w-16 ml-2", size: "small", onValueChange: t4, renderValue: _temp$j, children: t5 }) });
9496
9630
  $[6] = t3;
9497
9631
  $[7] = t4;
9498
9632
  $[8] = t6;
@@ -10491,8 +10625,7 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10491
10625
  className,
10492
10626
  endAdornment,
10493
10627
  AddColumnComponent,
10494
- initialScroll = 0,
10495
- debug
10628
+ initialScroll = 0
10496
10629
  }) {
10497
10630
  const sortByProperty = sortBy ? sortBy[0] : void 0;
10498
10631
  const currentSort = sortBy ? sortBy[1] : void 0;
@@ -10502,7 +10635,10 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10502
10635
  const debouncedScroll = useDebounceCallback(onScrollProp, 200);
10503
10636
  useEffect(() => {
10504
10637
  if (tableRef.current && initialScroll) {
10505
- tableRef.current.scrollTo(0, initialScroll);
10638
+ const {
10639
+ scrollLeft
10640
+ } = tableRef.current;
10641
+ tableRef.current.scrollTo(scrollLeft, initialScroll);
10506
10642
  }
10507
10643
  }, [tableRef, initialScroll]);
10508
10644
  useEffect(() => {
@@ -10533,11 +10669,9 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10533
10669
  offsetSize: true
10534
10670
  });
10535
10671
  const onColumnResizeInternal = useCallback((params) => {
10536
- if (debug) console.log("onColumnResizeInternal", params);
10537
- setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
10538
- }, [columns]);
10672
+ setColumns((prevColumns) => prevColumns.map((column) => column.key === params.column.key ? params.column : column));
10673
+ }, []);
10539
10674
  const onColumnResizeEndInternal = useCallback((params_0) => {
10540
- if (debug) console.log("onColumnResizeEndInternal", params_0);
10541
10675
  setColumns(columns.map((column_0) => column_0.key === params_0.column.key ? params_0.column : column_0));
10542
10676
  if (onColumnResize) {
10543
10677
  onColumnResize(params_0);
@@ -10545,18 +10679,15 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10545
10679
  }, [columns, onColumnResize]);
10546
10680
  const filterRef = useRef();
10547
10681
  useEffect(() => {
10548
- if (debug) console.log("Filter updated", filterInput);
10549
10682
  filterRef.current = filterInput;
10550
10683
  }, [filterInput]);
10551
10684
  const scrollToTop = useCallback(() => {
10552
- if (debug) console.log("scrollToTop");
10553
10685
  endReachCallbackThreshold.current = 0;
10554
10686
  if (tableRef.current) {
10555
10687
  tableRef.current.scrollTo(tableRef.current?.scrollLeft, 0);
10556
10688
  }
10557
10689
  }, []);
10558
10690
  const onColumnSort = useCallback((key) => {
10559
- if (debug) console.log("onColumnSort", key);
10560
10691
  const isDesc = sortByProperty === key && currentSort === "desc";
10561
10692
  const isAsc = sortByProperty === key && currentSort === "asc";
10562
10693
  const newSort = isAsc ? "desc" : isDesc ? void 0 : "asc";
@@ -10577,9 +10708,7 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10577
10708
  scrollToTop();
10578
10709
  }, [checkFilterCombination, currentSort, onFilterUpdate, onResetPagination, onSortByUpdate, scrollToTop, sortByProperty]);
10579
10710
  const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
10580
- if (debug) console.log("maxScroll", maxScroll);
10581
10711
  const onEndReachedInternal = useCallback((scrollOffset) => {
10582
- if (debug) console.log("onEndReachedInternal", scrollOffset, endReachCallbackThreshold.current + endOffset);
10583
10712
  if (onEndReached && (data?.length ?? 0) > 0 && scrollOffset > endReachCallbackThreshold.current + endOffset) {
10584
10713
  endReachCallbackThreshold.current = scrollOffset;
10585
10714
  onEndReached();
@@ -10590,11 +10719,6 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10590
10719
  scrollOffset: scrollOffset_0,
10591
10720
  scrollUpdateWasRequested
10592
10721
  }) => {
10593
- if (debug) console.log("onScroll", {
10594
- scrollDirection,
10595
- scrollOffset: scrollOffset_0,
10596
- scrollUpdateWasRequested
10597
- });
10598
10722
  if (onScrollProp) {
10599
10723
  debouncedScroll({
10600
10724
  scrollDirection,
@@ -10605,7 +10729,6 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10605
10729
  if (!scrollUpdateWasRequested && scrollOffset_0 >= maxScroll - endOffset) onEndReachedInternal(scrollOffset_0);
10606
10730
  }, [maxScroll, onEndReachedInternal]);
10607
10731
  const onFilterUpdateInternal = useCallback((column_1, filterForProperty) => {
10608
- if (debug) console.log("onFilterUpdateInternal", column_1, filterForProperty);
10609
10732
  endReachCallbackThreshold.current = 0;
10610
10733
  const filter_0 = filterRef.current;
10611
10734
  let newFilterValue = filter_0 ? {
@@ -10653,7 +10776,6 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10653
10776
  endAdornment,
10654
10777
  AddColumnComponent
10655
10778
  };
10656
- if (debug) console.log("VirtualTable render", virtualListController);
10657
10779
  return /* @__PURE__ */ jsx("div", { ref: measureRef, style, className: cls("h-full w-full", className), children: /* @__PURE__ */ jsx(VirtualListContext.Provider, { value: virtualListController, children: /* @__PURE__ */ jsx(MemoizedList, { outerRef: tableRef, width: bounds.width, height: bounds.height, itemCount: (data?.length ?? 0) + (endAdornment ? 1 : 0), onScroll, includeAddColumn: Boolean(AddColumnComponent), itemSize: rowHeight }, rowHeight) }) });
10658
10780
  }, equal);
10659
10781
  function MemoizedList({
@@ -10989,8 +11111,8 @@ function StringNumberFilterField(t0) {
10989
11111
  }
10990
11112
  let t9;
10991
11113
  if ($[34] !== dataType || $[35] !== enumValues || $[36] !== internalValue || $[37] !== multiple || $[38] !== name || $[39] !== operation || $[40] !== updateFilter) {
10992
- t9 = enumValues && multiple && /* @__PURE__ */ jsx(MultiSelect, { position: "item-aligned", value: Array.isArray(internalValue) ? internalValue.map(_temp3$3) : [], onValueChange: (value_2) => {
10993
- updateFilter(operation, dataType === "number" ? value_2.map(_temp4$2) : value_2);
11114
+ t9 = enumValues && multiple && /* @__PURE__ */ jsx(MultiSelect, { position: "item-aligned", value: Array.isArray(internalValue) ? internalValue.map(_temp3$4) : [], onValueChange: (value_2) => {
11115
+ updateFilter(operation, dataType === "number" ? value_2.map(_temp4$3) : value_2);
10994
11116
  }, multiple, endAdornment: internalValue && /* @__PURE__ */ jsx(IconButton, { className: "absolute right-2 top-3", onClick: (e_2) => updateFilter(operation, void 0), children: /* @__PURE__ */ jsx(CloseIcon, {}) }), children: enumValues.map((enumConfig_0) => /* @__PURE__ */ jsx(MultiSelectItem, { value: String(enumConfig_0.id), children: /* @__PURE__ */ jsx(EnumValuesChip, { enumKey: String(enumConfig_0.id), enumValues, size: "small" }) }, `select_value_${name}_${enumConfig_0.id}`)) });
10995
11117
  $[34] = dataType;
10996
11118
  $[35] = enumValues;
@@ -11053,10 +11175,10 @@ function StringNumberFilterField(t0) {
11053
11175
  }
11054
11176
  return t12;
11055
11177
  }
11056
- function _temp4$2(v) {
11178
+ function _temp4$3(v) {
11057
11179
  return parseInt(v);
11058
11180
  }
11059
- function _temp3$3(e_1) {
11181
+ function _temp3$4(e_1) {
11060
11182
  return String(e_1);
11061
11183
  }
11062
11184
  function _temp2$7(op_1) {
@@ -11293,97 +11415,94 @@ function _temp2$6(op_1) {
11293
11415
  function _temp$g(op_0) {
11294
11416
  return operationLabels[op_0];
11295
11417
  }
11296
- const SelectableTable = React__default.memo(
11297
- function SelectableTable2({
11298
- onValueChange,
11299
- cellRenderer,
11300
- onEntityClick,
11301
- onColumnResize,
11302
- hoverRow = true,
11303
- size = "m",
11304
- inlineEditing = false,
11305
- tableController: {
11306
- data,
11307
- dataLoading,
11308
- noMoreToLoad,
11309
- dataLoadingError,
11310
- filterValues,
11311
- setFilterValues,
11312
- sortBy,
11313
- setSortBy,
11314
- itemCount,
11315
- setItemCount,
11316
- pageSize = 50,
11317
- paginationEnabled,
11318
- checkFilterCombination,
11319
- setPopupCell
11320
- },
11321
- filterable = true,
11322
- onScroll,
11323
- initialScroll,
11324
- emptyComponent,
11325
- columns,
11326
- forceFilter,
11327
- highlightedRow,
11328
- endAdornment,
11329
- AddColumnComponent
11330
- }) {
11331
- const ref = useRef(null);
11332
- const [selectedCell, setSelectedCell] = React__default.useState(void 0);
11333
- const loadNextPage = () => {
11334
- if (!paginationEnabled || dataLoading || noMoreToLoad) return;
11335
- if (itemCount !== void 0) setItemCount?.(itemCount + pageSize);
11336
- };
11337
- const resetPagination = useCallback(() => {
11338
- setItemCount?.(pageSize);
11339
- }, [pageSize]);
11340
- const onRowClick = useCallback(({
11341
- rowData
11342
- }) => {
11343
- if (inlineEditing) return;
11344
- return onEntityClick && onEntityClick(rowData);
11345
- }, [onEntityClick, inlineEditing]);
11346
- useOutsideAlerter(ref, () => {
11347
- if (selectedCell) {
11418
+ const SelectableTable = function SelectableTable2({
11419
+ onValueChange,
11420
+ cellRenderer,
11421
+ onEntityClick,
11422
+ onColumnResize,
11423
+ hoverRow = true,
11424
+ size = "m",
11425
+ inlineEditing = false,
11426
+ tableController: {
11427
+ data,
11428
+ dataLoading,
11429
+ noMoreToLoad,
11430
+ dataLoadingError,
11431
+ filterValues,
11432
+ setFilterValues,
11433
+ sortBy,
11434
+ setSortBy,
11435
+ itemCount,
11436
+ setItemCount,
11437
+ pageSize = 50,
11438
+ paginationEnabled,
11439
+ checkFilterCombination,
11440
+ setPopupCell
11441
+ },
11442
+ filterable = true,
11443
+ onScroll,
11444
+ initialScroll,
11445
+ emptyComponent,
11446
+ columns,
11447
+ forceFilter,
11448
+ highlightedRow,
11449
+ endAdornment,
11450
+ AddColumnComponent
11451
+ }) {
11452
+ const ref = useRef(null);
11453
+ const [selectedCell, setSelectedCell] = React__default.useState(void 0);
11454
+ const loadNextPage = () => {
11455
+ if (!paginationEnabled || dataLoading || noMoreToLoad) return;
11456
+ if (itemCount !== void 0) setItemCount?.(itemCount + pageSize);
11457
+ };
11458
+ const resetPagination = useCallback(() => {
11459
+ setItemCount?.(pageSize);
11460
+ }, [pageSize]);
11461
+ const onRowClick = useCallback(({
11462
+ rowData
11463
+ }) => {
11464
+ if (inlineEditing) return;
11465
+ return onEntityClick && onEntityClick(rowData);
11466
+ }, [onEntityClick, inlineEditing]);
11467
+ useOutsideAlerter(ref, () => {
11468
+ if (selectedCell) {
11469
+ unselect();
11470
+ }
11471
+ }, Boolean(selectedCell));
11472
+ const select = useCallback((cell) => {
11473
+ setSelectedCell(cell);
11474
+ }, []);
11475
+ const unselect = useCallback(() => {
11476
+ setSelectedCell(void 0);
11477
+ }, []);
11478
+ useEffect(() => {
11479
+ const escFunction = (event) => {
11480
+ if (event.keyCode === 27) {
11348
11481
  unselect();
11349
11482
  }
11350
- }, Boolean(selectedCell));
11351
- useEffect(() => {
11352
- const escFunction = (event) => {
11353
- if (event.keyCode === 27) {
11354
- unselect();
11355
- }
11356
- };
11357
- document.addEventListener("keydown", escFunction, false);
11358
- return () => {
11359
- document.removeEventListener("keydown", escFunction, false);
11360
- };
11483
+ };
11484
+ document.addEventListener("keydown", escFunction, false);
11485
+ return () => {
11486
+ document.removeEventListener("keydown", escFunction, false);
11487
+ };
11488
+ }, [unselect]);
11489
+ const onFilterUpdate = useCallback((updatedFilterValues) => {
11490
+ setFilterValues?.({
11491
+ ...updatedFilterValues,
11492
+ ...forceFilter
11361
11493
  });
11362
- const select = useCallback((cell) => {
11363
- setSelectedCell(cell);
11364
- }, []);
11365
- const unselect = useCallback(() => {
11366
- setSelectedCell(void 0);
11367
- }, []);
11368
- const onFilterUpdate = useCallback((updatedFilterValues) => {
11369
- setFilterValues?.({
11370
- ...updatedFilterValues,
11371
- ...forceFilter
11372
- });
11373
- }, [forceFilter]);
11374
- return /* @__PURE__ */ jsx(SelectableTableContext.Provider, { value: {
11375
- setPopupCell,
11376
- select,
11377
- onValueChange,
11378
- size: size ?? "m",
11379
- selectedCell
11380
- }, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full flex flex-col bg-white dark:bg-surface-950", ref, children: /* @__PURE__ */ jsx(VirtualTable, { data, columns, cellRenderer, onRowClick: inlineEditing ? void 0 : onEntityClick ? onRowClick : void 0, onEndReached: loadNextPage, onResetPagination: resetPagination, error: dataLoadingError, onColumnResize, rowHeight: getRowHeight(size), loading: dataLoading, filter: filterValues, onFilterUpdate: setFilterValues ? onFilterUpdate : void 0, sortBy, onSortByUpdate: setSortBy, hoverRow, initialScroll, onScroll, checkFilterCombination, createFilterField: filterable ? createFilterField : void 0, rowClassName: useCallback((entity) => {
11381
- return highlightedRow?.(entity) ? "bg-surface-100 bg-opacity-75 dark:bg-surface-800 dark:bg-opacity-75" : "";
11382
- }, [highlightedRow]), className: "flex-grow", emptyComponent, endAdornment, AddColumnComponent }) }) });
11383
- },
11384
- () => false
11385
- // equal
11386
- );
11494
+ }, [forceFilter]);
11495
+ const contextValue = useMemo(() => ({
11496
+ setPopupCell,
11497
+ select,
11498
+ onValueChange,
11499
+ size: size ?? "m",
11500
+ selectedCell
11501
+ }), [setPopupCell, select, onValueChange, size, selectedCell]);
11502
+ return /* @__PURE__ */ jsx(SelectableTableContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full flex flex-col bg-white dark:bg-surface-950", ref, children: /* @__PURE__ */ jsx(VirtualTable, { data, columns, cellRenderer, onRowClick: inlineEditing ? void 0 : onEntityClick ? onRowClick : void 0, onEndReached: loadNextPage, onResetPagination: resetPagination, error: dataLoadingError, onColumnResize, rowHeight: getRowHeight(size), loading: dataLoading, filter: filterValues, onFilterUpdate: setFilterValues ? onFilterUpdate : void 0, sortBy, onSortByUpdate: setSortBy, hoverRow, initialScroll, onScroll, checkFilterCombination, createFilterField: filterable ? createFilterField : void 0, rowClassName: useCallback((entity) => {
11503
+ return highlightedRow?.(entity) ? "bg-surface-100 bg-opacity-75 dark:bg-surface-800 dark:bg-opacity-75" : "";
11504
+ }, [highlightedRow]), className: "flex-grow", emptyComponent, endAdornment, AddColumnComponent }) }) });
11505
+ };
11387
11506
  function createFilterField({
11388
11507
  id,
11389
11508
  filterValue,
@@ -12841,7 +12960,7 @@ function NavigationCardBinding(t0) {
12841
12960
  const favourite = t4;
12842
12961
  let t5;
12843
12962
  if ($[7] !== collection || $[8] !== context || $[9] !== customizationController.plugins || $[10] !== favourite || $[11] !== path || $[12] !== userConfigurationPersistence) {
12844
- const actionsArray = userConfigurationPersistence ? [/* @__PURE__ */ jsx(IconButton, { onClick: (e) => {
12963
+ const actionsArray = userConfigurationPersistence ? [/* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (e) => {
12845
12964
  e.preventDefault();
12846
12965
  e.stopPropagation();
12847
12966
  if (favourite) {
@@ -12849,7 +12968,7 @@ function NavigationCardBinding(t0) {
12849
12968
  } else {
12850
12969
  userConfigurationPersistence.setFavouritePaths([...userConfigurationPersistence.favouritePaths, path]);
12851
12970
  }
12852
- }, children: /* @__PURE__ */ jsx(StarIcon, { size: 18, className: favourite ? "text-secondary" : "text-surface-400 dark:text-surface-500" }) }, "favourite")] : [];
12971
+ }, children: /* @__PURE__ */ jsx(StarIcon, { size: "small", className: favourite ? "text-secondary" : "text-surface-400 dark:text-surface-500" }) }, "favourite")] : [];
12853
12972
  if (customizationController.plugins && collection) {
12854
12973
  let t62;
12855
12974
  if ($[14] !== collection || $[15] !== context || $[16] !== path) {
@@ -13183,7 +13302,7 @@ function DefaultHomePage(t0) {
13183
13302
  if ($[7] !== additionalActions || $[8] !== additionalChildrenStart || $[9] !== containerRef || $[10] !== context || $[11] !== customizationController.plugins || $[12] !== direction || $[13] !== filteredNavigationEntries || $[14] !== filteredUrls || $[15] !== groups || $[16] !== performingSearch) {
13184
13303
  const filteredGroups = filteredUrls ? filteredNavigationEntries.map(_temp2$5) : [];
13185
13304
  const allGroups = filteredUrls ? filteredGroups.filter((group, index) => filteredGroups.indexOf(group) === index) : [...groups];
13186
- if (filteredNavigationEntries.filter(_temp3$2).length > 0 || filteredNavigationEntries.length === 0) {
13305
+ if (filteredNavigationEntries.filter(_temp3$3).length > 0 || filteredNavigationEntries.length === 0) {
13187
13306
  allGroups.push(void 0);
13188
13307
  }
13189
13308
  let additionalPluginChildrenStart;
@@ -13193,7 +13312,7 @@ function DefaultHomePage(t0) {
13193
13312
  const sectionProps = {
13194
13313
  context
13195
13314
  };
13196
- t143 = customizationController.plugins.filter(_temp4$1).map((plugin_0, i) => {
13315
+ t143 = customizationController.plugins.filter(_temp4$2).map((plugin_0, i) => {
13197
13316
  const section = plugin_0.homePage.includeSection(sectionProps);
13198
13317
  return /* @__PURE__ */ jsx(NavigationGroup, { group: section.title, children: section.children }, `plugin_section_${plugin_0.key}`);
13199
13318
  });
@@ -13214,7 +13333,7 @@ function DefaultHomePage(t0) {
13214
13333
  additionalPluginSections = t153;
13215
13334
  let t162;
13216
13335
  if ($[34] !== customizationController.plugins) {
13217
- t162 = customizationController.plugins.filter(_temp5$1).map(_temp6$1);
13336
+ t162 = customizationController.plugins.filter(_temp5$2).map(_temp6$2);
13218
13337
  $[34] = customizationController.plugins;
13219
13338
  $[35] = t162;
13220
13339
  } else {
@@ -13231,7 +13350,7 @@ function DefaultHomePage(t0) {
13231
13350
  additionalPluginChildrenStart = t172;
13232
13351
  let t18;
13233
13352
  if ($[38] !== customizationController.plugins) {
13234
- t18 = customizationController.plugins.filter(_temp7).map(_temp8);
13353
+ t18 = customizationController.plugins.filter(_temp7$1).map(_temp8);
13235
13354
  $[38] = customizationController.plugins;
13236
13355
  $[39] = t18;
13237
13356
  } else {
@@ -13328,7 +13447,7 @@ function DefaultHomePage(t0) {
13328
13447
  context.analyticsController?.onAnalyticsEvent?.(event, {
13329
13448
  path: entry_1.path
13330
13449
  });
13331
- } }) }, `nav_${entry_1.group}_${entry_1.name}`)),
13450
+ } }) }, `nav_${entry_1.group}_${entry_1.path}_${entry_1.name}`)),
13332
13451
  group_0?.toLowerCase() !== "admin" && AdditionalCards && AdditionalCards.map((AdditionalCard, i_2) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AdditionalCard, { ...actionProps }) }, `nav_${group_0}_add_${i_2}`))
13333
13452
  ] }) }, `plugin_section_${group_0}`);
13334
13453
  };
@@ -13419,19 +13538,19 @@ function DefaultHomePage(t0) {
13419
13538
  function _temp8(plugin_4, i_1) {
13420
13539
  return /* @__PURE__ */ jsx("div", { children: plugin_4.homePage.additionalChildrenEnd }, `plugin_children_start_${i_1}`);
13421
13540
  }
13422
- function _temp7(plugin_3) {
13541
+ function _temp7$1(plugin_3) {
13423
13542
  return plugin_3.homePage?.additionalChildrenEnd;
13424
13543
  }
13425
- function _temp6$1(plugin_2, i_0) {
13544
+ function _temp6$2(plugin_2, i_0) {
13426
13545
  return /* @__PURE__ */ jsx("div", { children: plugin_2.homePage.additionalChildrenStart }, `plugin_children_start_${i_0}`);
13427
13546
  }
13428
- function _temp5$1(plugin_1) {
13547
+ function _temp5$2(plugin_1) {
13429
13548
  return plugin_1.homePage?.additionalChildrenStart;
13430
13549
  }
13431
- function _temp4$1(plugin) {
13550
+ function _temp4$2(plugin) {
13432
13551
  return plugin.homePage?.includeSection;
13433
13552
  }
13434
- function _temp3$2(e_1) {
13553
+ function _temp3$3(e_1) {
13435
13554
  return !e_1.group;
13436
13555
  }
13437
13556
  function _temp2$5(entry) {
@@ -13609,7 +13728,7 @@ function useDraggable({
13609
13728
  let relX = 0;
13610
13729
  let relY = 0;
13611
13730
  const listeningRef = React__default.useRef(false);
13612
- const onMouseDown = (event) => {
13731
+ const onMouseDown = useCallback((event) => {
13613
13732
  if (event.button !== 0 || !containerRef.current || event.defaultPrevented || event.innerClicked) {
13614
13733
  return;
13615
13734
  }
@@ -13623,14 +13742,14 @@ function useDraggable({
13623
13742
  document.addEventListener("mouseup", onMouseUp);
13624
13743
  document.addEventListener("selectstart", onSelect);
13625
13744
  listeningRef.current = true;
13626
- };
13627
- const onMouseDownInner = (event_0) => {
13745
+ }, [containerRef, onMove]);
13746
+ const onMouseDownInner = useCallback((event_0) => {
13628
13747
  event_0.innerClicked = true;
13629
- };
13630
- const onSelect = (event_1) => {
13748
+ }, []);
13749
+ const onSelect = useCallback((event_1) => {
13631
13750
  event_1.preventDefault();
13632
13751
  event_1.stopPropagation();
13633
- };
13752
+ }, []);
13634
13753
  const onMouseUp = (event_2) => {
13635
13754
  document.removeEventListener("mousemove", onMouseMove);
13636
13755
  document.removeEventListener("mouseup", onMouseUp);
@@ -13663,7 +13782,7 @@ function useDraggable({
13663
13782
  if (current) current.removeEventListener("mousedown", onMouseDown);
13664
13783
  if (innerCurrent) innerCurrent.removeEventListener("mousedown", onMouseDownInner);
13665
13784
  };
13666
- });
13785
+ }, [containerRef, innerRef, onMouseDownInner, onMouseDown]);
13667
13786
  }
13668
13787
  function useWindowSize() {
13669
13788
  const $ = c(3);
@@ -13702,46 +13821,6 @@ function useWindowSize() {
13702
13821
  useLayoutEffect(t1, t2);
13703
13822
  return size;
13704
13823
  }
13705
- const ElementResizeListener = ({
13706
- onResize
13707
- }) => {
13708
- const rafRef = useRef(0);
13709
- const objectRef = useRef(null);
13710
- const onResizeRef = useRef(onResize);
13711
- onResizeRef.current = onResize;
13712
- const _onResize = useCallback((e) => {
13713
- if (rafRef.current) {
13714
- cancelAnimationFrame(rafRef.current);
13715
- }
13716
- rafRef.current = requestAnimationFrame(() => {
13717
- onResizeRef.current(e);
13718
- });
13719
- }, []);
13720
- const onLoad = useCallback(() => {
13721
- const obj = objectRef.current;
13722
- if (obj && obj.contentDocument && obj.contentDocument.defaultView) {
13723
- obj.contentDocument.defaultView.addEventListener("resize", _onResize);
13724
- }
13725
- }, [_onResize]);
13726
- useEffect(() => {
13727
- const obj_0 = objectRef.current;
13728
- return () => {
13729
- if (obj_0 && obj_0.contentDocument && obj_0.contentDocument.defaultView) {
13730
- obj_0.contentDocument.defaultView.removeEventListener("resize", _onResize);
13731
- }
13732
- };
13733
- }, [_onResize]);
13734
- return /* @__PURE__ */ jsx("object", { onLoad, ref: objectRef, tabIndex: -1, type: "text/html", data: "about:blank", title: "", style: {
13735
- position: "absolute",
13736
- top: 0,
13737
- left: 0,
13738
- height: "100%",
13739
- width: "100%",
13740
- pointerEvents: "none",
13741
- zIndex: -1,
13742
- opacity: 0
13743
- } });
13744
- };
13745
13824
  function CustomIdField({
13746
13825
  customId,
13747
13826
  entityId,
@@ -13783,7 +13862,9 @@ function CustomIdField({
13783
13862
  ] }) : void 0
13784
13863
  };
13785
13864
  return /* @__PURE__ */ jsxs(Fragment, { children: [
13786
- enumValues && /* @__PURE__ */ jsx(Select, { size: "large", error, fullWidth: true, onValueChange: (v) => onChange(v), ...fieldProps, renderValue: (option) => {
13865
+ enumValues && /* @__PURE__ */ jsx(Select, { size: "large", error, fullWidth: true, onValueChange: (v) => {
13866
+ onChange(v);
13867
+ }, ...fieldProps, renderValue: (option) => {
13787
13868
  const enumConfig = enumValues.find((e_1) => e_1.id === option);
13788
13869
  if (!enumConfig) return option;
13789
13870
  return `${enumConfig.id} - ${enumConfig.label}`;
@@ -14362,7 +14443,7 @@ function EntityForm({
14362
14443
  const formRef = useRef(null);
14363
14444
  const formView = /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Fragment, { children: [
14364
14445
  !Builder && /* @__PURE__ */ jsxs("div", { className: "w-full py-2 flex flex-col items-start my-4 lg:my-6", children: [
14365
- /* @__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 }),
14446
+ /* @__PURE__ */ jsx(Typography, { className: "my-4 flex-grow line-clamp-1 " + (collection.hideIdFromForm ? "mb-6" : ""), variant: "h4", children: title ?? collection.singularName ?? collection.name }),
14366
14447
  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: [
14367
14448
  entity?.path ?? path,
14368
14449
  "/",
@@ -14515,7 +14596,7 @@ const LabelWithIcon = forwardRef((t0, ref) => {
14515
14596
  const t1 = small ? "gap-1" : "gap-2";
14516
14597
  let t2;
14517
14598
  if ($[0] !== className || $[1] !== t1) {
14518
- t2 = cls("inline-flex items-center my-0.5", t1, className);
14599
+ t2 = cls("align-middle inline-flex items-center my-0.5", t1, className);
14519
14600
  $[0] = className;
14520
14601
  $[1] = t1;
14521
14602
  $[2] = t2;
@@ -14851,7 +14932,7 @@ function SelectFieldBinding(t0) {
14851
14932
  }
14852
14933
  let t13;
14853
14934
  if ($[20] !== disabled || $[21] !== handleClearClick || $[22] !== property.clearable) {
14854
- t13 = property.clearable && !disabled && /* @__PURE__ */ jsx(IconButton, { onClick: handleClearClick, children: /* @__PURE__ */ jsx(CloseIcon, {}) });
14935
+ t13 = property.clearable && !disabled && /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: handleClearClick, children: /* @__PURE__ */ jsx(CloseIcon, { size: "small" }) });
14855
14936
  $[20] = disabled;
14856
14937
  $[21] = handleClearClick;
14857
14938
  $[22] = property.clearable;
@@ -14964,7 +15045,7 @@ function MultiSelectFieldBinding({
14964
15045
  ] }, enumKey);
14965
15046
  }, [enumValues, setValue, value]);
14966
15047
  return /* @__PURE__ */ jsxs(Fragment, { children: [
14967
- /* @__PURE__ */ jsx(MultiSelect, { className: "w-full mt-2", size, value: validValue ? value.map((v_0) => v_0.toString()) : [], disabled, modalPopover: true, label: /* @__PURE__ */ jsx(LabelWithIconAndTooltip, { propertyKey, icon: getIconForProperty(property, "small"), required: property.validation?.required, title: property.name, className: "h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5" }), onValueChange: (updatedValue) => {
15048
+ /* @__PURE__ */ jsx(MultiSelect, { className: "w-full mt-2", size, value: validValue ? value.map((v_0) => v_0?.toString()) : [], disabled, modalPopover: true, label: /* @__PURE__ */ jsx(LabelWithIconAndTooltip, { propertyKey, icon: getIconForProperty(property, "small"), required: property.validation?.required, title: property.name, className: "h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5" }), onValueChange: (updatedValue) => {
14968
15049
  let newValue;
14969
15050
  if (of && of?.dataType === "number") {
14970
15051
  newValue = updatedValue ? updatedValue.map((e_1) => parseFloat(e_1)) : [];
@@ -15045,7 +15126,8 @@ function ArrayOfReferencesFieldBinding({
15045
15126
  !collection && /* @__PURE__ */ jsx(ErrorView, { error: "The specified collection does not exist. Check console" }),
15046
15127
  collection && /* @__PURE__ */ jsxs("div", { className: "group", children: [
15047
15128
  /* @__PURE__ */ jsx(ArrayContainer, { droppableId: propertyKey, value, disabled: isSubmitting, buildEntry, canAddElements: false, addLabel: property.name ? "Add reference to " + property.name : "Add reference", newDefaultEntry: property.of.defaultValue, onValueChange: (value_0) => setFieldValue(propertyKey, value_0) }),
15048
- /* @__PURE__ */ jsxs(Button, { className: "my-4 justify-center text-left", variant: "text", color: "primary", disabled: isSubmitting, onClick: onEntryClick, children: [
15129
+ /* @__PURE__ */ jsxs(Button, { className: "ml-3.5 my-4 justify-center text-left", variant: "text", color: "primary", disabled: isSubmitting, onClick: onEntryClick, children: [
15130
+ /* @__PURE__ */ jsx(EditIcon, { size: "small" }),
15049
15131
  "Edit ",
15050
15132
  property.name
15051
15133
  ] })
@@ -15294,15 +15376,161 @@ function StorageUploadFieldBinding(t0) {
15294
15376
  }
15295
15377
  return t12;
15296
15378
  }
15379
+ function SortableStorageItem(t0) {
15380
+ const $ = c(35);
15381
+ const {
15382
+ id,
15383
+ entry,
15384
+ property,
15385
+ metadata,
15386
+ storagePathBuilder,
15387
+ onFileUploadComplete,
15388
+ onClear,
15389
+ disabled
15390
+ } = t0;
15391
+ let t1;
15392
+ if ($[0] !== id) {
15393
+ t1 = {
15394
+ id
15395
+ };
15396
+ $[0] = id;
15397
+ $[1] = t1;
15398
+ } else {
15399
+ t1 = $[1];
15400
+ }
15401
+ const {
15402
+ attributes,
15403
+ listeners: listeners2,
15404
+ setNodeRef,
15405
+ transform,
15406
+ transition,
15407
+ isDragging
15408
+ } = useSortable(t1);
15409
+ let t2;
15410
+ if ($[2] !== transform) {
15411
+ t2 = CSS.Transform.toString(transform);
15412
+ $[2] = transform;
15413
+ $[3] = t2;
15414
+ } else {
15415
+ t2 = $[3];
15416
+ }
15417
+ const t3 = isDragging ? 100 : void 0;
15418
+ const t4 = isDragging ? 0.8 : 1;
15419
+ let t5;
15420
+ if ($[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== transition) {
15421
+ t5 = {
15422
+ transform: t2,
15423
+ transition,
15424
+ zIndex: t3,
15425
+ opacity: t4
15426
+ };
15427
+ $[4] = t2;
15428
+ $[5] = t3;
15429
+ $[6] = t4;
15430
+ $[7] = transition;
15431
+ $[8] = t5;
15432
+ } else {
15433
+ t5 = $[8];
15434
+ }
15435
+ const style = t5;
15436
+ const getImageSizeNumber = _temp$a;
15437
+ let child;
15438
+ if (entry.storagePathOrDownloadUrl) {
15439
+ const t62 = `storage_preview_${entry.storagePathOrDownloadUrl}`;
15440
+ let t72;
15441
+ if ($[9] !== entry.storagePathOrDownloadUrl || $[10] !== onClear) {
15442
+ t72 = () => onClear(entry.storagePathOrDownloadUrl);
15443
+ $[9] = entry.storagePathOrDownloadUrl;
15444
+ $[10] = onClear;
15445
+ $[11] = t72;
15446
+ } else {
15447
+ t72 = $[11];
15448
+ }
15449
+ let t8;
15450
+ if ($[12] !== disabled || $[13] !== entry.size || $[14] !== entry.storagePathOrDownloadUrl || $[15] !== property || $[16] !== t62 || $[17] !== t72) {
15451
+ t8 = /* @__PURE__ */ jsx(StorageItemPreview, { name: t62, property, disabled, value: entry.storagePathOrDownloadUrl, onRemove: t72, size: entry.size });
15452
+ $[12] = disabled;
15453
+ $[13] = entry.size;
15454
+ $[14] = entry.storagePathOrDownloadUrl;
15455
+ $[15] = property;
15456
+ $[16] = t62;
15457
+ $[17] = t72;
15458
+ $[18] = t8;
15459
+ } else {
15460
+ t8 = $[18];
15461
+ }
15462
+ child = t8;
15463
+ } else {
15464
+ if (entry.file) {
15465
+ let t62;
15466
+ if ($[19] !== entry.file || $[20] !== storagePathBuilder) {
15467
+ t62 = storagePathBuilder(entry.file);
15468
+ $[19] = entry.file;
15469
+ $[20] = storagePathBuilder;
15470
+ $[21] = t62;
15471
+ } else {
15472
+ t62 = $[21];
15473
+ }
15474
+ const t72 = getImageSizeNumber(entry.size);
15475
+ let t8;
15476
+ if ($[22] !== entry || $[23] !== metadata || $[24] !== onFileUploadComplete || $[25] !== t62 || $[26] !== t72) {
15477
+ t8 = /* @__PURE__ */ jsx(StorageUploadProgress, { entry, metadata, storagePath: t62, onFileUploadComplete, imageSize: t72, simple: false });
15478
+ $[22] = entry;
15479
+ $[23] = metadata;
15480
+ $[24] = onFileUploadComplete;
15481
+ $[25] = t62;
15482
+ $[26] = t72;
15483
+ $[27] = t8;
15484
+ } else {
15485
+ t8 = $[27];
15486
+ }
15487
+ child = t8;
15488
+ }
15489
+ }
15490
+ let t6;
15491
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
15492
+ t6 = cls("rounded-md m-1");
15493
+ $[28] = t6;
15494
+ } else {
15495
+ t6 = $[28];
15496
+ }
15497
+ let t7;
15498
+ if ($[29] !== attributes || $[30] !== child || $[31] !== listeners2 || $[32] !== setNodeRef || $[33] !== style) {
15499
+ t7 = /* @__PURE__ */ jsx("div", { ref: setNodeRef, style, ...attributes, ...listeners2, className: t6, tabIndex: -1, children: child });
15500
+ $[29] = attributes;
15501
+ $[30] = child;
15502
+ $[31] = listeners2;
15503
+ $[32] = setNodeRef;
15504
+ $[33] = style;
15505
+ $[34] = t7;
15506
+ } else {
15507
+ t7 = $[34];
15508
+ }
15509
+ return t7;
15510
+ }
15511
+ function _temp$a(previewSize) {
15512
+ switch (previewSize) {
15513
+ case "small": {
15514
+ return 40;
15515
+ }
15516
+ case "medium": {
15517
+ return 118;
15518
+ }
15519
+ case "large": {
15520
+ return 220;
15521
+ }
15522
+ default: {
15523
+ return 118;
15524
+ }
15525
+ }
15526
+ }
15297
15527
  function FileDropComponent(t0) {
15298
- const $ = c(64);
15528
+ const $ = c(63);
15299
15529
  const {
15300
15530
  storage,
15301
15531
  disabled,
15302
- isDraggingOver,
15303
15532
  onFilesAdded,
15304
15533
  multipleFilesSupported,
15305
- droppableProvided,
15306
15534
  autoFocus,
15307
15535
  internalValue,
15308
15536
  property,
@@ -15310,23 +15538,23 @@ function FileDropComponent(t0) {
15310
15538
  metadata,
15311
15539
  storagePathBuilder,
15312
15540
  onFileUploadComplete,
15313
- size,
15314
15541
  name,
15315
- helpText
15542
+ helpText,
15543
+ isDndItemDragging
15316
15544
  } = t0;
15317
15545
  const snackbarContext = useSnackbarController();
15318
15546
  let t1;
15319
15547
  if ($[0] !== storage.acceptedFiles) {
15320
- t1 = storage.acceptedFiles ? storage.acceptedFiles.map(_temp$a).reduce(_temp2$4, {}) : void 0;
15548
+ t1 = storage.acceptedFiles ? storage.acceptedFiles.reduce(_temp2$4, {}) : void 0;
15321
15549
  $[0] = storage.acceptedFiles;
15322
15550
  $[1] = t1;
15323
15551
  } else {
15324
15552
  t1 = $[1];
15325
15553
  }
15326
- const t2 = disabled || isDraggingOver;
15554
+ const t2 = disabled || isDndItemDragging;
15327
15555
  let t3;
15328
15556
  if ($[2] !== snackbarContext || $[3] !== storage.maxSize) {
15329
- t3 = (fileRejections, event) => {
15557
+ t3 = (fileRejections) => {
15330
15558
  for (const fileRejection of fileRejections) {
15331
15559
  for (const error of fileRejection.errors) {
15332
15560
  console.error("Error uploading file: ", error);
@@ -15388,170 +15616,154 @@ function FileDropComponent(t0) {
15388
15616
  }
15389
15617
  const t6 = disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin;
15390
15618
  const t7 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15391
- const t8 = multipleFilesSupported && internalValue.length ? "" : "flex";
15619
+ const t8 = multipleFilesSupported && internalValue.length === 0 && "flex";
15392
15620
  const t9 = !isDragActive;
15393
- let t10;
15394
- if ($[13] !== disabled || $[14] !== isDragAccept || $[15] !== isDragActive || $[16] !== isDragReject || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
15395
- t10 = cls(fieldBackgroundMixin, t6, t7, dropZoneClasses, t8, {
15621
+ const t10 = disabled || isDndItemDragging;
15622
+ let t11;
15623
+ if ($[13] !== isDragAccept || $[14] !== isDragActive || $[15] !== isDragReject || $[16] !== t10 || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
15624
+ t11 = cls(fieldBackgroundMixin, t6, t7, dropZoneClasses, t8, {
15396
15625
  [nonActiveDropClasses]: t9,
15397
15626
  [activeDropClasses]: isDragActive,
15398
15627
  [rejectDropClasses]: isDragReject,
15399
15628
  [acceptDropClasses]: isDragAccept,
15400
- [disabledClasses]: disabled
15629
+ [disabledClasses]: t10
15401
15630
  });
15402
- $[13] = disabled;
15403
- $[14] = isDragAccept;
15404
- $[15] = isDragActive;
15405
- $[16] = isDragReject;
15631
+ $[13] = isDragAccept;
15632
+ $[14] = isDragActive;
15633
+ $[15] = isDragReject;
15634
+ $[16] = t10;
15406
15635
  $[17] = t6;
15407
15636
  $[18] = t7;
15408
15637
  $[19] = t8;
15409
15638
  $[20] = t9;
15410
- $[21] = t10;
15411
- } else {
15412
- t10 = $[21];
15413
- }
15414
- const t11 = droppableProvided.droppableProps;
15415
- const t12 = droppableProvided.innerRef;
15416
- const t13 = multipleFilesSupported && internalValue.length ? "overflow-auto" : "";
15417
- const t14 = multipleFilesSupported && internalValue.length ? "min-h-[180px]" : "min-h-[250px]";
15418
- let t15;
15419
- if ($[22] !== t13 || $[23] !== t14) {
15420
- t15 = cls("flex items-center p-1 no-scrollbar", t13, t14);
15421
- $[22] = t13;
15422
- $[23] = t14;
15423
- $[24] = t15;
15639
+ $[21] = t11;
15424
15640
  } else {
15425
- t15 = $[24];
15641
+ t11 = $[21];
15426
15642
  }
15643
+ const t12 = multipleFilesSupported && internalValue.length ? "flex-row overflow-x-auto" : "flex-col";
15644
+ const t13 = internalValue.length === 0 && "min-h-[250px] justify-center";
15645
+ const t14 = multipleFilesSupported && internalValue.length > 0 && "min-h-[180px]";
15646
+ const t15 = !multipleFilesSupported && internalValue.length > 0 && "min-h-[250px]";
15427
15647
  let t16;
15428
- if ($[25] !== getInputProps) {
15429
- t16 = getInputProps();
15430
- $[25] = getInputProps;
15648
+ if ($[22] !== t12 || $[23] !== t13 || $[24] !== t14 || $[25] !== t15) {
15649
+ t16 = cls("flex items-center p-1 no-scrollbar", t12, t13, t14, t15);
15650
+ $[22] = t12;
15651
+ $[23] = t13;
15652
+ $[24] = t14;
15653
+ $[25] = t15;
15431
15654
  $[26] = t16;
15432
15655
  } else {
15433
15656
  t16 = $[26];
15434
15657
  }
15435
15658
  let t17;
15436
- if ($[27] !== autoFocus || $[28] !== t16) {
15437
- t17 = /* @__PURE__ */ jsx("input", { autoFocus, ...t16 });
15438
- $[27] = autoFocus;
15439
- $[28] = t16;
15440
- $[29] = t17;
15659
+ if ($[27] !== getInputProps) {
15660
+ t17 = getInputProps();
15661
+ $[27] = getInputProps;
15662
+ $[28] = t17;
15441
15663
  } else {
15442
- t17 = $[29];
15664
+ t17 = $[28];
15443
15665
  }
15444
15666
  let t18;
15445
- if ($[30] !== disabled || $[31] !== internalValue || $[32] !== metadata || $[33] !== name || $[34] !== onClear || $[35] !== onFileUploadComplete || $[36] !== property || $[37] !== size || $[38] !== storagePathBuilder) {
15446
- let t192;
15447
- if ($[40] !== disabled || $[41] !== metadata || $[42] !== name || $[43] !== onClear || $[44] !== onFileUploadComplete || $[45] !== property || $[46] !== size || $[47] !== storagePathBuilder) {
15448
- t192 = (entry, index) => {
15449
- let child;
15450
- if (entry.storagePathOrDownloadUrl) {
15451
- child = /* @__PURE__ */ jsx(StorageItemPreview, { name: `storage_preview_${entry.storagePathOrDownloadUrl}`, property, disabled, value: entry.storagePathOrDownloadUrl, onRemove: onClear, size: entry.size });
15452
- } else {
15453
- if (entry.file) {
15454
- child = /* @__PURE__ */ jsx(StorageUploadProgress, { entry, metadata, storagePath: storagePathBuilder(entry.file), onFileUploadComplete, imageSize: size === "large" ? 220 : 118, simple: false });
15455
- }
15456
- }
15457
- return /* @__PURE__ */ jsx(Draggable, { draggableId: `array_field_${name}_${entry.id}`, index, children: (provided, snapshot) => /* @__PURE__ */ jsx("div", { tabIndex: -1, ref: provided.innerRef, ...provided.draggableProps, ...provided.dragHandleProps, className: cls("rounded-md"), style: {
15458
- ...provided.draggableProps.style
15459
- }, children: child }) }, `array_field_${name}_${entry.id}`);
15460
- };
15461
- $[40] = disabled;
15462
- $[41] = metadata;
15463
- $[42] = name;
15464
- $[43] = onClear;
15465
- $[44] = onFileUploadComplete;
15466
- $[45] = property;
15467
- $[46] = size;
15468
- $[47] = storagePathBuilder;
15469
- $[48] = t192;
15470
- } else {
15471
- t192 = $[48];
15472
- }
15473
- t18 = internalValue.map(t192);
15474
- $[30] = disabled;
15475
- $[31] = internalValue;
15476
- $[32] = metadata;
15477
- $[33] = name;
15478
- $[34] = onClear;
15479
- $[35] = onFileUploadComplete;
15480
- $[36] = property;
15481
- $[37] = size;
15482
- $[38] = storagePathBuilder;
15483
- $[39] = t18;
15484
- } else {
15485
- t18 = $[39];
15667
+ if ($[29] !== autoFocus || $[30] !== t17) {
15668
+ t18 = /* @__PURE__ */ jsx("input", { autoFocus, ...t17 });
15669
+ $[29] = autoFocus;
15670
+ $[30] = t17;
15671
+ $[31] = t18;
15672
+ } else {
15673
+ t18 = $[31];
15486
15674
  }
15487
15675
  let t19;
15488
- if ($[49] !== droppableProvided.droppableProps || $[50] !== droppableProvided.innerRef || $[51] !== droppableProvided.placeholder || $[52] !== t15 || $[53] !== t17 || $[54] !== t18) {
15489
- t19 = /* @__PURE__ */ jsxs("div", { ...t11, ref: t12, className: t15, children: [
15490
- t17,
15676
+ if ($[32] !== disabled || $[33] !== internalValue || $[34] !== metadata || $[35] !== multipleFilesSupported || $[36] !== name || $[37] !== onClear || $[38] !== onFileUploadComplete || $[39] !== property || $[40] !== storagePathBuilder) {
15677
+ let t202;
15678
+ if ($[42] !== disabled || $[43] !== metadata || $[44] !== multipleFilesSupported || $[45] !== name || $[46] !== onClear || $[47] !== onFileUploadComplete || $[48] !== property || $[49] !== storagePathBuilder) {
15679
+ t202 = (entry) => /* @__PURE__ */ jsx(SortableStorageItem, { id: entry.id, entry, property, name, metadata, storagePathBuilder, onFileUploadComplete, onClear, disabled, isSortable: multipleFilesSupported }, entry.id);
15680
+ $[42] = disabled;
15681
+ $[43] = metadata;
15682
+ $[44] = multipleFilesSupported;
15683
+ $[45] = name;
15684
+ $[46] = onClear;
15685
+ $[47] = onFileUploadComplete;
15686
+ $[48] = property;
15687
+ $[49] = storagePathBuilder;
15688
+ $[50] = t202;
15689
+ } else {
15690
+ t202 = $[50];
15691
+ }
15692
+ t19 = internalValue.map(t202);
15693
+ $[32] = disabled;
15694
+ $[33] = internalValue;
15695
+ $[34] = metadata;
15696
+ $[35] = multipleFilesSupported;
15697
+ $[36] = name;
15698
+ $[37] = onClear;
15699
+ $[38] = onFileUploadComplete;
15700
+ $[39] = property;
15701
+ $[40] = storagePathBuilder;
15702
+ $[41] = t19;
15703
+ } else {
15704
+ t19 = $[41];
15705
+ }
15706
+ let t20;
15707
+ if ($[51] !== t16 || $[52] !== t18 || $[53] !== t19) {
15708
+ t20 = /* @__PURE__ */ jsxs("div", { className: t16, children: [
15491
15709
  t18,
15492
- droppableProvided.placeholder
15710
+ t19
15493
15711
  ] });
15494
- $[49] = droppableProvided.droppableProps;
15495
- $[50] = droppableProvided.innerRef;
15496
- $[51] = droppableProvided.placeholder;
15497
- $[52] = t15;
15498
- $[53] = t17;
15499
- $[54] = t18;
15500
- $[55] = t19;
15501
- } else {
15502
- t19 = $[55];
15503
- }
15504
- const t20 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15505
- let t21;
15506
- if ($[56] !== helpText || $[57] !== t20) {
15507
- t21 = /* @__PURE__ */ jsx("div", { className: "flex-grow min-h-[38px] box-border m-2 text-center", children: /* @__PURE__ */ jsx(Typography, { align: "center", variant: "label", className: t20, children: helpText }) });
15508
- $[56] = helpText;
15509
- $[57] = t20;
15510
- $[58] = t21;
15712
+ $[51] = t16;
15713
+ $[52] = t18;
15714
+ $[53] = t19;
15715
+ $[54] = t20;
15511
15716
  } else {
15512
- t21 = $[58];
15717
+ t20 = $[54];
15513
15718
  }
15719
+ const t21 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15514
15720
  let t22;
15515
- if ($[59] !== t10 || $[60] !== t19 || $[61] !== t21 || $[62] !== t5) {
15516
- t22 = /* @__PURE__ */ jsxs("div", { ...t5, className: t10, children: [
15517
- t19,
15518
- t21
15721
+ if ($[55] !== helpText || $[56] !== t21) {
15722
+ t22 = /* @__PURE__ */ jsx("div", { className: "flex-grow min-h-[38px] box-border m-2 text-center", children: /* @__PURE__ */ jsx(Typography, { align: "center", variant: "label", className: t21, children: helpText }) });
15723
+ $[55] = helpText;
15724
+ $[56] = t21;
15725
+ $[57] = t22;
15726
+ } else {
15727
+ t22 = $[57];
15728
+ }
15729
+ let t23;
15730
+ if ($[58] !== t11 || $[59] !== t20 || $[60] !== t22 || $[61] !== t5) {
15731
+ t23 = /* @__PURE__ */ jsxs("div", { ...t5, className: t11, children: [
15732
+ t20,
15733
+ t22
15519
15734
  ] });
15520
- $[59] = t10;
15521
- $[60] = t19;
15522
- $[61] = t21;
15523
- $[62] = t5;
15524
- $[63] = t22;
15735
+ $[58] = t11;
15736
+ $[59] = t20;
15737
+ $[60] = t22;
15738
+ $[61] = t5;
15739
+ $[62] = t23;
15525
15740
  } else {
15526
- t22 = $[63];
15741
+ t23 = $[62];
15527
15742
  }
15528
- return t22;
15743
+ return t23;
15529
15744
  }
15530
- function _temp2$4(a, b) {
15745
+ function _temp2$4(acc, ext) {
15531
15746
  return {
15532
- ...a,
15533
- ...b
15534
- };
15535
- }
15536
- function _temp$a(e) {
15537
- return {
15538
- [e]: []
15747
+ ...acc,
15748
+ [ext]: []
15539
15749
  };
15540
15750
  }
15541
- function StorageUpload({
15542
- property,
15543
- name,
15544
- value,
15545
- setInternalValue,
15546
- onChange,
15547
- multipleFilesSupported,
15548
- onFileUploadComplete,
15549
- disabled,
15550
- onFilesAdded,
15551
- autoFocus,
15552
- storage,
15553
- storagePathBuilder
15554
- }) {
15751
+ function StorageUpload(t0) {
15752
+ const $ = c(44);
15753
+ const {
15754
+ property,
15755
+ name,
15756
+ value,
15757
+ setInternalValue,
15758
+ onChange,
15759
+ multipleFilesSupported,
15760
+ onFileUploadComplete,
15761
+ disabled,
15762
+ onFilesAdded,
15763
+ autoFocus,
15764
+ storage,
15765
+ storagePathBuilder
15766
+ } = t0;
15555
15767
  if (multipleFilesSupported) {
15556
15768
  const arrayProperty = property;
15557
15769
  if (arrayProperty.of) {
@@ -15566,41 +15778,208 @@ function StorageUpload({
15566
15778
  }
15567
15779
  }
15568
15780
  const metadata = storage?.metadata;
15569
- const size = multipleFilesSupported ? "medium" : "large";
15570
- const moveItem = useCallback((fromIndex, toIndex) => {
15571
- if (!multipleFilesSupported) return;
15572
- const newValue = [...value];
15573
- const item = newValue[fromIndex];
15574
- newValue.splice(fromIndex, 1);
15575
- newValue.splice(toIndex, 0, item);
15576
- setInternalValue(newValue);
15577
- const fieldValue = newValue.filter((e) => !!e.storagePathOrDownloadUrl).map((e_0) => e_0.storagePathOrDownloadUrl);
15578
- onChange(fieldValue);
15579
- }, [multipleFilesSupported, onChange, setInternalValue, value]);
15580
- const onDragEnd = useCallback((result) => {
15581
- if (!result.destination) {
15582
- return;
15583
- }
15584
- moveItem(result.source.index, result.destination.index);
15585
- }, [moveItem]);
15586
- const onClear = useCallback((clearedStoragePathOrDownloadUrl) => {
15587
- if (multipleFilesSupported) {
15588
- const newValue_0 = value.filter((v) => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);
15589
- onChange(newValue_0.filter((v_0) => !!v_0.storagePathOrDownloadUrl).map((v_1) => v_1.storagePathOrDownloadUrl));
15781
+ const [isDndItemDragging, setIsDndItemDragging] = useState(false);
15782
+ let t1;
15783
+ if ($[0] !== multipleFilesSupported || $[1] !== onChange || $[2] !== setInternalValue || $[3] !== value) {
15784
+ t1 = (fromIndex, toIndex) => {
15785
+ if (!multipleFilesSupported || fromIndex === toIndex) {
15786
+ return;
15787
+ }
15788
+ const newValue = [...value];
15789
+ const item = newValue[fromIndex];
15790
+ newValue.splice(fromIndex, 1);
15791
+ newValue.splice(toIndex, 0, item);
15792
+ setInternalValue(newValue);
15793
+ const fieldValue = newValue.filter(_temp3$2).map(_temp4$1);
15794
+ onChange(fieldValue);
15795
+ };
15796
+ $[0] = multipleFilesSupported;
15797
+ $[1] = onChange;
15798
+ $[2] = setInternalValue;
15799
+ $[3] = value;
15800
+ $[4] = t1;
15801
+ } else {
15802
+ t1 = $[4];
15803
+ }
15804
+ const moveItem = t1;
15805
+ let t2;
15806
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
15807
+ t2 = {
15808
+ activationConstraint: {
15809
+ distance: 5
15810
+ }
15811
+ };
15812
+ $[5] = t2;
15813
+ } else {
15814
+ t2 = $[5];
15815
+ }
15816
+ let t3;
15817
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
15818
+ t3 = {
15819
+ coordinateGetter: sortableKeyboardCoordinates
15820
+ };
15821
+ $[6] = t3;
15822
+ } else {
15823
+ t3 = $[6];
15824
+ }
15825
+ const sensors = useSensors(useSensor(PointerSensor, t2), useSensor(KeyboardSensor, t3));
15826
+ let t4;
15827
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
15828
+ t4 = (event) => {
15829
+ setIsDndItemDragging(true);
15830
+ };
15831
+ $[7] = t4;
15832
+ } else {
15833
+ t4 = $[7];
15834
+ }
15835
+ const handleDragStart = t4;
15836
+ let t5;
15837
+ if ($[8] !== moveItem || $[9] !== value) {
15838
+ t5 = (event_0) => {
15839
+ setIsDndItemDragging(false);
15840
+ const {
15841
+ active,
15842
+ over
15843
+ } = event_0;
15844
+ if (over && active.id !== over.id) {
15845
+ const oldIndex = value.findIndex((item_0) => item_0.id === active.id);
15846
+ const newIndex = value.findIndex((item_1) => item_1.id === over.id);
15847
+ if (oldIndex !== -1 && newIndex !== -1) {
15848
+ moveItem(oldIndex, newIndex);
15849
+ }
15850
+ }
15851
+ };
15852
+ $[8] = moveItem;
15853
+ $[9] = value;
15854
+ $[10] = t5;
15855
+ } else {
15856
+ t5 = $[10];
15857
+ }
15858
+ const handleDragEnd = t5;
15859
+ let t6;
15860
+ if ($[11] !== multipleFilesSupported || $[12] !== onChange || $[13] !== setInternalValue || $[14] !== value) {
15861
+ t6 = (clearedStoragePathOrDownloadUrl) => {
15862
+ let newValue_0;
15863
+ if (multipleFilesSupported) {
15864
+ newValue_0 = value.filter((v) => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);
15865
+ onChange(newValue_0.filter(_temp5$1).map(_temp6$1));
15866
+ } else {
15867
+ newValue_0 = [];
15868
+ onChange(null);
15869
+ }
15590
15870
  setInternalValue(newValue_0);
15871
+ };
15872
+ $[11] = multipleFilesSupported;
15873
+ $[12] = onChange;
15874
+ $[13] = setInternalValue;
15875
+ $[14] = value;
15876
+ $[15] = t6;
15877
+ } else {
15878
+ t6 = $[15];
15879
+ }
15880
+ const onClear = t6;
15881
+ const helpText = multipleFilesSupported ? "Drag 'n' drop some files here, or click to select files. Drag to reorder." : "Drag 'n' drop a file here, or click to select one";
15882
+ const renderProperty = multipleFilesSupported ? property.of : property;
15883
+ let t7;
15884
+ if ($[16] !== autoFocus || $[17] !== disabled || $[18] !== helpText || $[19] !== isDndItemDragging || $[20] !== metadata || $[21] !== multipleFilesSupported || $[22] !== name || $[23] !== onClear || $[24] !== onFileUploadComplete || $[25] !== onFilesAdded || $[26] !== renderProperty || $[27] !== storage || $[28] !== storagePathBuilder || $[29] !== value) {
15885
+ t7 = {
15886
+ storage,
15887
+ disabled,
15888
+ onFilesAdded,
15889
+ multipleFilesSupported,
15890
+ autoFocus,
15891
+ internalValue: value,
15892
+ property: renderProperty,
15893
+ onClear,
15894
+ metadata,
15895
+ storagePathBuilder,
15896
+ onFileUploadComplete,
15897
+ name,
15898
+ helpText,
15899
+ isDndItemDragging
15900
+ };
15901
+ $[16] = autoFocus;
15902
+ $[17] = disabled;
15903
+ $[18] = helpText;
15904
+ $[19] = isDndItemDragging;
15905
+ $[20] = metadata;
15906
+ $[21] = multipleFilesSupported;
15907
+ $[22] = name;
15908
+ $[23] = onClear;
15909
+ $[24] = onFileUploadComplete;
15910
+ $[25] = onFilesAdded;
15911
+ $[26] = renderProperty;
15912
+ $[27] = storage;
15913
+ $[28] = storagePathBuilder;
15914
+ $[29] = value;
15915
+ $[30] = t7;
15916
+ } else {
15917
+ t7 = $[30];
15918
+ }
15919
+ const fileDropProps = t7;
15920
+ if (multipleFilesSupported) {
15921
+ let t8;
15922
+ if ($[31] !== value) {
15923
+ t8 = value.map(_temp7);
15924
+ $[31] = value;
15925
+ $[32] = t8;
15591
15926
  } else {
15592
- onChange(null);
15593
- setInternalValue([]);
15927
+ t8 = $[32];
15594
15928
  }
15595
- }, [value, multipleFilesSupported, onChange]);
15596
- const helpText = multipleFilesSupported ? "Drag 'n' drop some files here, or click to select files" : "Drag 'n' drop a file here, or click to select one";
15597
- const renderProperty = multipleFilesSupported ? property.of : property;
15598
- return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId: `droppable_${name}`, direction: "horizontal", renderClone: (provided, snapshot, rubric) => {
15599
- const entry = value[rubric.source.index];
15600
- return /* @__PURE__ */ jsx("div", { ref: provided.innerRef, ...provided.draggableProps, ...provided.dragHandleProps, style: provided.draggableProps.style, className: "rounded", children: /* @__PURE__ */ jsx(StorageItemPreview, { name: `storage_preview_${entry.storagePathOrDownloadUrl}`, placeholder: true, property: renderProperty, disabled: true, value: entry.storagePathOrDownloadUrl, onRemove: onClear, size: entry.size }) });
15601
- }, children: (provided_0, snapshot_0) => {
15602
- return /* @__PURE__ */ jsx(FileDropComponent, { storage, disabled, isDraggingOver: snapshot_0.isDraggingOver, droppableProvided: provided_0, onFilesAdded, multipleFilesSupported, autoFocus, internalValue: value, property: renderProperty, onClear, metadata, storagePathBuilder, onFileUploadComplete, size, name, helpText });
15603
- } }) });
15929
+ let t9;
15930
+ if ($[33] !== fileDropProps) {
15931
+ t9 = /* @__PURE__ */ jsx(FileDropComponent, { ...fileDropProps });
15932
+ $[33] = fileDropProps;
15933
+ $[34] = t9;
15934
+ } else {
15935
+ t9 = $[34];
15936
+ }
15937
+ let t10;
15938
+ if ($[35] !== t8 || $[36] !== t9) {
15939
+ t10 = /* @__PURE__ */ jsx(SortableContext, { items: t8, strategy: horizontalListSortingStrategy, children: t9 });
15940
+ $[35] = t8;
15941
+ $[36] = t9;
15942
+ $[37] = t10;
15943
+ } else {
15944
+ t10 = $[37];
15945
+ }
15946
+ let t11;
15947
+ if ($[38] !== handleDragEnd || $[39] !== sensors || $[40] !== t10) {
15948
+ t11 = /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: t10 });
15949
+ $[38] = handleDragEnd;
15950
+ $[39] = sensors;
15951
+ $[40] = t10;
15952
+ $[41] = t11;
15953
+ } else {
15954
+ t11 = $[41];
15955
+ }
15956
+ return t11;
15957
+ } else {
15958
+ let t8;
15959
+ if ($[42] !== fileDropProps) {
15960
+ t8 = /* @__PURE__ */ jsx(FileDropComponent, { ...fileDropProps, isDndItemDragging: false });
15961
+ $[42] = fileDropProps;
15962
+ $[43] = t8;
15963
+ } else {
15964
+ t8 = $[43];
15965
+ }
15966
+ return t8;
15967
+ }
15968
+ }
15969
+ function _temp7(v_2) {
15970
+ return v_2.id;
15971
+ }
15972
+ function _temp6$1(v_1) {
15973
+ return v_1.storagePathOrDownloadUrl;
15974
+ }
15975
+ function _temp5$1(v_0) {
15976
+ return !!v_0.storagePathOrDownloadUrl;
15977
+ }
15978
+ function _temp4$1(e_0) {
15979
+ return e_0.storagePathOrDownloadUrl;
15980
+ }
15981
+ function _temp3$2(e) {
15982
+ return !!e.storagePathOrDownloadUrl;
15604
15983
  }
15605
15984
  function TextFieldBinding(t0) {
15606
15985
  const $ = c(52);
@@ -16419,6 +16798,7 @@ function MapFieldBinding(t0) {
16419
16798
  error,
16420
16799
  disabled,
16421
16800
  property,
16801
+ partOfArray,
16422
16802
  minimalistView: minimalistViewProp,
16423
16803
  includeDescription,
16424
16804
  autoFocus,
@@ -16543,7 +16923,7 @@ function MapFieldBinding(t0) {
16543
16923
  }
16544
16924
  const t6 = minimalistView && mapFormView;
16545
16925
  const t7 = showError ?? false;
16546
- const t8 = error ? typeof error === "string" ? error : "A property of this map has an error" : void 0;
16926
+ const t8 = error && !partOfArray ? typeof error === "string" ? error : "A property of this map has an error" : void 0;
16547
16927
  let t9;
16548
16928
  if ($[31] !== disabled || $[32] !== includeDescription || $[33] !== property || $[34] !== t7 || $[35] !== t8) {
16549
16929
  t9 = /* @__PURE__ */ jsx(FieldHelperText, { includeDescription, showError: t7, error: t8, disabled, property });
@@ -17394,6 +17774,7 @@ function RepeatFieldBinding(t0) {
17394
17774
  minimalistView: false,
17395
17775
  autoFocus: internalId === lastAddedId
17396
17776
  };
17777
+ console.debug("Building entry for", index, fieldProps);
17397
17778
  return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(PropertyFieldBinding, { ...fieldProps, index }) });
17398
17779
  };
17399
17780
  $[4] = context;
@@ -18030,7 +18411,7 @@ function PopupFormField(props) {
18030
18411
  return t0;
18031
18412
  }
18032
18413
  function PopupFormFieldLoading(t0) {
18033
- const $ = c(23);
18414
+ const $ = c(21);
18034
18415
  const {
18035
18416
  tableKey,
18036
18417
  entityId,
@@ -18047,6 +18428,7 @@ function PopupFormFieldLoading(t0) {
18047
18428
  const dataSource = useDataSource();
18048
18429
  const [entity, setEntity] = useState(void 0);
18049
18430
  let t1;
18431
+ let t2;
18050
18432
  if ($[0] !== dataSource || $[1] !== entityId || $[2] !== inputCollection || $[3] !== path) {
18051
18433
  t1 = () => {
18052
18434
  if (entityId && inputCollection) {
@@ -18057,29 +18439,23 @@ function PopupFormFieldLoading(t0) {
18057
18439
  }).then(setEntity);
18058
18440
  }
18059
18441
  };
18442
+ t2 = [entityId, inputCollection, dataSource, path];
18060
18443
  $[0] = dataSource;
18061
18444
  $[1] = entityId;
18062
18445
  $[2] = inputCollection;
18063
18446
  $[3] = path;
18064
18447
  $[4] = t1;
18448
+ $[5] = t2;
18065
18449
  } else {
18066
18450
  t1 = $[4];
18067
- }
18068
- let t2;
18069
- if ($[5] !== entityId || $[6] !== inputCollection) {
18070
- t2 = [entityId, inputCollection];
18071
- $[5] = entityId;
18072
- $[6] = inputCollection;
18073
- $[7] = t2;
18074
- } else {
18075
- t2 = $[7];
18451
+ t2 = $[5];
18076
18452
  }
18077
18453
  useEffect(t1, t2);
18078
18454
  if (!entity) {
18079
18455
  return null;
18080
18456
  }
18081
18457
  let t3;
18082
- if ($[8] !== cellRect || $[9] !== container || $[10] !== customFieldValidator || $[11] !== entityId || $[12] !== inputCollection || $[13] !== onCellValueChange || $[14] !== onClose || $[15] !== open || $[16] !== path || $[17] !== propertyKey || $[18] !== tableKey) {
18458
+ if ($[6] !== cellRect || $[7] !== container || $[8] !== customFieldValidator || $[9] !== entityId || $[10] !== inputCollection || $[11] !== onCellValueChange || $[12] !== onClose || $[13] !== open || $[14] !== path || $[15] !== propertyKey || $[16] !== tableKey) {
18083
18459
  t3 = {
18084
18460
  tableKey,
18085
18461
  entityId,
@@ -18093,29 +18469,29 @@ function PopupFormFieldLoading(t0) {
18093
18469
  onCellValueChange,
18094
18470
  container
18095
18471
  };
18096
- $[8] = cellRect;
18097
- $[9] = container;
18098
- $[10] = customFieldValidator;
18099
- $[11] = entityId;
18100
- $[12] = inputCollection;
18101
- $[13] = onCellValueChange;
18102
- $[14] = onClose;
18103
- $[15] = open;
18104
- $[16] = path;
18105
- $[17] = propertyKey;
18106
- $[18] = tableKey;
18107
- $[19] = t3;
18472
+ $[6] = cellRect;
18473
+ $[7] = container;
18474
+ $[8] = customFieldValidator;
18475
+ $[9] = entityId;
18476
+ $[10] = inputCollection;
18477
+ $[11] = onCellValueChange;
18478
+ $[12] = onClose;
18479
+ $[13] = open;
18480
+ $[14] = path;
18481
+ $[15] = propertyKey;
18482
+ $[16] = tableKey;
18483
+ $[17] = t3;
18108
18484
  } else {
18109
- t3 = $[19];
18485
+ t3 = $[17];
18110
18486
  }
18111
18487
  let t4;
18112
- if ($[20] !== entity || $[21] !== t3) {
18488
+ if ($[18] !== entity || $[19] !== t3) {
18113
18489
  t4 = /* @__PURE__ */ jsx(PopupFormFieldInternal, { ...t3, entity });
18114
- $[20] = entity;
18115
- $[21] = t3;
18116
- $[22] = t4;
18490
+ $[18] = entity;
18491
+ $[19] = t3;
18492
+ $[20] = t4;
18117
18493
  } else {
18118
- t4 = $[22];
18494
+ t4 = $[20];
18119
18495
  }
18120
18496
  return t4;
18121
18497
  }
@@ -18157,23 +18533,26 @@ function PopupFormFieldInternal({
18157
18533
  y: cellRect.top < windowSize.height - cellRect.bottom ? cellRect.y + cellRect.height / 2 : cellRect.y - cellRect.height / 2
18158
18534
  };
18159
18535
  }, [cellRect, windowSize.height, windowSize.width]);
18160
- const normalizePosition = useCallback(({
18161
- x,
18162
- y
18163
- }) => {
18164
- const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();
18165
- if (!draggableBoundingRect) throw Error("normalizePosition called before draggableBoundingRect is set");
18536
+ const normalizePosition = useCallback((pos, draggableBoundingRect, currentWindowSize) => {
18537
+ if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {
18538
+ return pos;
18539
+ }
18166
18540
  return {
18167
- x: Math.max(0, Math.min(x, windowSize.width - draggableBoundingRect.width)),
18168
- y: Math.max(0, Math.min(y, windowSize.height - draggableBoundingRect.height))
18541
+ x: Math.max(0, Math.min(pos.x, currentWindowSize.width - draggableBoundingRect.width)),
18542
+ y: Math.max(0, Math.min(pos.y, currentWindowSize.height - draggableBoundingRect.height))
18169
18543
  };
18170
- }, [windowSize]);
18171
- const updatePopupLocation = useCallback((position) => {
18544
+ }, []);
18545
+ const updatePopupLocation = useCallback((newPositionCandidate) => {
18172
18546
  const draggableBoundingRect_0 = draggableRef.current?.getBoundingClientRect();
18173
- if (!cellRect || !draggableBoundingRect_0) return;
18174
- const newPosition = position ?? normalizePosition(getInitialLocation());
18175
- if (!popupLocation || newPosition.x !== popupLocation.x || newPosition.y !== popupLocation.y) setPopupLocation(newPosition);
18176
- }, [cellRect, getInitialLocation, normalizePosition, popupLocation]);
18547
+ if (!cellRect || !draggableBoundingRect_0 || draggableBoundingRect_0.width === 0 || draggableBoundingRect_0.height === 0) {
18548
+ return;
18549
+ }
18550
+ const basePosition = newPositionCandidate ?? getInitialLocation();
18551
+ const newNormalizedPosition = normalizePosition(basePosition, draggableBoundingRect_0, windowSize);
18552
+ if (!popupLocation || newNormalizedPosition.x !== popupLocation.x || newNormalizedPosition.y !== popupLocation.y) {
18553
+ setPopupLocation(newNormalizedPosition);
18554
+ }
18555
+ }, [cellRect, getInitialLocation, normalizePosition, popupLocation, windowSize]);
18177
18556
  useDraggable({
18178
18557
  containerRef: draggableRef,
18179
18558
  innerRef,
@@ -18184,15 +18563,22 @@ function PopupFormFieldInternal({
18184
18563
  useEffect(() => {
18185
18564
  initialPositionSet.current = false;
18186
18565
  }, [propertyKey, entity]);
18187
- useLayoutEffect(() => {
18188
- const draggableBoundingRect_1 = draggableRef.current?.getBoundingClientRect();
18189
- if (!cellRect || !draggableBoundingRect_1 || initialPositionSet.current) return;
18190
- updatePopupLocation();
18191
- initialPositionSet.current = true;
18192
- }, [cellRect, updatePopupLocation, initialPositionSet.current]);
18566
+ useLayoutEffect(
18567
+ () => {
18568
+ if (!cellRect || initialPositionSet.current) return;
18569
+ const draggableBoundingRect_1 = draggableRef.current?.getBoundingClientRect();
18570
+ if (!draggableBoundingRect_1 || draggableBoundingRect_1.width === 0 || draggableBoundingRect_1.height === 0) {
18571
+ return;
18572
+ }
18573
+ updatePopupLocation();
18574
+ initialPositionSet.current = true;
18575
+ },
18576
+ [cellRect, updatePopupLocation]
18577
+ // Removed initialPositionSet.current from deps as it's a ref
18578
+ );
18193
18579
  useLayoutEffect(() => {
18194
18580
  updatePopupLocation(popupLocation);
18195
- }, [windowSize, cellRect]);
18581
+ }, [windowSize, cellRect, updatePopupLocation, popupLocation]);
18196
18582
  const validationSchema = useMemo(() => {
18197
18583
  if (!collection || !entityId) return;
18198
18584
  return getYupEntitySchema(entityId, propertyKey && collection.properties[propertyKey] ? {
@@ -18202,6 +18588,18 @@ function PopupFormFieldInternal({
18202
18588
  const adaptResize = useCallback(() => {
18203
18589
  return updatePopupLocation(popupLocation);
18204
18590
  }, [popupLocation, updatePopupLocation]);
18591
+ useEffect(() => {
18592
+ const element = draggableRef.current;
18593
+ if (!element) return;
18594
+ const observer = new ResizeObserver(() => {
18595
+ adaptResize();
18596
+ });
18597
+ observer.observe(element);
18598
+ return () => {
18599
+ observer.unobserve(element);
18600
+ observer.disconnect();
18601
+ };
18602
+ }, [adaptResize, draggableRef]);
18205
18603
  const saveValue = async (values) => {
18206
18604
  setSavingError(null);
18207
18605
  if (inputCollection && entity && onCellValueChange && propertyKey) {
@@ -18261,7 +18659,7 @@ function PopupFormFieldInternal({
18261
18659
  underlyingValueHasChanged: false,
18262
18660
  context: formContext,
18263
18661
  partOfArray: false,
18264
- minimalistView: false,
18662
+ minimalistView: true,
18265
18663
  autoFocus: open
18266
18664
  } : void 0;
18267
18665
  let internalForm = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "w-[700px] max-w-full max-h-[85vh]", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [
@@ -18282,21 +18680,18 @@ function PopupFormFieldInternal({
18282
18680
  internalForm,
18283
18681
  savingError && /* @__PURE__ */ jsx(Typography, { color: "error", children: savingError.message })
18284
18682
  ] });
18285
- const draggable = /* @__PURE__ */ jsxs("div", { style: {
18683
+ const draggable = /* @__PURE__ */ jsx("div", { style: {
18286
18684
  boxShadow: "0 0 0 2px rgba(128,128,128,0.2)"
18287
- }, className: `inline-block fixed z-20 shadow-outline rounded-md bg-white dark:bg-surface-950 ${!open ? "invisible" : "visible"} cursor-grab overflow-visible`, ref: draggableRef, children: [
18288
- /* @__PURE__ */ jsx(ElementResizeListener, { onResize: adaptResize }),
18289
- /* @__PURE__ */ jsxs("div", { className: "overflow-hidden", children: [
18290
- form,
18291
- /* @__PURE__ */ jsx("div", { className: "absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full", style: {
18292
- width: "32px",
18293
- height: "32px"
18294
- }, children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (event) => {
18295
- event.stopPropagation();
18296
- onClose();
18297
- }, children: /* @__PURE__ */ jsx(CloseIcon, { className: "text-white", size: "small" }) }) })
18298
- ] })
18299
- ] }, `draggable_${propertyKey}_${entityId}_${open}`);
18685
+ }, className: `inline-block fixed z-20 shadow-outline rounded-md bg-white dark:bg-surface-950 ${!open ? "invisible" : "visible"} cursor-grab overflow-visible`, ref: draggableRef, children: /* @__PURE__ */ jsxs("div", { className: "overflow-hidden", children: [
18686
+ form,
18687
+ /* @__PURE__ */ jsx("div", { className: "absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full", style: {
18688
+ width: "32px",
18689
+ height: "32px"
18690
+ }, children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (event) => {
18691
+ event.stopPropagation();
18692
+ onClose();
18693
+ }, children: /* @__PURE__ */ jsx(CloseIcon, { className: "text-white", size: "small" }) }) })
18694
+ ] }) }, `draggable_${propertyKey}_${entityId}_${open}`);
18300
18695
  return /* @__PURE__ */ jsx(Portal.Root, { asChild: true, container, children: /* @__PURE__ */ jsx(Formex, { value: formex, children: draggable }) });
18301
18696
  }
18302
18697
  function ClearFilterSortButton(t0) {
@@ -18313,7 +18708,7 @@ function ClearFilterSortButton(t0) {
18313
18708
  if ((filterIsSet || sortIsSet) && (tableController.clearFilter || tableController.setSortBy)) {
18314
18709
  let label;
18315
18710
  if (filterIsSet && sortIsSet) {
18316
- label = "Clear filter and sort";
18711
+ label = "Clear filter/sort";
18317
18712
  } else {
18318
18713
  if (filterIsSet) {
18319
18714
  label = "Clear filter";
@@ -18691,7 +19086,7 @@ const EntityCollectionView = React__default.memo(function EntityCollectionView2(
18691
19086
  dependencies: [],
18692
19087
  Builder: ({
18693
19088
  entity: entity_3
18694
- }) => /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", startIcon: /* @__PURE__ */ jsx(KeyboardTabIcon, { size: "small" }), onClick: (event) => {
19089
+ }) => /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", className: "max-w-full truncate justify-start", startIcon: /* @__PURE__ */ jsx(KeyboardTabIcon, { size: "small" }), onClick: (event) => {
18695
19090
  event.stopPropagation();
18696
19091
  navigateToEntity({
18697
19092
  openEntityMode,
@@ -18802,7 +19197,7 @@ const EntityCollectionView = React__default.memo(function EntityCollectionView2(
18802
19197
  deleteEntityClicked && /* @__PURE__ */ jsx(DeleteEntityDialog, { entityOrEntitiesToDelete: deleteEntityClicked, path: fullPath, collection, callbacks: collection.callbacks, open: Boolean(deleteEntityClicked), onEntityDelete: internalOnEntityDelete, onMultipleEntitiesDelete: internalOnMultipleEntitiesDelete, onClose: () => setDeleteEntityClicked(void 0) })
18803
19198
  ] });
18804
19199
  }, (a, b) => {
18805
- return equal(a.path, b.path) && equal(a.parentCollectionIds, b.parentCollectionIds) && equal(a.isSubCollection, b.isSubCollection) && equal(a.className, b.className) && equal(a.properties, b.properties) && equal(a.propertiesOrder, b.propertiesOrder) && equal(a.hideIdFromCollection, b.hideIdFromCollection) && equal(a.inlineEditing, b.inlineEditing) && equal(a.selectionEnabled, b.selectionEnabled) && equal(a.selectionController, b.selectionController) && equal(a.Actions, b.Actions) && equal(a.defaultSize, b.defaultSize) && equal(a.initialFilter, b.initialFilter) && equal(a.initialSort, b.initialSort) && equal(a.textSearchEnabled, b.textSearchEnabled) && equal(a.additionalFields, b.additionalFields) && equal(a.sideDialogWidth, b.sideDialogWidth) && equal(a.openEntityMode, b.openEntityMode) && equal(a.forceFilter, b.forceFilter);
19200
+ return equal(a.path, b.path) && equal(a.parentCollectionIds, b.parentCollectionIds) && equal(a.isSubCollection, b.isSubCollection) && equal(a.className, b.className) && equal(a.properties, b.properties) && equal(a.propertiesOrder, b.propertiesOrder) && equal(a.hideIdFromCollection, b.hideIdFromCollection) && equal(a.inlineEditing, b.inlineEditing) && equal(a.selectionEnabled, b.selectionEnabled) && equal(a.selectionController, b.selectionController) && equal(a.Actions, b.Actions) && equal(a.defaultSize, b.defaultSize) && equal(a.initialFilter, b.initialFilter) && equal(a.initialSort, b.initialSort) && equal(a.includeJsonView, b.includeJsonView) && equal(a.textSearchEnabled, b.textSearchEnabled) && equal(a.additionalFields, b.additionalFields) && equal(a.sideDialogWidth, b.sideDialogWidth) && equal(a.openEntityMode, b.openEntityMode) && equal(a.exportable, b.exportable) && equal(a.history, b.history) && equal(a.forceFilter, b.forceFilter);
18806
19201
  });
18807
19202
  function EntitiesCount({
18808
19203
  fullPath,
@@ -19121,7 +19516,7 @@ function ConfirmationDialog(t0) {
19121
19516
  }
19122
19517
  let t5;
19123
19518
  if ($[8] !== loading || $[9] !== onAccept) {
19124
- t5 = /* @__PURE__ */ jsx(LoadingButton, { color: "primary", type: "submit", loading, onClick: onAccept, children: "Ok" });
19519
+ t5 = /* @__PURE__ */ jsx(LoadingButton, { color: "primary", type: "submit", loading, onClick: onAccept, autoFocus: true, children: "Ok" });
19125
19520
  $[8] = loading;
19126
19521
  $[9] = onAccept;
19127
19522
  $[10] = t5;
@@ -19533,227 +19928,182 @@ const buildIdsMap = (value) => value && Array.isArray(value) && value.length > 0
19533
19928
  ...a,
19534
19929
  ...b
19535
19930
  }), {}) : {};
19536
- function ArrayContainer({
19537
- droppableId,
19538
- addLabel,
19539
- value,
19540
- disabled = false,
19931
+ function SortableItem({
19932
+ id,
19933
+ index,
19934
+ size,
19935
+ disabled,
19541
19936
  buildEntry,
19542
- size = "medium",
19543
- onInternalIdAdded,
19544
- includeAddButton: deprecatedIncludeAddButton,
19545
- canAddElements: canAddElementsProp = true,
19546
- sortable = true,
19547
- newDefaultEntry,
19548
- onValueChange,
19549
- className,
19550
- min = 0,
19551
- max = Infinity
19937
+ remove,
19938
+ copy,
19939
+ addInIndex,
19940
+ canAddElements,
19941
+ sortable,
19942
+ storedProps,
19943
+ updateItemCustomProps
19552
19944
  }) {
19553
- const canAddElements = (canAddElementsProp || canAddElementsProp === void 0) && (deprecatedIncludeAddButton === void 0 || deprecatedIncludeAddButton);
19554
- const hasValue = value && Array.isArray(value) && value.length > 0;
19555
- const internalIdsRef = useRef(buildIdsMap(value));
19556
- const [internalIds, setInternalIds] = useState(hasValue ? Object.values(internalIdsRef.current) : []);
19557
- const itemCustomPropsRef = useRef({});
19558
- const updateItemCustomProps = useCallback((internalId, customProps) => {
19559
- itemCustomPropsRef.current[internalId] = customProps;
19560
- }, []);
19561
- useEffect(() => {
19562
- if (hasValue && value && value.length !== internalIds.length) {
19563
- const newInternalIds = value.map((v, index) => {
19564
- const hashValue = getHashValue(v) + index;
19565
- if (hashValue in internalIdsRef.current) {
19566
- return internalIdsRef.current[hashValue];
19567
- } else {
19568
- const newInternalId = getRandomId();
19569
- internalIdsRef.current[hashValue] = newInternalId;
19570
- return newInternalId;
19571
- }
19572
- });
19573
- setInternalIds(newInternalIds);
19574
- }
19575
- }, [hasValue, internalIds.length, value]);
19576
- const insertInEnd = (e) => {
19577
- e.preventDefault();
19578
- if (disabled || (value ?? []).length >= max) return;
19579
- const id = getRandomId();
19580
- const newIds = [...internalIds, id];
19581
- if (onInternalIdAdded) onInternalIdAdded(id);
19582
- setInternalIds(newIds);
19583
- onValueChange([...value ?? [], newDefaultEntry]);
19584
- };
19585
- const remove = (index_0) => {
19586
- if ((value ?? []).length <= min) return;
19587
- const newIds_0 = [...internalIds];
19588
- newIds_0.splice(index_0, 1);
19589
- setInternalIds(newIds_0);
19590
- onValueChange(value.filter((_, i) => i !== index_0));
19591
- };
19592
- const copy = (index_1) => {
19593
- if ((value ?? []).length >= max) return;
19594
- const id_0 = getRandomId();
19595
- const copyingItem = value[index_1];
19596
- const newIds_1 = [...internalIds.slice(0, index_1 + 1), id_0, ...internalIds.slice(index_1 + 1)];
19597
- if (onInternalIdAdded) onInternalIdAdded(id_0);
19598
- setInternalIds(newIds_1);
19599
- onValueChange([...value.slice(0, index_1 + 1), copyingItem, ...value.slice(index_1 + 1)]);
19600
- };
19601
- const addInIndex = (index_2) => {
19602
- if ((value ?? []).length >= max) return;
19603
- const id_1 = getRandomId();
19604
- const newIds_2 = [...internalIds.slice(0, index_2), id_1, ...internalIds.slice(index_2)];
19605
- if (onInternalIdAdded) onInternalIdAdded(id_1);
19606
- setInternalIds(newIds_2);
19607
- onValueChange([...value.slice(0, index_2), newDefaultEntry, ...value.slice(index_2)]);
19608
- };
19609
- const onDragEnd = (result) => {
19610
- if (!result.destination) {
19611
- return;
19612
- }
19613
- const sourceIndex = result.source.index;
19614
- const destinationIndex = result.destination.index;
19615
- const newIds_3 = [...internalIds];
19616
- const temp = newIds_3[sourceIndex];
19617
- newIds_3[sourceIndex] = newIds_3[destinationIndex];
19618
- newIds_3[destinationIndex] = temp;
19619
- setInternalIds(newIds_3);
19620
- onValueChange(arrayMove(value, sourceIndex, destinationIndex));
19945
+ const {
19946
+ attributes,
19947
+ listeners: listeners2,
19948
+ setNodeRef,
19949
+ transform,
19950
+ transition,
19951
+ isDragging
19952
+ } = sortable ? useSortable({
19953
+ id
19954
+ }) : {
19955
+ attributes: {},
19956
+ listeners: {},
19957
+ setNodeRef: (node) => {
19958
+ },
19959
+ transform: null,
19960
+ transition: void 0,
19961
+ isDragging: false
19621
19962
  };
19622
- return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId, renderClone: (provided, snapshot, rubric) => {
19623
- const index_3 = rubric.source.index;
19624
- const internalId_0 = internalIds[index_3];
19625
- return /* @__PURE__ */ jsx(ArrayContainerItem, { provided, internalId: internalId_0, index: index_3, size, disabled, buildEntry, remove, copy, isDragging: snapshot.isDragging, storedProps: itemCustomPropsRef.current[internalId_0], updateItemCustomProps, addInIndex, canAddElements, sortable });
19626
- }, children: (droppableProvided, droppableSnapshot) => /* @__PURE__ */ jsxs("div", { className: cls("space-y-1", className), ...droppableProvided.droppableProps, ref: droppableProvided.innerRef, children: [
19627
- hasValue && internalIds.map((internalId_1, index_4) => {
19628
- return /* @__PURE__ */ jsx(Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled || !sortable, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsx(ArrayContainerItem, { provided: provided_0, internalId: internalId_1, index: index_4, size, disabled, buildEntry, remove, copy, isDragging: snapshot_0.isDragging, storedProps: itemCustomPropsRef.current[internalId_1], updateItemCustomProps, addInIndex, canAddElements, sortable }) }, `array_field_${internalId_1}`);
19629
- }),
19630
- droppableProvided.placeholder,
19631
- canAddElements && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value?.length >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
19632
- ] }) }) });
19963
+ const style = transform ? {
19964
+ transform: CSS.Transform.toString(transform),
19965
+ transition
19966
+ } : {};
19967
+ const dragHandleProps = sortable ? {
19968
+ ...listeners2,
19969
+ ...attributes
19970
+ } : {};
19971
+ return /* @__PURE__ */ jsx(ArrayContainerItem, { nodeRef: setNodeRef, style, dragHandleProps, internalId: id, index, size, disabled, buildEntry, remove, copy, addInIndex, canAddElements, sortable, isDragging, storedProps, updateItemCustomProps });
19633
19972
  }
19634
19973
  function ArrayContainerItem(t0) {
19635
19974
  const $ = c(30);
19636
19975
  const {
19637
- provided,
19976
+ nodeRef,
19977
+ style,
19978
+ dragHandleProps,
19638
19979
  index,
19639
19980
  internalId,
19640
19981
  size,
19641
19982
  disabled,
19642
19983
  buildEntry,
19643
19984
  remove,
19985
+ copy,
19644
19986
  addInIndex,
19645
19987
  canAddElements,
19646
19988
  sortable,
19647
- copy,
19648
19989
  isDragging,
19649
19990
  storedProps,
19650
19991
  updateItemCustomProps
19651
19992
  } = t0;
19652
- const t1 = provided.innerRef;
19653
- const t2 = provided.draggableProps;
19654
- const t3 = provided.draggableProps.style;
19655
- const t4 = `relative ${!isDragging ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 dark:hover:bg-opacity-20" : ""} rounded-md opacity-100`;
19656
- let t5;
19993
+ const t1 = `relative ${!isDragging ? "hover\\:bg-surface-accent-50 dark\\:hover\\:bg-surface-800 dark\\:hover\\:bg-opacity-20" : ""} rounded-md opacity-100`;
19994
+ let t2;
19657
19995
  if ($[0] !== internalId || $[1] !== updateItemCustomProps) {
19658
- t5 = (props) => updateItemCustomProps(internalId, props);
19996
+ t2 = (props) => updateItemCustomProps(internalId, props);
19659
19997
  $[0] = internalId;
19660
19998
  $[1] = updateItemCustomProps;
19661
- $[2] = t5;
19999
+ $[2] = t2;
19662
20000
  } else {
19663
- t5 = $[2];
20001
+ t2 = $[2];
19664
20002
  }
19665
- let t6;
19666
- if ($[3] !== buildEntry || $[4] !== index || $[5] !== internalId || $[6] !== isDragging || $[7] !== storedProps || $[8] !== t5) {
19667
- t6 = buildEntry({
20003
+ let t3;
20004
+ if ($[3] !== buildEntry || $[4] !== index || $[5] !== internalId || $[6] !== isDragging || $[7] !== storedProps || $[8] !== t2) {
20005
+ t3 = buildEntry({
19668
20006
  index,
19669
20007
  internalId,
19670
20008
  isDragging,
19671
20009
  storedProps,
19672
- storeProps: t5
20010
+ storeProps: t2
19673
20011
  });
19674
20012
  $[3] = buildEntry;
19675
20013
  $[4] = index;
19676
20014
  $[5] = internalId;
19677
20015
  $[6] = isDragging;
19678
20016
  $[7] = storedProps;
19679
- $[8] = t5;
19680
- $[9] = t6;
20017
+ $[8] = t2;
20018
+ $[9] = t3;
19681
20019
  } else {
19682
- t6 = $[9];
20020
+ t3 = $[9];
19683
20021
  }
19684
- let t7;
19685
- if ($[10] !== t6) {
19686
- t7 = /* @__PURE__ */ jsx("div", { className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark", children: t6 });
19687
- $[10] = t6;
19688
- $[11] = t7;
20022
+ let t4;
20023
+ if ($[10] !== t3) {
20024
+ t4 = /* @__PURE__ */ jsx("div", { className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark", children: t3 });
20025
+ $[10] = t3;
20026
+ $[11] = t4;
19689
20027
  } else {
19690
- t7 = $[11];
20028
+ t4 = $[11];
19691
20029
  }
19692
- const t8 = size === "small" ? "row" : "column";
19693
- let t9;
19694
- if ($[12] !== addInIndex || $[13] !== canAddElements || $[14] !== copy || $[15] !== disabled || $[16] !== index || $[17] !== provided || $[18] !== remove || $[19] !== sortable || $[20] !== t8) {
19695
- t9 = /* @__PURE__ */ jsx(ArrayItemOptions, { direction: t8, disabled, remove, index, provided, addInIndex, canAddElements, sortable, copy });
20030
+ const t5 = size === "small" ? "row" : "column";
20031
+ let t6;
20032
+ if ($[12] !== addInIndex || $[13] !== canAddElements || $[14] !== copy || $[15] !== disabled || $[16] !== dragHandleProps || $[17] !== index || $[18] !== remove || $[19] !== sortable || $[20] !== t5) {
20033
+ t6 = /* @__PURE__ */ jsx(ArrayItemOptions, { dragHandleProps, direction: t5, disabled, remove, index, copy, canAddElements, sortable, addInIndex });
19696
20034
  $[12] = addInIndex;
19697
20035
  $[13] = canAddElements;
19698
20036
  $[14] = copy;
19699
20037
  $[15] = disabled;
19700
- $[16] = index;
19701
- $[17] = provided;
20038
+ $[16] = dragHandleProps;
20039
+ $[17] = index;
19702
20040
  $[18] = remove;
19703
20041
  $[19] = sortable;
19704
- $[20] = t8;
19705
- $[21] = t9;
20042
+ $[20] = t5;
20043
+ $[21] = t6;
19706
20044
  } else {
19707
- t9 = $[21];
20045
+ t6 = $[21];
19708
20046
  }
19709
- let t10;
19710
- if ($[22] !== t7 || $[23] !== t9) {
19711
- t10 = /* @__PURE__ */ jsxs("div", { className: "flex items-start", children: [
19712
- t7,
19713
- t9
20047
+ let t7;
20048
+ if ($[22] !== t4 || $[23] !== t6) {
20049
+ t7 = /* @__PURE__ */ jsxs("div", { className: "flex items-start", children: [
20050
+ t4,
20051
+ t6
19714
20052
  ] });
19715
- $[22] = t7;
19716
- $[23] = t9;
19717
- $[24] = t10;
20053
+ $[22] = t4;
20054
+ $[23] = t6;
20055
+ $[24] = t7;
19718
20056
  } else {
19719
- t10 = $[24];
20057
+ t7 = $[24];
19720
20058
  }
19721
- let t11;
19722
- if ($[25] !== provided.draggableProps || $[26] !== provided.innerRef || $[27] !== t10 || $[28] !== t4) {
19723
- t11 = /* @__PURE__ */ jsx("div", { ref: t1, ...t2, style: t3, className: t4, children: t10 });
19724
- $[25] = provided.draggableProps;
19725
- $[26] = provided.innerRef;
19726
- $[27] = t10;
19727
- $[28] = t4;
19728
- $[29] = t11;
20059
+ let t8;
20060
+ if ($[25] !== nodeRef || $[26] !== style || $[27] !== t1 || $[28] !== t7) {
20061
+ t8 = /* @__PURE__ */ jsx("div", { ref: nodeRef, style, className: t1, children: t7 });
20062
+ $[25] = nodeRef;
20063
+ $[26] = style;
20064
+ $[27] = t1;
20065
+ $[28] = t7;
20066
+ $[29] = t8;
19729
20067
  } else {
19730
- t11 = $[29];
20068
+ t8 = $[29];
19731
20069
  }
19732
- return t11;
20070
+ return t8;
19733
20071
  }
19734
20072
  function ArrayItemOptions({
20073
+ dragHandleProps,
19735
20074
  direction,
19736
20075
  disabled,
19737
20076
  remove,
19738
20077
  index,
19739
- provided,
19740
20078
  copy,
19741
20079
  canAddElements,
19742
20080
  sortable,
19743
20081
  addInIndex
19744
20082
  }) {
19745
20083
  const [menuOpen, setMenuOpen] = useState(false);
19746
- const iconRef = React__default.useRef(null);
19747
- useOutsideAlerter(iconRef, () => setMenuOpen(false));
19748
- return /* @__PURE__ */ jsx("div", { className: `pl-2 pt-1 pb-1 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`, ref: iconRef, ...provided.dragHandleProps, children: /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 400, open: menuOpen ? false : void 0, side: direction === "column" ? "left" : void 0, title: !disabled && sortable ? "Drag to move. Click for more options" : void 0, children: [
19749
- /* @__PURE__ */ jsx(IconButton, { size: "small", disabled: disabled || !canAddElements, onClick: (e) => {
20084
+ const iconRef = useRef(null);
20085
+ useOutsideAlerter(iconRef, () => {
20086
+ if (menuOpen) setMenuOpen(false);
20087
+ });
20088
+ const showMenu = canAddElements ?? false;
20089
+ const handleIconButtonClick = (e) => {
20090
+ if (showMenu) {
20091
+ e.stopPropagation();
19750
20092
  e.preventDefault();
19751
- setMenuOpen(true);
19752
- }, onDragStart: (e_0) => {
19753
- setMenuOpen(false);
19754
- }, className: disabled || !sortable ? "cursor-inherit" : "cursor-grab", children: /* @__PURE__ */ jsx(HandleIcon, {}) }),
19755
- /* @__PURE__ */ jsxs(Menu, { portalContainer: iconRef.current, open: menuOpen, trigger: /* @__PURE__ */ jsx("div", { tabIndex: -1 }), children: [
19756
- /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: (e_1) => {
20093
+ setMenuOpen((o) => !o);
20094
+ } else if (sortable) ;
20095
+ else {
20096
+ e.stopPropagation();
20097
+ e.preventDefault();
20098
+ }
20099
+ };
20100
+ const title = !disabled && sortable && showMenu ? "Drag to move. Click for options" : !disabled && showMenu ? "Click for options" : !disabled && sortable ? "Drag to move" : void 0;
20101
+ return /* @__PURE__ */ jsxs("div", { ref: iconRef, className: `pl-2 pt-1 pb-1 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`, children: [
20102
+ /* @__PURE__ */ jsx(Tooltip, { delayDuration: 400, open: menuOpen ? false : void 0, side: direction === "column" ? "left" : void 0, title, children: /* @__PURE__ */ jsx(IconButton, { size: "small", disabled: disabled || !showMenu && !sortable, ...sortable ? dragHandleProps : {}, onClick: handleIconButtonClick, onFocus: () => {
20103
+ if (sortable && menuOpen) setMenuOpen(false);
20104
+ }, className: cls(disabled || !sortable && !showMenu ? "cursor-inherit" : "", sortable && !disabled ? "cursor-grab" : "", !sortable && showMenu && !disabled ? "cursor-pointer" : ""), children: /* @__PURE__ */ jsx(HandleIcon, {}) }) }),
20105
+ showMenu && /* @__PURE__ */ jsxs(Menu, { portalContainer: iconRef.current, open: menuOpen, trigger: /* @__PURE__ */ jsx("div", { tabIndex: -1 }), children: [
20106
+ /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: (e_0) => {
19757
20107
  setMenuOpen(false);
19758
20108
  remove(index);
19759
20109
  }, children: [
@@ -19782,7 +20132,110 @@ function ArrayItemOptions({
19782
20132
  "Add below"
19783
20133
  ] })
19784
20134
  ] })
19785
- ] }) });
20135
+ ] });
20136
+ }
20137
+ function ArrayContainer({
20138
+ droppableId,
20139
+ addLabel,
20140
+ value,
20141
+ disabled = false,
20142
+ buildEntry,
20143
+ size = "medium",
20144
+ onInternalIdAdded,
20145
+ includeAddButton: deprecatedIncludeAddButton,
20146
+ canAddElements: canAddElementsProp = true,
20147
+ sortable = true,
20148
+ newDefaultEntry,
20149
+ onValueChange,
20150
+ className,
20151
+ min = 0,
20152
+ max = Infinity
20153
+ }) {
20154
+ const canAddElements = (canAddElementsProp === void 0 ? true : canAddElementsProp) && // Default canAddElementsProp to true if undefined
20155
+ (deprecatedIncludeAddButton === void 0 || deprecatedIncludeAddButton);
20156
+ const hasValue = value && Array.isArray(value) && value.length > 0;
20157
+ const internalIdsRef = useRef(buildIdsMap(value));
20158
+ const [internalIds, setInternalIds] = useState(hasValue ? Object.values(internalIdsRef.current) : []);
20159
+ const itemCustomPropsRef = useRef({});
20160
+ const updateItemCustomProps = useCallback((internalId, customProps) => {
20161
+ itemCustomPropsRef.current[internalId] = customProps;
20162
+ }, []);
20163
+ const pointerSensor = useSensor(PointerSensor, {
20164
+ activationConstraint: {
20165
+ distance: 5
20166
+ }
20167
+ });
20168
+ const keyboardSensor = useSensor(KeyboardSensor, {});
20169
+ const sensors = useSensors(pointerSensor, keyboardSensor);
20170
+ useEffect(() => {
20171
+ if (hasValue && value && value.length !== internalIds.length) {
20172
+ const newInternalIds = value.map((v, index) => {
20173
+ const hashValue = getHashValue(v) + index;
20174
+ if (hashValue in internalIdsRef.current) {
20175
+ return internalIdsRef.current[hashValue];
20176
+ } else {
20177
+ const newInternalId = getRandomId();
20178
+ internalIdsRef.current[hashValue] = newInternalId;
20179
+ return newInternalId;
20180
+ }
20181
+ });
20182
+ setInternalIds(newInternalIds);
20183
+ }
20184
+ }, [hasValue, internalIds.length, value]);
20185
+ const insertInEnd = (e) => {
20186
+ e.preventDefault();
20187
+ if (disabled || (value ?? []).length >= max) return;
20188
+ const id = getRandomId();
20189
+ const newIds = [...internalIds, id];
20190
+ if (onInternalIdAdded) onInternalIdAdded(id);
20191
+ setInternalIds(newIds);
20192
+ onValueChange([...value ?? [], newDefaultEntry]);
20193
+ };
20194
+ const remove = (index_0) => {
20195
+ if ((value ?? []).length <= min) return;
20196
+ const newIds_0 = [...internalIds];
20197
+ newIds_0.splice(index_0, 1);
20198
+ setInternalIds(newIds_0);
20199
+ onValueChange(value.filter((_, i) => i !== index_0));
20200
+ };
20201
+ const copy = (index_1) => {
20202
+ if ((value ?? []).length >= max) return;
20203
+ const id_0 = getRandomId();
20204
+ const copyingItem = value[index_1];
20205
+ const newIds_1 = [...internalIds.slice(0, index_1 + 1), id_0, ...internalIds.slice(index_1 + 1)];
20206
+ if (onInternalIdAdded) onInternalIdAdded(id_0);
20207
+ setInternalIds(newIds_1);
20208
+ onValueChange([...value.slice(0, index_1 + 1), copyingItem, ...value.slice(index_1 + 1)]);
20209
+ };
20210
+ const addInIndex = (index_2) => {
20211
+ if ((value ?? []).length >= max) return;
20212
+ const id_1 = getRandomId();
20213
+ const newIds_2 = [...internalIds.slice(0, index_2), id_1, ...internalIds.slice(index_2)];
20214
+ if (onInternalIdAdded) onInternalIdAdded(id_1);
20215
+ setInternalIds(newIds_2);
20216
+ onValueChange([...value.slice(0, index_2), newDefaultEntry, ...value.slice(index_2)]);
20217
+ };
20218
+ const onDragEnd = (event) => {
20219
+ const {
20220
+ active,
20221
+ over
20222
+ } = event;
20223
+ if (!over || active.id === over.id) return;
20224
+ const oldIndex = internalIds.indexOf(active.id);
20225
+ const newIndex = internalIds.indexOf(over.id);
20226
+ if (oldIndex === -1 || newIndex === -1) return;
20227
+ const newIds_3 = arrayMove(internalIds, oldIndex, newIndex);
20228
+ setInternalIds(newIds_3);
20229
+ onValueChange(arrayMove(value, oldIndex, newIndex));
20230
+ };
20231
+ return sortable ? /* @__PURE__ */ jsx(DndContext, { sensors, modifiers: [restrictToVerticalAxis], collisionDetection: closestCenter, onDragEnd, children: /* @__PURE__ */ jsx(SortableContext, { items: internalIds, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsxs("div", { className: cls("space-y-1", className), id: droppableId, children: [
20232
+ hasValue && internalIds.map((internalId_0, index_3) => /* @__PURE__ */ jsx(SortableItem, { id: internalId_0, index: index_3, size, disabled, buildEntry, remove, copy, addInIndex, canAddElements, sortable, storedProps: itemCustomPropsRef.current[internalId_0], updateItemCustomProps }, `array_field_${internalId_0}`)),
20233
+ canAddElements && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || (value?.length ?? 0) >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, className: "ml-3.5", children: addLabel ?? "Add" }) })
20234
+ ] }) }) }) : /* @__PURE__ */ jsxs("div", { className: cls("space-y-1", className), id: droppableId, children: [
20235
+ hasValue && internalIds.map((internalId_1, index_4) => /* @__PURE__ */ jsx(ArrayContainerItem, { nodeRef: (node) => {
20236
+ }, style: {}, dragHandleProps: {}, internalId: internalId_1, index: index_4, size, disabled, buildEntry, remove, copy, addInIndex, canAddElements, sortable: false, isDragging: false, storedProps: itemCustomPropsRef.current[internalId_1], updateItemCustomProps }, `array_field_${internalId_1}`)),
20237
+ canAddElements && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || (value?.length ?? 0) >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
20238
+ ] });
19786
20239
  }
19787
20240
  function arrayMove(value, sourceIndex, destinationIndex) {
19788
20241
  const result = Array.from(value);
@@ -20125,9 +20578,9 @@ function useBuildNavigationController(props) {
20125
20578
  views: viewsProp,
20126
20579
  adminViews: adminViewsProp,
20127
20580
  viewsOrder,
20581
+ plugins,
20128
20582
  userConfigPersistence,
20129
20583
  dataSourceDelegate,
20130
- injectCollections,
20131
20584
  disabled
20132
20585
  } = props;
20133
20586
  const navigate = useNavigate();
@@ -20217,7 +20670,7 @@ function useBuildNavigationController(props) {
20217
20670
  if (disabled || authController.initialLoading) return;
20218
20671
  console.debug("Refreshing navigation");
20219
20672
  try {
20220
- const [resolvedCollections = [], resolvedViews, resolvedAdminViews = []] = await Promise.all([resolveCollections(collectionsProp, collectionPermissions, authController, dataSourceDelegate, injectCollections), resolveCMSViews(viewsProp, authController, dataSourceDelegate), resolveCMSViews(adminViewsProp, authController, dataSourceDelegate)]);
20673
+ const [resolvedCollections = [], resolvedViews, resolvedAdminViews = []] = await Promise.all([resolveCollections(collectionsProp, collectionPermissions, authController, dataSourceDelegate, plugins), resolveCMSViews(viewsProp, authController, dataSourceDelegate), resolveCMSViews(adminViewsProp, authController, dataSourceDelegate)]);
20221
20674
  let shouldUpdateTopLevelNav = false;
20222
20675
  if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
20223
20676
  collectionsRef.current = resolvedCollections;
@@ -20246,7 +20699,7 @@ function useBuildNavigationController(props) {
20246
20699
  }
20247
20700
  if (navigationLoading) setNavigationLoading(false);
20248
20701
  if (!initialised) setInitialised(true);
20249
- }, [collectionsProp, collectionPermissions, authController.user, authController.initialLoading, disabled, viewsProp, adminViewsProp, computeTopNavigation, injectCollections]);
20702
+ }, [collectionsProp, collectionPermissions, authController.user, authController.initialLoading, disabled, viewsProp, adminViewsProp, computeTopNavigation]);
20250
20703
  useEffect(() => {
20251
20704
  refreshNavigation();
20252
20705
  }, [refreshNavigation]);
@@ -20369,7 +20822,8 @@ function useBuildNavigationController(props) {
20369
20822
  getParentReferencesFromPath: getAllParentReferencesForPath,
20370
20823
  getParentCollectionIds,
20371
20824
  convertIdsToPaths,
20372
- navigate
20825
+ navigate,
20826
+ plugins
20373
20827
  };
20374
20828
  }
20375
20829
  function encodePath(input) {
@@ -20388,7 +20842,19 @@ function filterOutNotAllowedCollections(resolvedCollections, authController) {
20388
20842
  };
20389
20843
  });
20390
20844
  }
20391
- async function resolveCollections(collections, collectionPermissions, authController, dataSource, injectCollections) {
20845
+ function applyPluginModifyCollection(resolvedCollections, modifyCollection) {
20846
+ return resolvedCollections.map((collection) => {
20847
+ const modifiedCollection = modifyCollection(collection);
20848
+ if (modifiedCollection.subcollections) {
20849
+ return {
20850
+ ...modifiedCollection,
20851
+ subcollections: applyPluginModifyCollection(modifiedCollection.subcollections, modifyCollection)
20852
+ };
20853
+ }
20854
+ return modifiedCollection;
20855
+ });
20856
+ }
20857
+ async function resolveCollections(collections, collectionPermissions, authController, dataSource, plugins) {
20392
20858
  let resolvedCollections = [];
20393
20859
  if (typeof collections === "function") {
20394
20860
  resolvedCollections = await collections({
@@ -20399,8 +20865,15 @@ async function resolveCollections(collections, collectionPermissions, authContro
20399
20865
  } else if (Array.isArray(collections)) {
20400
20866
  resolvedCollections = collections;
20401
20867
  }
20402
- if (injectCollections) {
20403
- resolvedCollections = injectCollections(resolvedCollections ?? []);
20868
+ if (plugins) {
20869
+ for (const plugin of plugins) {
20870
+ if (plugin.collection?.modifyCollection) {
20871
+ resolvedCollections = applyPluginModifyCollection(resolvedCollections, plugin.collection.modifyCollection);
20872
+ }
20873
+ if (plugin.collection?.injectCollections) {
20874
+ resolvedCollections = plugin.collection.injectCollections(resolvedCollections ?? []);
20875
+ }
20876
+ }
20404
20877
  }
20405
20878
  resolvedCollections = applyPermissionsFunctionIfEmpty(resolvedCollections, collectionPermissions);
20406
20879
  resolvedCollections = filterOutNotAllowedCollections(resolvedCollections, authController);
@@ -21321,10 +21794,11 @@ function EntityEditViewInner({
21321
21794
  }, [selectedTabProp]);
21322
21795
  const subcollections = (collection.subcollections ?? []).filter((c2) => !c2.hideFromNavigation);
21323
21796
  const subcollectionsCount = subcollections?.length ?? 0;
21324
- const customViews = collection.entityViews;
21797
+ const customViews = collection.entityViews ?? [];
21325
21798
  const customViewsCount = customViews?.length ?? 0;
21326
21799
  const includeJsonView = collection.includeJsonView === void 0 ? true : collection.includeJsonView;
21327
21800
  const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
21801
+ const plugins = customizationController.plugins;
21328
21802
  const {
21329
21803
  resolvedEntityViews,
21330
21804
  selectedEntityView,
@@ -21341,7 +21815,6 @@ function EntityEditViewInner({
21341
21815
  return null;
21342
21816
  }
21343
21817
  if (!entityId) {
21344
- console.error("INTERNAL: entityId is not defined");
21345
21818
  return null;
21346
21819
  }
21347
21820
  const formexStub = createFormexStub(usedEntity?.values ?? {});
@@ -21373,7 +21846,7 @@ function EntityEditViewInner({
21373
21846
  };
21374
21847
  return /* @__PURE__ */ jsx("div", { className: cls(defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
21375
21848
  "hidden": selectedTab !== customView.key
21376
- }), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsx(Builder, { collection, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
21849
+ }), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsx(Builder, { collection, parentCollectionIds, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
21377
21850
  }).filter(Boolean);
21378
21851
  const globalLoading = dataLoading && !usedEntity;
21379
21852
  const jsonView = /* @__PURE__ */ jsx("div", { className: cls("relative flex-1 h-full overflow-auto w-full", {
@@ -21402,7 +21875,8 @@ function EntityEditViewInner({
21402
21875
  };
21403
21876
  const entityReadOnlyView = !canEdit && entity ? /* @__PURE__ */ jsx("div", { className: cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", canEdit || !mainViewVisible || selectedSecondaryForm ? "hidden" : ""), children: /* @__PURE__ */ jsxs("div", { className: 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: [
21404
21877
  /* @__PURE__ */ jsx(Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
21405
- /* @__PURE__ */ jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection })
21878
+ /* @__PURE__ */ jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection }),
21879
+ /* @__PURE__ */ jsx("div", { className: "h-16" })
21406
21880
  ] }) }) : null;
21407
21881
  const entityView = /* @__PURE__ */ jsx(EntityForm, { collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues: cachedDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: cls((!mainViewVisible || !canEdit) && !selectedSecondaryForm ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, disabled: !canEdit, ...formProps, onEntityChange: (entity_0) => {
21408
21882
  setUsedEntity(entity_0);
@@ -21422,7 +21896,8 @@ function EntityEditViewInner({
21422
21896
  formProps?.onSaved?.(res);
21423
21897
  }, Builder: selectedSecondaryForm?.Builder });
21424
21898
  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}`));
21425
- 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}`));
21899
+ const customViewTabsStart = resolvedEntityViews.filter((view) => view.position === "start").map((view_0) => /* @__PURE__ */ jsx(Tab, { className: !view_0.tabComponent ? "text-sm min-w-[120px]" : void 0, value: view_0.key, children: view_0.tabComponent ?? view_0.name }, `entity_detail_collection_tab_${view_0.name}`));
21900
+ const customViewTabsEnd = resolvedEntityViews.filter((view_1) => !view_1.position || view_1.position === "end").map((view_2) => /* @__PURE__ */ jsx(Tab, { className: !view_2.tabComponent ? "text-sm min-w-[120px]" : void 0, value: view_2.key, children: view_2.tabComponent ?? view_2.name }, `entity_detail_collection_tab_${view_2.name}`));
21426
21901
  const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
21427
21902
  let result = /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col h-full w-full bg-white dark:bg-surface-900", children: [
21428
21903
  shouldShowTopBar && /* @__PURE__ */ jsxs("div", { className: cls("h-14 flex overflow-visible overflow-x-scroll w-full no-scrollbar h-14 border-b pl-2 pr-2 pt-1 flex items-end bg-surface-50 dark:bg-surface-900", defaultBorderMixin), children: [
@@ -21432,9 +21907,10 @@ function EntityEditViewInner({
21432
21907
  hasAdditionalViews && /* @__PURE__ */ jsxs(Tabs, { value: selectedTab, onValueChange: (value_1) => {
21433
21908
  onSideTabClick(value_1);
21434
21909
  }, children: [
21435
- includeJsonView && /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsx(CodeIcon, { size: "small" }) }),
21910
+ includeJsonView && /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, className: "text-sm", children: /* @__PURE__ */ jsx(CodeIcon, { size: "small" }) }),
21911
+ customViewTabsStart,
21436
21912
  /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
21437
- customViewTabs,
21913
+ customViewTabsEnd,
21438
21914
  subcollectionTabs
21439
21915
  ] })
21440
21916
  ] }),
@@ -21446,7 +21922,6 @@ function EntityEditViewInner({
21446
21922
  customViewsView,
21447
21923
  subCollectionsViews
21448
21924
  ] });
21449
- const plugins = customizationController.plugins;
21450
21925
  if (plugins) {
21451
21926
  plugins.forEach((plugin) => {
21452
21927
  if (plugin.form?.provider) {
@@ -21457,6 +21932,12 @@ function EntityEditViewInner({
21457
21932
  return result;
21458
21933
  }
21459
21934
  function EntitySidePanel(props) {
21935
+ const {
21936
+ allowFullScreen = true,
21937
+ path,
21938
+ entityId,
21939
+ formProps
21940
+ } = props;
21460
21941
  const {
21461
21942
  blocked,
21462
21943
  setBlocked,
@@ -21494,19 +21975,9 @@ function EntitySidePanel(props) {
21494
21975
  }
21495
21976
  };
21496
21977
  const parentCollectionIds = useMemo(() => {
21497
- return navigationController.getParentCollectionIds(props.path);
21498
- }, [navigationController, props.path]);
21499
- const collection = useMemo(() => {
21500
- if (props.collection) {
21501
- return props.collection;
21502
- }
21503
- const registryCollection = navigationController.getCollection(props.path);
21504
- if (registryCollection) {
21505
- return registryCollection;
21506
- }
21507
- console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
21508
- throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
21509
- }, [navigationController, props.collection]);
21978
+ return navigationController.getParentCollectionIds(path);
21979
+ }, [navigationController, path]);
21980
+ const collection = props.collection ?? navigationController.getCollection(path);
21510
21981
  useEffect(() => {
21511
21982
  function beforeunload(e) {
21512
21983
  if (blocked && collection) {
@@ -21532,24 +22003,24 @@ function EntitySidePanel(props) {
21532
22003
  }
21533
22004
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(EntityEditView, { ...props, layout: "side_panel", collection, parentCollectionIds, onValuesModified, onSaved: onUpdate, barActions: /* @__PURE__ */ jsxs(Fragment, { children: [
21534
22005
  /* @__PURE__ */ jsx(IconButton, { className: "self-center", onClick: onClose, children: /* @__PURE__ */ jsx(CloseIcon, { size: "small" }) }),
21535
- /* @__PURE__ */ jsx(IconButton, { className: "self-center", onClick: () => {
21536
- if (props.entityId) navigate(location.pathname);
22006
+ allowFullScreen && /* @__PURE__ */ jsx(IconButton, { className: "self-center", onClick: () => {
22007
+ if (entityId) navigate(location.pathname);
21537
22008
  else navigate(location.pathname + "#new");
21538
22009
  }, children: /* @__PURE__ */ jsx(OpenInFullIcon, { size: "small" }) })
21539
22010
  ] }), onTabChange: ({
21540
- path,
21541
- entityId,
22011
+ path: path_0,
22012
+ entityId: entityId_0,
21542
22013
  selectedTab,
21543
22014
  collection: collection_0
21544
22015
  }) => {
21545
22016
  sideEntityController.replace({
21546
- path,
21547
- entityId,
22017
+ path: path_0,
22018
+ entityId: entityId_0,
21548
22019
  selectedTab,
21549
22020
  updateUrl: true,
21550
22021
  collection: collection_0
21551
22022
  });
21552
- }, formProps: props.formProps }) }) });
22023
+ }, formProps }) }) });
21553
22024
  }
21554
22025
  const NEW_URL_HASH = "new_side";
21555
22026
  const SIDE_URL_HASH = "side";
@@ -21558,7 +22029,7 @@ function getEntityViewWidth(props, small, customizationController, authControlle
21558
22029
  const {
21559
22030
  selectedSecondaryForm
21560
22031
  } = resolvedSelectedEntityView(props.collection?.entityViews, customizationController, props.selectedTab);
21561
- const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || Boolean(selectedSecondaryForm);
22032
+ const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || props.selectedTab === "__history" || Boolean(selectedSecondaryForm);
21562
22033
  let resolvedWidth;
21563
22034
  if (props.width) {
21564
22035
  resolvedWidth = typeof props.width === "number" ? `${props.width}px` : props.width;
@@ -22282,7 +22753,7 @@ function FireCMS(props) {
22282
22753
  authController,
22283
22754
  storageSource,
22284
22755
  dataSourceDelegate,
22285
- plugins,
22756
+ plugins: pluginsProp,
22286
22757
  onAnalyticsEvent,
22287
22758
  propertyConfigs,
22288
22759
  entityViews,
@@ -22290,6 +22761,10 @@ function FireCMS(props) {
22290
22761
  navigationController,
22291
22762
  apiKey
22292
22763
  } = props;
22764
+ if (pluginsProp) {
22765
+ console.warn("The `plugins` prop is deprecated in the FireCMS component. You should pass your plugins to `useBuildNavigationController` instead.");
22766
+ }
22767
+ const plugins = navigationController.plugins ?? pluginsProp;
22293
22768
  const sideDialogsController = useBuildSideDialogsController();
22294
22769
  const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController, authController);
22295
22770
  const pluginsLoading = plugins?.some((p) => p.loading) ?? false;
@@ -23995,6 +24470,8 @@ export {
23995
24470
  EntityCollectionView,
23996
24471
  EntityCollectionViewActions,
23997
24472
  EntityForm,
24473
+ EntityPreview,
24474
+ EntityPreviewContainer,
23998
24475
  EntityReference,
23999
24476
  EntityView,
24000
24477
  EnumValuesChip,
@@ -24128,6 +24605,7 @@ export {
24128
24605
  joinCollectionLists,
24129
24606
  makePropertiesEditable,
24130
24607
  makePropertiesNonEditable,
24608
+ mergeCallbacks,
24131
24609
  mergeCollection,
24132
24610
  mergeDeep,
24133
24611
  mergeEntityActions,