@firecms/core 3.0.0-canary.241 → 3.0.0-canary.244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@firecms/ui"), require("notistack"), require("object-hash"), require("@firecms/formex"), require("react-router-dom"), require("fuse.js"), require("react-fast-compare"), require("date-fns"), require("date-fns/locale"), require("react-use-measure"), require("yup"), require("react-window"), require("@hello-pangea/dnd"), require("react-dropzone"), require("react-image-file-resizer"), require("@firecms/editor"), require("prism-react-renderer"), require("react-router"), require("@radix-ui/react-portal")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@firecms/ui", "notistack", "object-hash", "@firecms/formex", "react-router-dom", "fuse.js", "react-fast-compare", "date-fns", "date-fns/locale", "react-use-measure", "yup", "react-window", "@hello-pangea/dnd", "react-dropzone", "react-image-file-resizer", "@firecms/editor", "prism-react-renderer", "react-router", "@radix-ui/react-portal"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Core"] = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.ui, global.notistack, global.hash, global.formex, global.reactRouterDom, global.Fuse, global.equal, global.dateFns, global.locales, global.useMeasure, global.yup, global.reactWindow, global.dnd, global.reactDropzone, global.Resizer, global.editor, global.prismReactRenderer, global.reactRouter, global.Portal));
3
- })(this, function(exports2, jsxRuntime, reactCompilerRuntime, React, ui, notistack, hash, formex, reactRouterDom, Fuse, equal, dateFns, locales, useMeasure, yup, reactWindow, dnd, reactDropzone, Resizer, editor, prismReactRenderer, reactRouter, Portal) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@firecms/ui"), require("notistack"), require("object-hash"), require("@firecms/formex"), require("react-router-dom"), require("fuse.js"), require("react-fast-compare"), require("date-fns"), require("date-fns/locale"), require("react-use-measure"), require("yup"), require("react-window"), require("@dnd-kit/core"), require("@dnd-kit/modifiers"), require("@dnd-kit/sortable"), require("@dnd-kit/utilities"), require("react-dropzone"), require("react-image-file-resizer"), require("@firecms/editor"), require("prism-react-renderer"), require("react-router"), require("@radix-ui/react-portal")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@firecms/ui", "notistack", "object-hash", "@firecms/formex", "react-router-dom", "fuse.js", "react-fast-compare", "date-fns", "date-fns/locale", "react-use-measure", "yup", "react-window", "@dnd-kit/core", "@dnd-kit/modifiers", "@dnd-kit/sortable", "@dnd-kit/utilities", "react-dropzone", "react-image-file-resizer", "@firecms/editor", "prism-react-renderer", "react-router", "@radix-ui/react-portal"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Core"] = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.ui, global.notistack, global.hash, global.formex, global.reactRouterDom, global.Fuse, global.equal, global.dateFns, global.locales, global.useMeasure, global.yup, global.reactWindow, global.core, global.modifiers, global.sortable, global.utilities, global.reactDropzone, global.Resizer, global.editor, global.prismReactRenderer, global.reactRouter, global.Portal));
3
+ })(this, function(exports2, jsxRuntime, reactCompilerRuntime, React, ui, notistack, hash, formex, reactRouterDom, Fuse, equal, dateFns, locales, useMeasure, yup, reactWindow, core, modifiers, sortable, utilities, reactDropzone, Resizer, editor, prismReactRenderer, reactRouter, Portal) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -4308,7 +4308,7 @@
4308
4308
  }
4309
4309
  } else {
4310
4310
  onEntityUpdate(void 0);
4311
- return _temp3$4;
4311
+ return _temp3$5;
4312
4312
  }
4313
4313
  }
4314
4314
  };
@@ -4349,7 +4349,7 @@
4349
4349
  }
4350
4350
  return t5;
4351
4351
  }
4352
- function _temp3$4() {
4352
+ function _temp3$5() {
4353
4353
  }
4354
4354
  function _temp2$d() {
4355
4355
  }
@@ -5702,7 +5702,7 @@
5702
5702
  let t1;
5703
5703
  if ($[17] !== size || $[18] !== value) {
5704
5704
  const lines = value.split("\n");
5705
- t1 = value && value.includes("\n") ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("overflow-x-scroll", size === "small" ? "text-sm" : ""), children: lines.map((str, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
5705
+ t1 = value && value.includes("\n") ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("overflow-x-scroll overflow-hidden", size === "small" ? "text-sm" : ""), children: lines.map((str, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
5706
5706
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: str }),
5707
5707
  index !== lines.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("br", {})
5708
5708
  ] }, `string_preview_${index}`)) }) : size === "small" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: value }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: value });
@@ -7268,7 +7268,6 @@
7268
7268
  width: "100%",
7269
7269
  color: "unset",
7270
7270
  fontWeight: "unset",
7271
- lineHeight: 1.7142857,
7272
7271
  fontSize: "unset",
7273
7272
  fontFamily: "unset",
7274
7273
  background: "unset",
@@ -9885,7 +9884,7 @@
9885
9884
  }
9886
9885
  function propertiesToColumns({
9887
9886
  properties,
9888
- sortable,
9887
+ sortable: sortable2,
9889
9888
  forceFilter,
9890
9889
  AdditionalHeaderWidget
9891
9890
  }) {
@@ -9902,7 +9901,7 @@
9902
9901
  align: getTableCellAlignment(property),
9903
9902
  icon: getIconForProperty(property, "small"),
9904
9903
  title: property.name ?? key,
9905
- sortable,
9904
+ sortable: sortable2,
9906
9905
  filter: !disabledFilter && filterable,
9907
9906
  width: getTablePropertyColumnWidth(property),
9908
9907
  resizable: true,
@@ -10611,8 +10610,7 @@
10611
10610
  className,
10612
10611
  endAdornment,
10613
10612
  AddColumnComponent,
10614
- initialScroll = 0,
10615
- debug
10613
+ initialScroll = 0
10616
10614
  }) {
10617
10615
  const sortByProperty = sortBy ? sortBy[0] : void 0;
10618
10616
  const currentSort = sortBy ? sortBy[1] : void 0;
@@ -10622,7 +10620,10 @@
10622
10620
  const debouncedScroll = useDebounceCallback(onScrollProp, 200);
10623
10621
  React.useEffect(() => {
10624
10622
  if (tableRef.current && initialScroll) {
10625
- tableRef.current.scrollTo(0, initialScroll);
10623
+ const {
10624
+ scrollLeft
10625
+ } = tableRef.current;
10626
+ tableRef.current.scrollTo(scrollLeft, initialScroll);
10626
10627
  }
10627
10628
  }, [tableRef, initialScroll]);
10628
10629
  React.useEffect(() => {
@@ -10653,11 +10654,9 @@
10653
10654
  offsetSize: true
10654
10655
  });
10655
10656
  const onColumnResizeInternal = React.useCallback((params) => {
10656
- if (debug) console.log("onColumnResizeInternal", params);
10657
10657
  setColumns((prevColumns) => prevColumns.map((column) => column.key === params.column.key ? params.column : column));
10658
10658
  }, []);
10659
10659
  const onColumnResizeEndInternal = React.useCallback((params_0) => {
10660
- if (debug) console.log("onColumnResizeEndInternal", params_0);
10661
10660
  setColumns(columns.map((column_0) => column_0.key === params_0.column.key ? params_0.column : column_0));
10662
10661
  if (onColumnResize) {
10663
10662
  onColumnResize(params_0);
@@ -10665,18 +10664,15 @@
10665
10664
  }, [columns, onColumnResize]);
10666
10665
  const filterRef = React.useRef();
10667
10666
  React.useEffect(() => {
10668
- if (debug) console.log("Filter updated", filterInput);
10669
10667
  filterRef.current = filterInput;
10670
10668
  }, [filterInput]);
10671
10669
  const scrollToTop = React.useCallback(() => {
10672
- if (debug) console.log("scrollToTop");
10673
10670
  endReachCallbackThreshold.current = 0;
10674
10671
  if (tableRef.current) {
10675
10672
  tableRef.current.scrollTo(tableRef.current?.scrollLeft, 0);
10676
10673
  }
10677
10674
  }, []);
10678
10675
  const onColumnSort = React.useCallback((key) => {
10679
- if (debug) console.log("onColumnSort", key);
10680
10676
  const isDesc = sortByProperty === key && currentSort === "desc";
10681
10677
  const isAsc = sortByProperty === key && currentSort === "asc";
10682
10678
  const newSort = isAsc ? "desc" : isDesc ? void 0 : "asc";
@@ -10697,9 +10693,7 @@
10697
10693
  scrollToTop();
10698
10694
  }, [checkFilterCombination, currentSort, onFilterUpdate, onResetPagination, onSortByUpdate, scrollToTop, sortByProperty]);
10699
10695
  const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
10700
- if (debug) console.log("maxScroll", maxScroll);
10701
10696
  const onEndReachedInternal = React.useCallback((scrollOffset) => {
10702
- if (debug) console.log("onEndReachedInternal", scrollOffset, endReachCallbackThreshold.current + endOffset);
10703
10697
  if (onEndReached && (data?.length ?? 0) > 0 && scrollOffset > endReachCallbackThreshold.current + endOffset) {
10704
10698
  endReachCallbackThreshold.current = scrollOffset;
10705
10699
  onEndReached();
@@ -10710,11 +10704,6 @@
10710
10704
  scrollOffset: scrollOffset_0,
10711
10705
  scrollUpdateWasRequested
10712
10706
  }) => {
10713
- if (debug) console.log("onScroll", {
10714
- scrollDirection,
10715
- scrollOffset: scrollOffset_0,
10716
- scrollUpdateWasRequested
10717
- });
10718
10707
  if (onScrollProp) {
10719
10708
  debouncedScroll({
10720
10709
  scrollDirection,
@@ -10725,7 +10714,6 @@
10725
10714
  if (!scrollUpdateWasRequested && scrollOffset_0 >= maxScroll - endOffset) onEndReachedInternal(scrollOffset_0);
10726
10715
  }, [maxScroll, onEndReachedInternal]);
10727
10716
  const onFilterUpdateInternal = React.useCallback((column_1, filterForProperty) => {
10728
- if (debug) console.log("onFilterUpdateInternal", column_1, filterForProperty);
10729
10717
  endReachCallbackThreshold.current = 0;
10730
10718
  const filter_0 = filterRef.current;
10731
10719
  let newFilterValue = filter_0 ? {
@@ -10773,7 +10761,6 @@
10773
10761
  endAdornment,
10774
10762
  AddColumnComponent
10775
10763
  };
10776
- if (debug) console.log("VirtualTable render", virtualListController);
10777
10764
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: measureRef, style, className: ui.cls("h-full w-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(VirtualListContext.Provider, { value: virtualListController, children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedList, { outerRef: tableRef, width: bounds.width, height: bounds.height, itemCount: (data?.length ?? 0) + (endAdornment ? 1 : 0), onScroll, includeAddColumn: Boolean(AddColumnComponent), itemSize: rowHeight }, rowHeight) }) });
10778
10765
  }, equal);
10779
10766
  function MemoizedList({
@@ -11109,8 +11096,8 @@
11109
11096
  }
11110
11097
  let t9;
11111
11098
  if ($[34] !== dataType || $[35] !== enumValues || $[36] !== internalValue || $[37] !== multiple || $[38] !== name || $[39] !== operation || $[40] !== updateFilter) {
11112
- t9 = enumValues && multiple && /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelect, { position: "item-aligned", value: Array.isArray(internalValue) ? internalValue.map(_temp3$3) : [], onValueChange: (value_2) => {
11113
- updateFilter(operation, dataType === "number" ? value_2.map(_temp4$2) : value_2);
11099
+ t9 = enumValues && multiple && /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelect, { position: "item-aligned", value: Array.isArray(internalValue) ? internalValue.map(_temp3$4) : [], onValueChange: (value_2) => {
11100
+ updateFilter(operation, dataType === "number" ? value_2.map(_temp4$3) : value_2);
11114
11101
  }, multiple, endAdornment: internalValue && /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { className: "absolute right-2 top-3", onClick: (e_2) => updateFilter(operation, void 0), children: /* @__PURE__ */ jsxRuntime.jsx(ui.CloseIcon, {}) }), children: enumValues.map((enumConfig_0) => /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelectItem, { value: String(enumConfig_0.id), children: /* @__PURE__ */ jsxRuntime.jsx(EnumValuesChip, { enumKey: String(enumConfig_0.id), enumValues, size: "small" }) }, `select_value_${name}_${enumConfig_0.id}`)) });
11115
11102
  $[34] = dataType;
11116
11103
  $[35] = enumValues;
@@ -11173,10 +11160,10 @@
11173
11160
  }
11174
11161
  return t12;
11175
11162
  }
11176
- function _temp4$2(v) {
11163
+ function _temp4$3(v) {
11177
11164
  return parseInt(v);
11178
11165
  }
11179
- function _temp3$3(e_1) {
11166
+ function _temp3$4(e_1) {
11180
11167
  return String(e_1);
11181
11168
  }
11182
11169
  function _temp2$7(op_1) {
@@ -11562,7 +11549,7 @@
11562
11549
  properties,
11563
11550
  tableController,
11564
11551
  filterable = true,
11565
- sortable = true,
11552
+ sortable: sortable2 = true,
11566
11553
  endAdornment,
11567
11554
  AddColumnComponent,
11568
11555
  AdditionalHeaderWidget,
@@ -11638,7 +11625,7 @@
11638
11625
  const collectionColumns = (() => {
11639
11626
  const columnsResult = propertiesToColumns({
11640
11627
  properties,
11641
- sortable,
11628
+ sortable: sortable2,
11642
11629
  forceFilter,
11643
11630
  AdditionalHeaderWidget
11644
11631
  });
@@ -13300,7 +13287,7 @@
13300
13287
  if ($[7] !== additionalActions || $[8] !== additionalChildrenStart || $[9] !== containerRef || $[10] !== context || $[11] !== customizationController.plugins || $[12] !== direction || $[13] !== filteredNavigationEntries || $[14] !== filteredUrls || $[15] !== groups || $[16] !== performingSearch) {
13301
13288
  const filteredGroups = filteredUrls ? filteredNavigationEntries.map(_temp2$5) : [];
13302
13289
  const allGroups = filteredUrls ? filteredGroups.filter((group, index) => filteredGroups.indexOf(group) === index) : [...groups];
13303
- if (filteredNavigationEntries.filter(_temp3$2).length > 0 || filteredNavigationEntries.length === 0) {
13290
+ if (filteredNavigationEntries.filter(_temp3$3).length > 0 || filteredNavigationEntries.length === 0) {
13304
13291
  allGroups.push(void 0);
13305
13292
  }
13306
13293
  let additionalPluginChildrenStart;
@@ -13310,7 +13297,7 @@
13310
13297
  const sectionProps = {
13311
13298
  context
13312
13299
  };
13313
- t143 = customizationController.plugins.filter(_temp4$1).map((plugin_0, i) => {
13300
+ t143 = customizationController.plugins.filter(_temp4$2).map((plugin_0, i) => {
13314
13301
  const section = plugin_0.homePage.includeSection(sectionProps);
13315
13302
  return /* @__PURE__ */ jsxRuntime.jsx(NavigationGroup, { group: section.title, children: section.children }, `plugin_section_${plugin_0.key}`);
13316
13303
  });
@@ -13331,7 +13318,7 @@
13331
13318
  additionalPluginSections = t153;
13332
13319
  let t162;
13333
13320
  if ($[34] !== customizationController.plugins) {
13334
- t162 = customizationController.plugins.filter(_temp5$1).map(_temp6$1);
13321
+ t162 = customizationController.plugins.filter(_temp5$2).map(_temp6$2);
13335
13322
  $[34] = customizationController.plugins;
13336
13323
  $[35] = t162;
13337
13324
  } else {
@@ -13348,7 +13335,7 @@
13348
13335
  additionalPluginChildrenStart = t172;
13349
13336
  let t18;
13350
13337
  if ($[38] !== customizationController.plugins) {
13351
- t18 = customizationController.plugins.filter(_temp7).map(_temp8);
13338
+ t18 = customizationController.plugins.filter(_temp7$1).map(_temp8);
13352
13339
  $[38] = customizationController.plugins;
13353
13340
  $[39] = t18;
13354
13341
  } else {
@@ -13536,19 +13523,19 @@
13536
13523
  function _temp8(plugin_4, i_1) {
13537
13524
  return /* @__PURE__ */ jsxRuntime.jsx("div", { children: plugin_4.homePage.additionalChildrenEnd }, `plugin_children_start_${i_1}`);
13538
13525
  }
13539
- function _temp7(plugin_3) {
13526
+ function _temp7$1(plugin_3) {
13540
13527
  return plugin_3.homePage?.additionalChildrenEnd;
13541
13528
  }
13542
- function _temp6$1(plugin_2, i_0) {
13529
+ function _temp6$2(plugin_2, i_0) {
13543
13530
  return /* @__PURE__ */ jsxRuntime.jsx("div", { children: plugin_2.homePage.additionalChildrenStart }, `plugin_children_start_${i_0}`);
13544
13531
  }
13545
- function _temp5$1(plugin_1) {
13532
+ function _temp5$2(plugin_1) {
13546
13533
  return plugin_1.homePage?.additionalChildrenStart;
13547
13534
  }
13548
- function _temp4$1(plugin) {
13535
+ function _temp4$2(plugin) {
13549
13536
  return plugin.homePage?.includeSection;
13550
13537
  }
13551
- function _temp3$2(e_1) {
13538
+ function _temp3$3(e_1) {
13552
13539
  return !e_1.group;
13553
13540
  }
13554
13541
  function _temp2$5(entry) {
@@ -13900,7 +13887,9 @@
13900
13887
  ] }) : void 0
13901
13888
  };
13902
13889
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13903
- enumValues && /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { size: "large", error, fullWidth: true, onValueChange: (v) => onChange(v), ...fieldProps, renderValue: (option) => {
13890
+ enumValues && /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { size: "large", error, fullWidth: true, onValueChange: (v) => {
13891
+ onChange(v);
13892
+ }, ...fieldProps, renderValue: (option) => {
13904
13893
  const enumConfig = enumValues.find((e_1) => e_1.id === option);
13905
13894
  if (!enumConfig) return option;
13906
13895
  return `${enumConfig.id} - ${enumConfig.label}`;
@@ -14968,7 +14957,7 @@
14968
14957
  }
14969
14958
  let t13;
14970
14959
  if ($[20] !== disabled || $[21] !== handleClearClick || $[22] !== property.clearable) {
14971
- t13 = property.clearable && !disabled && /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { onClick: handleClearClick, children: /* @__PURE__ */ jsxRuntime.jsx(ui.CloseIcon, {}) });
14960
+ t13 = property.clearable && !disabled && /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", onClick: handleClearClick, children: /* @__PURE__ */ jsxRuntime.jsx(ui.CloseIcon, { size: "small" }) });
14972
14961
  $[20] = disabled;
14973
14962
  $[21] = handleClearClick;
14974
14963
  $[22] = property.clearable;
@@ -15081,7 +15070,7 @@
15081
15070
  ] }, enumKey);
15082
15071
  }, [enumValues, setValue, value]);
15083
15072
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15084
- /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelect, { className: "w-full mt-2", size, value: validValue ? value.map((v_0) => v_0.toString()) : [], disabled, modalPopover: true, label: /* @__PURE__ */ jsxRuntime.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) => {
15073
+ /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelect, { className: "w-full mt-2", size, value: validValue ? value.map((v_0) => v_0?.toString()) : [], disabled, modalPopover: true, label: /* @__PURE__ */ jsxRuntime.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) => {
15085
15074
  let newValue;
15086
15075
  if (of && of?.dataType === "number") {
15087
15076
  newValue = updatedValue ? updatedValue.map((e_1) => parseFloat(e_1)) : [];
@@ -15411,15 +15400,161 @@
15411
15400
  }
15412
15401
  return t12;
15413
15402
  }
15403
+ function SortableStorageItem(t0) {
15404
+ const $ = reactCompilerRuntime.c(35);
15405
+ const {
15406
+ id,
15407
+ entry,
15408
+ property,
15409
+ metadata,
15410
+ storagePathBuilder,
15411
+ onFileUploadComplete,
15412
+ onClear,
15413
+ disabled
15414
+ } = t0;
15415
+ let t1;
15416
+ if ($[0] !== id) {
15417
+ t1 = {
15418
+ id
15419
+ };
15420
+ $[0] = id;
15421
+ $[1] = t1;
15422
+ } else {
15423
+ t1 = $[1];
15424
+ }
15425
+ const {
15426
+ attributes,
15427
+ listeners: listeners2,
15428
+ setNodeRef,
15429
+ transform,
15430
+ transition,
15431
+ isDragging
15432
+ } = sortable.useSortable(t1);
15433
+ let t2;
15434
+ if ($[2] !== transform) {
15435
+ t2 = utilities.CSS.Transform.toString(transform);
15436
+ $[2] = transform;
15437
+ $[3] = t2;
15438
+ } else {
15439
+ t2 = $[3];
15440
+ }
15441
+ const t3 = isDragging ? 100 : void 0;
15442
+ const t4 = isDragging ? 0.8 : 1;
15443
+ let t5;
15444
+ if ($[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== transition) {
15445
+ t5 = {
15446
+ transform: t2,
15447
+ transition,
15448
+ zIndex: t3,
15449
+ opacity: t4
15450
+ };
15451
+ $[4] = t2;
15452
+ $[5] = t3;
15453
+ $[6] = t4;
15454
+ $[7] = transition;
15455
+ $[8] = t5;
15456
+ } else {
15457
+ t5 = $[8];
15458
+ }
15459
+ const style = t5;
15460
+ const getImageSizeNumber = _temp$a;
15461
+ let child;
15462
+ if (entry.storagePathOrDownloadUrl) {
15463
+ const t62 = `storage_preview_${entry.storagePathOrDownloadUrl}`;
15464
+ let t72;
15465
+ if ($[9] !== entry.storagePathOrDownloadUrl || $[10] !== onClear) {
15466
+ t72 = () => onClear(entry.storagePathOrDownloadUrl);
15467
+ $[9] = entry.storagePathOrDownloadUrl;
15468
+ $[10] = onClear;
15469
+ $[11] = t72;
15470
+ } else {
15471
+ t72 = $[11];
15472
+ }
15473
+ let t8;
15474
+ if ($[12] !== disabled || $[13] !== entry.size || $[14] !== entry.storagePathOrDownloadUrl || $[15] !== property || $[16] !== t62 || $[17] !== t72) {
15475
+ t8 = /* @__PURE__ */ jsxRuntime.jsx(StorageItemPreview, { name: t62, property, disabled, value: entry.storagePathOrDownloadUrl, onRemove: t72, size: entry.size });
15476
+ $[12] = disabled;
15477
+ $[13] = entry.size;
15478
+ $[14] = entry.storagePathOrDownloadUrl;
15479
+ $[15] = property;
15480
+ $[16] = t62;
15481
+ $[17] = t72;
15482
+ $[18] = t8;
15483
+ } else {
15484
+ t8 = $[18];
15485
+ }
15486
+ child = t8;
15487
+ } else {
15488
+ if (entry.file) {
15489
+ let t62;
15490
+ if ($[19] !== entry.file || $[20] !== storagePathBuilder) {
15491
+ t62 = storagePathBuilder(entry.file);
15492
+ $[19] = entry.file;
15493
+ $[20] = storagePathBuilder;
15494
+ $[21] = t62;
15495
+ } else {
15496
+ t62 = $[21];
15497
+ }
15498
+ const t72 = getImageSizeNumber(entry.size);
15499
+ let t8;
15500
+ if ($[22] !== entry || $[23] !== metadata || $[24] !== onFileUploadComplete || $[25] !== t62 || $[26] !== t72) {
15501
+ t8 = /* @__PURE__ */ jsxRuntime.jsx(StorageUploadProgress, { entry, metadata, storagePath: t62, onFileUploadComplete, imageSize: t72, simple: false });
15502
+ $[22] = entry;
15503
+ $[23] = metadata;
15504
+ $[24] = onFileUploadComplete;
15505
+ $[25] = t62;
15506
+ $[26] = t72;
15507
+ $[27] = t8;
15508
+ } else {
15509
+ t8 = $[27];
15510
+ }
15511
+ child = t8;
15512
+ }
15513
+ }
15514
+ let t6;
15515
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
15516
+ t6 = ui.cls("rounded-md m-1");
15517
+ $[28] = t6;
15518
+ } else {
15519
+ t6 = $[28];
15520
+ }
15521
+ let t7;
15522
+ if ($[29] !== attributes || $[30] !== child || $[31] !== listeners2 || $[32] !== setNodeRef || $[33] !== style) {
15523
+ t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setNodeRef, style, ...attributes, ...listeners2, className: t6, tabIndex: -1, children: child });
15524
+ $[29] = attributes;
15525
+ $[30] = child;
15526
+ $[31] = listeners2;
15527
+ $[32] = setNodeRef;
15528
+ $[33] = style;
15529
+ $[34] = t7;
15530
+ } else {
15531
+ t7 = $[34];
15532
+ }
15533
+ return t7;
15534
+ }
15535
+ function _temp$a(previewSize) {
15536
+ switch (previewSize) {
15537
+ case "small": {
15538
+ return 40;
15539
+ }
15540
+ case "medium": {
15541
+ return 118;
15542
+ }
15543
+ case "large": {
15544
+ return 220;
15545
+ }
15546
+ default: {
15547
+ return 118;
15548
+ }
15549
+ }
15550
+ }
15414
15551
  function FileDropComponent(t0) {
15415
- const $ = reactCompilerRuntime.c(64);
15552
+ const $ = reactCompilerRuntime.c(63);
15416
15553
  const {
15417
15554
  storage,
15418
15555
  disabled,
15419
- isDraggingOver,
15420
15556
  onFilesAdded,
15421
15557
  multipleFilesSupported,
15422
- droppableProvided,
15423
15558
  autoFocus,
15424
15559
  internalValue,
15425
15560
  property,
@@ -15427,23 +15562,23 @@
15427
15562
  metadata,
15428
15563
  storagePathBuilder,
15429
15564
  onFileUploadComplete,
15430
- size,
15431
15565
  name,
15432
- helpText
15566
+ helpText,
15567
+ isDndItemDragging
15433
15568
  } = t0;
15434
15569
  const snackbarContext = useSnackbarController();
15435
15570
  let t1;
15436
15571
  if ($[0] !== storage.acceptedFiles) {
15437
- t1 = storage.acceptedFiles ? storage.acceptedFiles.map(_temp$a).reduce(_temp2$4, {}) : void 0;
15572
+ t1 = storage.acceptedFiles ? storage.acceptedFiles.reduce(_temp2$4, {}) : void 0;
15438
15573
  $[0] = storage.acceptedFiles;
15439
15574
  $[1] = t1;
15440
15575
  } else {
15441
15576
  t1 = $[1];
15442
15577
  }
15443
- const t2 = disabled || isDraggingOver;
15578
+ const t2 = disabled || isDndItemDragging;
15444
15579
  let t3;
15445
15580
  if ($[2] !== snackbarContext || $[3] !== storage.maxSize) {
15446
- t3 = (fileRejections, event) => {
15581
+ t3 = (fileRejections) => {
15447
15582
  for (const fileRejection of fileRejections) {
15448
15583
  for (const error of fileRejection.errors) {
15449
15584
  console.error("Error uploading file: ", error);
@@ -15505,170 +15640,154 @@
15505
15640
  }
15506
15641
  const t6 = disabled ? ui.fieldBackgroundDisabledMixin : ui.fieldBackgroundHoverMixin;
15507
15642
  const t7 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15508
- const t8 = multipleFilesSupported && internalValue.length ? "" : "flex";
15643
+ const t8 = multipleFilesSupported && internalValue.length === 0 && "flex";
15509
15644
  const t9 = !isDragActive;
15510
- let t10;
15511
- if ($[13] !== disabled || $[14] !== isDragAccept || $[15] !== isDragActive || $[16] !== isDragReject || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
15512
- t10 = ui.cls(ui.fieldBackgroundMixin, t6, t7, dropZoneClasses, t8, {
15645
+ const t10 = disabled || isDndItemDragging;
15646
+ let t11;
15647
+ if ($[13] !== isDragAccept || $[14] !== isDragActive || $[15] !== isDragReject || $[16] !== t10 || $[17] !== t6 || $[18] !== t7 || $[19] !== t8 || $[20] !== t9) {
15648
+ t11 = ui.cls(ui.fieldBackgroundMixin, t6, t7, dropZoneClasses, t8, {
15513
15649
  [nonActiveDropClasses]: t9,
15514
15650
  [activeDropClasses]: isDragActive,
15515
15651
  [rejectDropClasses]: isDragReject,
15516
15652
  [acceptDropClasses]: isDragAccept,
15517
- [disabledClasses]: disabled
15653
+ [disabledClasses]: t10
15518
15654
  });
15519
- $[13] = disabled;
15520
- $[14] = isDragAccept;
15521
- $[15] = isDragActive;
15522
- $[16] = isDragReject;
15655
+ $[13] = isDragAccept;
15656
+ $[14] = isDragActive;
15657
+ $[15] = isDragReject;
15658
+ $[16] = t10;
15523
15659
  $[17] = t6;
15524
15660
  $[18] = t7;
15525
15661
  $[19] = t8;
15526
15662
  $[20] = t9;
15527
- $[21] = t10;
15528
- } else {
15529
- t10 = $[21];
15530
- }
15531
- const t11 = droppableProvided.droppableProps;
15532
- const t12 = droppableProvided.innerRef;
15533
- const t13 = multipleFilesSupported && internalValue.length ? "overflow-auto" : "";
15534
- const t14 = multipleFilesSupported && internalValue.length ? "min-h-[180px]" : "min-h-[250px]";
15535
- let t15;
15536
- if ($[22] !== t13 || $[23] !== t14) {
15537
- t15 = ui.cls("flex items-center p-1 no-scrollbar", t13, t14);
15538
- $[22] = t13;
15539
- $[23] = t14;
15540
- $[24] = t15;
15663
+ $[21] = t11;
15541
15664
  } else {
15542
- t15 = $[24];
15665
+ t11 = $[21];
15543
15666
  }
15667
+ const t12 = multipleFilesSupported && internalValue.length ? "flex-row overflow-x-auto" : "flex-col";
15668
+ const t13 = internalValue.length === 0 && "min-h-[250px] justify-center";
15669
+ const t14 = multipleFilesSupported && internalValue.length > 0 && "min-h-[180px]";
15670
+ const t15 = !multipleFilesSupported && internalValue.length > 0 && "min-h-[250px]";
15544
15671
  let t16;
15545
- if ($[25] !== getInputProps) {
15546
- t16 = getInputProps();
15547
- $[25] = getInputProps;
15672
+ if ($[22] !== t12 || $[23] !== t13 || $[24] !== t14 || $[25] !== t15) {
15673
+ t16 = ui.cls("flex items-center p-1 no-scrollbar", t12, t13, t14, t15);
15674
+ $[22] = t12;
15675
+ $[23] = t13;
15676
+ $[24] = t14;
15677
+ $[25] = t15;
15548
15678
  $[26] = t16;
15549
15679
  } else {
15550
15680
  t16 = $[26];
15551
15681
  }
15552
15682
  let t17;
15553
- if ($[27] !== autoFocus || $[28] !== t16) {
15554
- t17 = /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus, ...t16 });
15555
- $[27] = autoFocus;
15556
- $[28] = t16;
15557
- $[29] = t17;
15683
+ if ($[27] !== getInputProps) {
15684
+ t17 = getInputProps();
15685
+ $[27] = getInputProps;
15686
+ $[28] = t17;
15558
15687
  } else {
15559
- t17 = $[29];
15688
+ t17 = $[28];
15560
15689
  }
15561
15690
  let t18;
15562
- if ($[30] !== disabled || $[31] !== internalValue || $[32] !== metadata || $[33] !== name || $[34] !== onClear || $[35] !== onFileUploadComplete || $[36] !== property || $[37] !== size || $[38] !== storagePathBuilder) {
15563
- let t192;
15564
- if ($[40] !== disabled || $[41] !== metadata || $[42] !== name || $[43] !== onClear || $[44] !== onFileUploadComplete || $[45] !== property || $[46] !== size || $[47] !== storagePathBuilder) {
15565
- t192 = (entry, index) => {
15566
- let child;
15567
- if (entry.storagePathOrDownloadUrl) {
15568
- child = /* @__PURE__ */ jsxRuntime.jsx(StorageItemPreview, { name: `storage_preview_${entry.storagePathOrDownloadUrl}`, property, disabled, value: entry.storagePathOrDownloadUrl, onRemove: onClear, size: entry.size });
15569
- } else {
15570
- if (entry.file) {
15571
- child = /* @__PURE__ */ jsxRuntime.jsx(StorageUploadProgress, { entry, metadata, storagePath: storagePathBuilder(entry.file), onFileUploadComplete, imageSize: size === "large" ? 220 : 118, simple: false });
15572
- }
15573
- }
15574
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: `array_field_${name}_${entry.id}`, index, children: (provided, snapshot) => /* @__PURE__ */ jsxRuntime.jsx("div", { tabIndex: -1, ref: provided.innerRef, ...provided.draggableProps, ...provided.dragHandleProps, className: ui.cls("rounded-md"), style: {
15575
- ...provided.draggableProps.style
15576
- }, children: child }) }, `array_field_${name}_${entry.id}`);
15577
- };
15578
- $[40] = disabled;
15579
- $[41] = metadata;
15580
- $[42] = name;
15581
- $[43] = onClear;
15582
- $[44] = onFileUploadComplete;
15583
- $[45] = property;
15584
- $[46] = size;
15585
- $[47] = storagePathBuilder;
15586
- $[48] = t192;
15587
- } else {
15588
- t192 = $[48];
15589
- }
15590
- t18 = internalValue.map(t192);
15591
- $[30] = disabled;
15592
- $[31] = internalValue;
15593
- $[32] = metadata;
15594
- $[33] = name;
15595
- $[34] = onClear;
15596
- $[35] = onFileUploadComplete;
15597
- $[36] = property;
15598
- $[37] = size;
15599
- $[38] = storagePathBuilder;
15600
- $[39] = t18;
15601
- } else {
15602
- t18 = $[39];
15691
+ if ($[29] !== autoFocus || $[30] !== t17) {
15692
+ t18 = /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus, ...t17 });
15693
+ $[29] = autoFocus;
15694
+ $[30] = t17;
15695
+ $[31] = t18;
15696
+ } else {
15697
+ t18 = $[31];
15603
15698
  }
15604
15699
  let t19;
15605
- if ($[49] !== droppableProvided.droppableProps || $[50] !== droppableProvided.innerRef || $[51] !== droppableProvided.placeholder || $[52] !== t15 || $[53] !== t17 || $[54] !== t18) {
15606
- t19 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ...t11, ref: t12, className: t15, children: [
15607
- t17,
15700
+ if ($[32] !== disabled || $[33] !== internalValue || $[34] !== metadata || $[35] !== multipleFilesSupported || $[36] !== name || $[37] !== onClear || $[38] !== onFileUploadComplete || $[39] !== property || $[40] !== storagePathBuilder) {
15701
+ let t202;
15702
+ if ($[42] !== disabled || $[43] !== metadata || $[44] !== multipleFilesSupported || $[45] !== name || $[46] !== onClear || $[47] !== onFileUploadComplete || $[48] !== property || $[49] !== storagePathBuilder) {
15703
+ t202 = (entry) => /* @__PURE__ */ jsxRuntime.jsx(SortableStorageItem, { id: entry.id, entry, property, name, metadata, storagePathBuilder, onFileUploadComplete, onClear, disabled, isSortable: multipleFilesSupported }, entry.id);
15704
+ $[42] = disabled;
15705
+ $[43] = metadata;
15706
+ $[44] = multipleFilesSupported;
15707
+ $[45] = name;
15708
+ $[46] = onClear;
15709
+ $[47] = onFileUploadComplete;
15710
+ $[48] = property;
15711
+ $[49] = storagePathBuilder;
15712
+ $[50] = t202;
15713
+ } else {
15714
+ t202 = $[50];
15715
+ }
15716
+ t19 = internalValue.map(t202);
15717
+ $[32] = disabled;
15718
+ $[33] = internalValue;
15719
+ $[34] = metadata;
15720
+ $[35] = multipleFilesSupported;
15721
+ $[36] = name;
15722
+ $[37] = onClear;
15723
+ $[38] = onFileUploadComplete;
15724
+ $[39] = property;
15725
+ $[40] = storagePathBuilder;
15726
+ $[41] = t19;
15727
+ } else {
15728
+ t19 = $[41];
15729
+ }
15730
+ let t20;
15731
+ if ($[51] !== t16 || $[52] !== t18 || $[53] !== t19) {
15732
+ t20 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t16, children: [
15608
15733
  t18,
15609
- droppableProvided.placeholder
15734
+ t19
15610
15735
  ] });
15611
- $[49] = droppableProvided.droppableProps;
15612
- $[50] = droppableProvided.innerRef;
15613
- $[51] = droppableProvided.placeholder;
15614
- $[52] = t15;
15615
- $[53] = t17;
15616
- $[54] = t18;
15617
- $[55] = t19;
15736
+ $[51] = t16;
15737
+ $[52] = t18;
15738
+ $[53] = t19;
15739
+ $[54] = t20;
15618
15740
  } else {
15619
- t19 = $[55];
15741
+ t20 = $[54];
15620
15742
  }
15621
- const t20 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15622
- let t21;
15623
- if ($[56] !== helpText || $[57] !== t20) {
15624
- t21 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow min-h-[38px] box-border m-2 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { align: "center", variant: "label", className: t20, children: helpText }) });
15625
- $[56] = helpText;
15626
- $[57] = t20;
15627
- $[58] = t21;
15743
+ const t21 = disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "";
15744
+ let t22;
15745
+ if ($[55] !== helpText || $[56] !== t21) {
15746
+ t22 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow min-h-[38px] box-border m-2 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { align: "center", variant: "label", className: t21, children: helpText }) });
15747
+ $[55] = helpText;
15748
+ $[56] = t21;
15749
+ $[57] = t22;
15628
15750
  } else {
15629
- t21 = $[58];
15751
+ t22 = $[57];
15630
15752
  }
15631
- let t22;
15632
- if ($[59] !== t10 || $[60] !== t19 || $[61] !== t21 || $[62] !== t5) {
15633
- t22 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ...t5, className: t10, children: [
15634
- t19,
15635
- t21
15753
+ let t23;
15754
+ if ($[58] !== t11 || $[59] !== t20 || $[60] !== t22 || $[61] !== t5) {
15755
+ t23 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ...t5, className: t11, children: [
15756
+ t20,
15757
+ t22
15636
15758
  ] });
15637
- $[59] = t10;
15638
- $[60] = t19;
15639
- $[61] = t21;
15640
- $[62] = t5;
15641
- $[63] = t22;
15759
+ $[58] = t11;
15760
+ $[59] = t20;
15761
+ $[60] = t22;
15762
+ $[61] = t5;
15763
+ $[62] = t23;
15642
15764
  } else {
15643
- t22 = $[63];
15765
+ t23 = $[62];
15644
15766
  }
15645
- return t22;
15767
+ return t23;
15646
15768
  }
15647
- function _temp2$4(a, b) {
15769
+ function _temp2$4(acc, ext) {
15648
15770
  return {
15649
- ...a,
15650
- ...b
15771
+ ...acc,
15772
+ [ext]: []
15651
15773
  };
15652
15774
  }
15653
- function _temp$a(e) {
15654
- return {
15655
- [e]: []
15656
- };
15657
- }
15658
- function StorageUpload({
15659
- property,
15660
- name,
15661
- value,
15662
- setInternalValue,
15663
- onChange,
15664
- multipleFilesSupported,
15665
- onFileUploadComplete,
15666
- disabled,
15667
- onFilesAdded,
15668
- autoFocus,
15669
- storage,
15670
- storagePathBuilder
15671
- }) {
15775
+ function StorageUpload(t0) {
15776
+ const $ = reactCompilerRuntime.c(44);
15777
+ const {
15778
+ property,
15779
+ name,
15780
+ value,
15781
+ setInternalValue,
15782
+ onChange,
15783
+ multipleFilesSupported,
15784
+ onFileUploadComplete,
15785
+ disabled,
15786
+ onFilesAdded,
15787
+ autoFocus,
15788
+ storage,
15789
+ storagePathBuilder
15790
+ } = t0;
15672
15791
  if (multipleFilesSupported) {
15673
15792
  const arrayProperty = property;
15674
15793
  if (arrayProperty.of) {
@@ -15683,41 +15802,208 @@
15683
15802
  }
15684
15803
  }
15685
15804
  const metadata = storage?.metadata;
15686
- const size = multipleFilesSupported ? "medium" : "large";
15687
- const moveItem = React.useCallback((fromIndex, toIndex) => {
15688
- if (!multipleFilesSupported) return;
15689
- const newValue = [...value];
15690
- const item = newValue[fromIndex];
15691
- newValue.splice(fromIndex, 1);
15692
- newValue.splice(toIndex, 0, item);
15693
- setInternalValue(newValue);
15694
- const fieldValue = newValue.filter((e) => !!e.storagePathOrDownloadUrl).map((e_0) => e_0.storagePathOrDownloadUrl);
15695
- onChange(fieldValue);
15696
- }, [multipleFilesSupported, onChange, setInternalValue, value]);
15697
- const onDragEnd = React.useCallback((result) => {
15698
- if (!result.destination) {
15699
- return;
15700
- }
15701
- moveItem(result.source.index, result.destination.index);
15702
- }, [moveItem]);
15703
- const onClear = React.useCallback((clearedStoragePathOrDownloadUrl) => {
15704
- if (multipleFilesSupported) {
15705
- const newValue_0 = value.filter((v) => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);
15706
- onChange(newValue_0.filter((v_0) => !!v_0.storagePathOrDownloadUrl).map((v_1) => v_1.storagePathOrDownloadUrl));
15805
+ const [isDndItemDragging, setIsDndItemDragging] = React.useState(false);
15806
+ let t1;
15807
+ if ($[0] !== multipleFilesSupported || $[1] !== onChange || $[2] !== setInternalValue || $[3] !== value) {
15808
+ t1 = (fromIndex, toIndex) => {
15809
+ if (!multipleFilesSupported || fromIndex === toIndex) {
15810
+ return;
15811
+ }
15812
+ const newValue = [...value];
15813
+ const item = newValue[fromIndex];
15814
+ newValue.splice(fromIndex, 1);
15815
+ newValue.splice(toIndex, 0, item);
15816
+ setInternalValue(newValue);
15817
+ const fieldValue = newValue.filter(_temp3$2).map(_temp4$1);
15818
+ onChange(fieldValue);
15819
+ };
15820
+ $[0] = multipleFilesSupported;
15821
+ $[1] = onChange;
15822
+ $[2] = setInternalValue;
15823
+ $[3] = value;
15824
+ $[4] = t1;
15825
+ } else {
15826
+ t1 = $[4];
15827
+ }
15828
+ const moveItem = t1;
15829
+ let t2;
15830
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
15831
+ t2 = {
15832
+ activationConstraint: {
15833
+ distance: 5
15834
+ }
15835
+ };
15836
+ $[5] = t2;
15837
+ } else {
15838
+ t2 = $[5];
15839
+ }
15840
+ let t3;
15841
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
15842
+ t3 = {
15843
+ coordinateGetter: sortable.sortableKeyboardCoordinates
15844
+ };
15845
+ $[6] = t3;
15846
+ } else {
15847
+ t3 = $[6];
15848
+ }
15849
+ const sensors = core.useSensors(core.useSensor(core.PointerSensor, t2), core.useSensor(core.KeyboardSensor, t3));
15850
+ let t4;
15851
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
15852
+ t4 = (event) => {
15853
+ setIsDndItemDragging(true);
15854
+ };
15855
+ $[7] = t4;
15856
+ } else {
15857
+ t4 = $[7];
15858
+ }
15859
+ const handleDragStart = t4;
15860
+ let t5;
15861
+ if ($[8] !== moveItem || $[9] !== value) {
15862
+ t5 = (event_0) => {
15863
+ setIsDndItemDragging(false);
15864
+ const {
15865
+ active,
15866
+ over
15867
+ } = event_0;
15868
+ if (over && active.id !== over.id) {
15869
+ const oldIndex = value.findIndex((item_0) => item_0.id === active.id);
15870
+ const newIndex = value.findIndex((item_1) => item_1.id === over.id);
15871
+ if (oldIndex !== -1 && newIndex !== -1) {
15872
+ moveItem(oldIndex, newIndex);
15873
+ }
15874
+ }
15875
+ };
15876
+ $[8] = moveItem;
15877
+ $[9] = value;
15878
+ $[10] = t5;
15879
+ } else {
15880
+ t5 = $[10];
15881
+ }
15882
+ const handleDragEnd = t5;
15883
+ let t6;
15884
+ if ($[11] !== multipleFilesSupported || $[12] !== onChange || $[13] !== setInternalValue || $[14] !== value) {
15885
+ t6 = (clearedStoragePathOrDownloadUrl) => {
15886
+ let newValue_0;
15887
+ if (multipleFilesSupported) {
15888
+ newValue_0 = value.filter((v) => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);
15889
+ onChange(newValue_0.filter(_temp5$1).map(_temp6$1));
15890
+ } else {
15891
+ newValue_0 = [];
15892
+ onChange(null);
15893
+ }
15707
15894
  setInternalValue(newValue_0);
15895
+ };
15896
+ $[11] = multipleFilesSupported;
15897
+ $[12] = onChange;
15898
+ $[13] = setInternalValue;
15899
+ $[14] = value;
15900
+ $[15] = t6;
15901
+ } else {
15902
+ t6 = $[15];
15903
+ }
15904
+ const onClear = t6;
15905
+ 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";
15906
+ const renderProperty = multipleFilesSupported ? property.of : property;
15907
+ let t7;
15908
+ 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) {
15909
+ t7 = {
15910
+ storage,
15911
+ disabled,
15912
+ onFilesAdded,
15913
+ multipleFilesSupported,
15914
+ autoFocus,
15915
+ internalValue: value,
15916
+ property: renderProperty,
15917
+ onClear,
15918
+ metadata,
15919
+ storagePathBuilder,
15920
+ onFileUploadComplete,
15921
+ name,
15922
+ helpText,
15923
+ isDndItemDragging
15924
+ };
15925
+ $[16] = autoFocus;
15926
+ $[17] = disabled;
15927
+ $[18] = helpText;
15928
+ $[19] = isDndItemDragging;
15929
+ $[20] = metadata;
15930
+ $[21] = multipleFilesSupported;
15931
+ $[22] = name;
15932
+ $[23] = onClear;
15933
+ $[24] = onFileUploadComplete;
15934
+ $[25] = onFilesAdded;
15935
+ $[26] = renderProperty;
15936
+ $[27] = storage;
15937
+ $[28] = storagePathBuilder;
15938
+ $[29] = value;
15939
+ $[30] = t7;
15940
+ } else {
15941
+ t7 = $[30];
15942
+ }
15943
+ const fileDropProps = t7;
15944
+ if (multipleFilesSupported) {
15945
+ let t8;
15946
+ if ($[31] !== value) {
15947
+ t8 = value.map(_temp7);
15948
+ $[31] = value;
15949
+ $[32] = t8;
15708
15950
  } else {
15709
- onChange(null);
15710
- setInternalValue([]);
15951
+ t8 = $[32];
15711
15952
  }
15712
- }, [value, multipleFilesSupported, onChange]);
15713
- 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";
15714
- const renderProperty = multipleFilesSupported ? property.of : property;
15715
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: `droppable_${name}`, direction: "horizontal", renderClone: (provided, snapshot, rubric) => {
15716
- const entry = value[rubric.source.index];
15717
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: provided.innerRef, ...provided.draggableProps, ...provided.dragHandleProps, style: provided.draggableProps.style, className: "rounded", children: /* @__PURE__ */ jsxRuntime.jsx(StorageItemPreview, { name: `storage_preview_${entry.storagePathOrDownloadUrl}`, placeholder: true, property: renderProperty, disabled: true, value: entry.storagePathOrDownloadUrl, onRemove: onClear, size: entry.size }) });
15718
- }, children: (provided_0, snapshot_0) => {
15719
- return /* @__PURE__ */ jsxRuntime.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 });
15720
- } }) });
15953
+ let t9;
15954
+ if ($[33] !== fileDropProps) {
15955
+ t9 = /* @__PURE__ */ jsxRuntime.jsx(FileDropComponent, { ...fileDropProps });
15956
+ $[33] = fileDropProps;
15957
+ $[34] = t9;
15958
+ } else {
15959
+ t9 = $[34];
15960
+ }
15961
+ let t10;
15962
+ if ($[35] !== t8 || $[36] !== t9) {
15963
+ t10 = /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: t8, strategy: sortable.horizontalListSortingStrategy, children: t9 });
15964
+ $[35] = t8;
15965
+ $[36] = t9;
15966
+ $[37] = t10;
15967
+ } else {
15968
+ t10 = $[37];
15969
+ }
15970
+ let t11;
15971
+ if ($[38] !== handleDragEnd || $[39] !== sensors || $[40] !== t10) {
15972
+ t11 = /* @__PURE__ */ jsxRuntime.jsx(core.DndContext, { sensors, collisionDetection: core.closestCenter, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: t10 });
15973
+ $[38] = handleDragEnd;
15974
+ $[39] = sensors;
15975
+ $[40] = t10;
15976
+ $[41] = t11;
15977
+ } else {
15978
+ t11 = $[41];
15979
+ }
15980
+ return t11;
15981
+ } else {
15982
+ let t8;
15983
+ if ($[42] !== fileDropProps) {
15984
+ t8 = /* @__PURE__ */ jsxRuntime.jsx(FileDropComponent, { ...fileDropProps, isDndItemDragging: false });
15985
+ $[42] = fileDropProps;
15986
+ $[43] = t8;
15987
+ } else {
15988
+ t8 = $[43];
15989
+ }
15990
+ return t8;
15991
+ }
15992
+ }
15993
+ function _temp7(v_2) {
15994
+ return v_2.id;
15995
+ }
15996
+ function _temp6$1(v_1) {
15997
+ return v_1.storagePathOrDownloadUrl;
15998
+ }
15999
+ function _temp5$1(v_0) {
16000
+ return !!v_0.storagePathOrDownloadUrl;
16001
+ }
16002
+ function _temp4$1(e_0) {
16003
+ return e_0.storagePathOrDownloadUrl;
16004
+ }
16005
+ function _temp3$2(e) {
16006
+ return !!e.storagePathOrDownloadUrl;
15721
16007
  }
15722
16008
  function TextFieldBinding(t0) {
15723
16009
  const $ = reactCompilerRuntime.c(52);
@@ -17527,7 +17813,7 @@
17527
17813
  }
17528
17814
  const buildEntry = t2;
17529
17815
  const canAddElements = !property.disabled && !isSubmitting && !disabled && (property.canAddElements || property.canAddElements === void 0);
17530
- const sortable = property.sortable === void 0 ? true : property.sortable;
17816
+ const sortable2 = property.sortable === void 0 ? true : property.sortable;
17531
17817
  const t3 = property.name ? "Add entry to " + property.name : "Add entry";
17532
17818
  const t4 = isSubmitting || Boolean(property.disabled);
17533
17819
  let t5;
@@ -17549,12 +17835,12 @@
17549
17835
  }
17550
17836
  const t7 = property.widthPercentage !== void 0 ? "mt-8" : void 0;
17551
17837
  let t8;
17552
- if ($[18] !== buildEntry || $[19] !== canAddElements || $[20] !== propertyKey || $[21] !== sortable || $[22] !== t3 || $[23] !== t4 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== value) {
17553
- t8 = /* @__PURE__ */ jsxRuntime.jsx(ArrayContainer, { droppableId: propertyKey, addLabel: t3, value, buildEntry, onInternalIdAdded: setLastAddedId, disabled: t4, canAddElements, sortable, newDefaultEntry: t5, onValueChange: t6, className: t7 });
17838
+ if ($[18] !== buildEntry || $[19] !== canAddElements || $[20] !== propertyKey || $[21] !== sortable2 || $[22] !== t3 || $[23] !== t4 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== value) {
17839
+ t8 = /* @__PURE__ */ jsxRuntime.jsx(ArrayContainer, { droppableId: propertyKey, addLabel: t3, value, buildEntry, onInternalIdAdded: setLastAddedId, disabled: t4, canAddElements, sortable: sortable2, newDefaultEntry: t5, onValueChange: t6, className: t7 });
17554
17840
  $[18] = buildEntry;
17555
17841
  $[19] = canAddElements;
17556
17842
  $[20] = propertyKey;
17557
- $[21] = sortable;
17843
+ $[21] = sortable2;
17558
17844
  $[22] = t3;
17559
17845
  $[23] = t4;
17560
17846
  $[24] = t5;
@@ -18919,7 +19205,7 @@
18919
19205
  deleteEntityClicked && /* @__PURE__ */ jsxRuntime.jsx(DeleteEntityDialog, { entityOrEntitiesToDelete: deleteEntityClicked, path: fullPath, collection, callbacks: collection.callbacks, open: Boolean(deleteEntityClicked), onEntityDelete: internalOnEntityDelete, onMultipleEntitiesDelete: internalOnMultipleEntitiesDelete, onClose: () => setDeleteEntityClicked(void 0) })
18920
19206
  ] });
18921
19207
  }, (a, b) => {
18922
- 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.exportable, b.exportable) && equal(a.history, b.history) && equal(a.forceFilter, b.forceFilter);
19208
+ 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);
18923
19209
  });
18924
19210
  function EntitiesCount({
18925
19211
  fullPath,
@@ -19650,227 +19936,182 @@
19650
19936
  ...a,
19651
19937
  ...b
19652
19938
  }), {}) : {};
19653
- function ArrayContainer({
19654
- droppableId,
19655
- addLabel,
19656
- value,
19657
- disabled = false,
19939
+ function SortableItem({
19940
+ id,
19941
+ index,
19942
+ size,
19943
+ disabled,
19658
19944
  buildEntry,
19659
- size = "medium",
19660
- onInternalIdAdded,
19661
- includeAddButton: deprecatedIncludeAddButton,
19662
- canAddElements: canAddElementsProp = true,
19663
- sortable = true,
19664
- newDefaultEntry,
19665
- onValueChange,
19666
- className,
19667
- min = 0,
19668
- max = Infinity
19945
+ remove,
19946
+ copy,
19947
+ addInIndex,
19948
+ canAddElements,
19949
+ sortable: sortable$1,
19950
+ storedProps,
19951
+ updateItemCustomProps
19669
19952
  }) {
19670
- const canAddElements = (canAddElementsProp || canAddElementsProp === void 0) && (deprecatedIncludeAddButton === void 0 || deprecatedIncludeAddButton);
19671
- const hasValue = value && Array.isArray(value) && value.length > 0;
19672
- const internalIdsRef = React.useRef(buildIdsMap(value));
19673
- const [internalIds, setInternalIds] = React.useState(hasValue ? Object.values(internalIdsRef.current) : []);
19674
- const itemCustomPropsRef = React.useRef({});
19675
- const updateItemCustomProps = React.useCallback((internalId, customProps) => {
19676
- itemCustomPropsRef.current[internalId] = customProps;
19677
- }, []);
19678
- React.useEffect(() => {
19679
- if (hasValue && value && value.length !== internalIds.length) {
19680
- const newInternalIds = value.map((v, index) => {
19681
- const hashValue = getHashValue(v) + index;
19682
- if (hashValue in internalIdsRef.current) {
19683
- return internalIdsRef.current[hashValue];
19684
- } else {
19685
- const newInternalId = getRandomId();
19686
- internalIdsRef.current[hashValue] = newInternalId;
19687
- return newInternalId;
19688
- }
19689
- });
19690
- setInternalIds(newInternalIds);
19691
- }
19692
- }, [hasValue, internalIds.length, value]);
19693
- const insertInEnd = (e) => {
19694
- e.preventDefault();
19695
- if (disabled || (value ?? []).length >= max) return;
19696
- const id = getRandomId();
19697
- const newIds = [...internalIds, id];
19698
- if (onInternalIdAdded) onInternalIdAdded(id);
19699
- setInternalIds(newIds);
19700
- onValueChange([...value ?? [], newDefaultEntry]);
19701
- };
19702
- const remove = (index_0) => {
19703
- if ((value ?? []).length <= min) return;
19704
- const newIds_0 = [...internalIds];
19705
- newIds_0.splice(index_0, 1);
19706
- setInternalIds(newIds_0);
19707
- onValueChange(value.filter((_, i) => i !== index_0));
19708
- };
19709
- const copy = (index_1) => {
19710
- if ((value ?? []).length >= max) return;
19711
- const id_0 = getRandomId();
19712
- const copyingItem = value[index_1];
19713
- const newIds_1 = [...internalIds.slice(0, index_1 + 1), id_0, ...internalIds.slice(index_1 + 1)];
19714
- if (onInternalIdAdded) onInternalIdAdded(id_0);
19715
- setInternalIds(newIds_1);
19716
- onValueChange([...value.slice(0, index_1 + 1), copyingItem, ...value.slice(index_1 + 1)]);
19717
- };
19718
- const addInIndex = (index_2) => {
19719
- if ((value ?? []).length >= max) return;
19720
- const id_1 = getRandomId();
19721
- const newIds_2 = [...internalIds.slice(0, index_2), id_1, ...internalIds.slice(index_2)];
19722
- if (onInternalIdAdded) onInternalIdAdded(id_1);
19723
- setInternalIds(newIds_2);
19724
- onValueChange([...value.slice(0, index_2), newDefaultEntry, ...value.slice(index_2)]);
19725
- };
19726
- const onDragEnd = (result) => {
19727
- if (!result.destination) {
19728
- return;
19729
- }
19730
- const sourceIndex = result.source.index;
19731
- const destinationIndex = result.destination.index;
19732
- const newIds_3 = [...internalIds];
19733
- const temp = newIds_3[sourceIndex];
19734
- newIds_3[sourceIndex] = newIds_3[destinationIndex];
19735
- newIds_3[destinationIndex] = temp;
19736
- setInternalIds(newIds_3);
19737
- onValueChange(arrayMove(value, sourceIndex, destinationIndex));
19953
+ const {
19954
+ attributes,
19955
+ listeners: listeners2,
19956
+ setNodeRef,
19957
+ transform,
19958
+ transition,
19959
+ isDragging
19960
+ } = sortable$1 ? sortable.useSortable({
19961
+ id
19962
+ }) : {
19963
+ attributes: {},
19964
+ listeners: {},
19965
+ setNodeRef: (node) => {
19966
+ },
19967
+ transform: null,
19968
+ transition: void 0,
19969
+ isDragging: false
19738
19970
  };
19739
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId, renderClone: (provided, snapshot, rubric) => {
19740
- const index_3 = rubric.source.index;
19741
- const internalId_0 = internalIds[index_3];
19742
- return /* @__PURE__ */ jsxRuntime.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 });
19743
- }, children: (droppableProvided, droppableSnapshot) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("space-y-1", className), ...droppableProvided.droppableProps, ref: droppableProvided.innerRef, children: [
19744
- hasValue && internalIds.map((internalId_1, index_4) => {
19745
- return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled || !sortable, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsxRuntime.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}`);
19746
- }),
19747
- droppableProvided.placeholder,
19748
- canAddElements && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value?.length >= max, startIcon: /* @__PURE__ */ jsxRuntime.jsx(ui.AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
19749
- ] }) }) });
19971
+ const style = transform ? {
19972
+ transform: utilities.CSS.Transform.toString(transform),
19973
+ transition
19974
+ } : {};
19975
+ const dragHandleProps = sortable$1 ? {
19976
+ ...listeners2,
19977
+ ...attributes
19978
+ } : {};
19979
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayContainerItem, { nodeRef: setNodeRef, style, dragHandleProps, internalId: id, index, size, disabled, buildEntry, remove, copy, addInIndex, canAddElements, sortable: sortable$1, isDragging, storedProps, updateItemCustomProps });
19750
19980
  }
19751
19981
  function ArrayContainerItem(t0) {
19752
19982
  const $ = reactCompilerRuntime.c(30);
19753
19983
  const {
19754
- provided,
19984
+ nodeRef,
19985
+ style,
19986
+ dragHandleProps,
19755
19987
  index,
19756
19988
  internalId,
19757
19989
  size,
19758
19990
  disabled,
19759
19991
  buildEntry,
19760
19992
  remove,
19993
+ copy,
19761
19994
  addInIndex,
19762
19995
  canAddElements,
19763
- sortable,
19764
- copy,
19996
+ sortable: sortable2,
19765
19997
  isDragging,
19766
19998
  storedProps,
19767
19999
  updateItemCustomProps
19768
20000
  } = t0;
19769
- const t1 = provided.innerRef;
19770
- const t2 = provided.draggableProps;
19771
- const t3 = provided.draggableProps.style;
19772
- const t4 = `relative ${!isDragging ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 dark:hover:bg-opacity-20" : ""} rounded-md opacity-100`;
19773
- let t5;
20001
+ const t1 = `relative ${!isDragging ? "hover\\:bg-surface-accent-50 dark\\:hover\\:bg-surface-800 dark\\:hover\\:bg-opacity-20" : ""} rounded-md opacity-100`;
20002
+ let t2;
19774
20003
  if ($[0] !== internalId || $[1] !== updateItemCustomProps) {
19775
- t5 = (props) => updateItemCustomProps(internalId, props);
20004
+ t2 = (props) => updateItemCustomProps(internalId, props);
19776
20005
  $[0] = internalId;
19777
20006
  $[1] = updateItemCustomProps;
19778
- $[2] = t5;
20007
+ $[2] = t2;
19779
20008
  } else {
19780
- t5 = $[2];
20009
+ t2 = $[2];
19781
20010
  }
19782
- let t6;
19783
- if ($[3] !== buildEntry || $[4] !== index || $[5] !== internalId || $[6] !== isDragging || $[7] !== storedProps || $[8] !== t5) {
19784
- t6 = buildEntry({
20011
+ let t3;
20012
+ if ($[3] !== buildEntry || $[4] !== index || $[5] !== internalId || $[6] !== isDragging || $[7] !== storedProps || $[8] !== t2) {
20013
+ t3 = buildEntry({
19785
20014
  index,
19786
20015
  internalId,
19787
20016
  isDragging,
19788
20017
  storedProps,
19789
- storeProps: t5
20018
+ storeProps: t2
19790
20019
  });
19791
20020
  $[3] = buildEntry;
19792
20021
  $[4] = index;
19793
20022
  $[5] = internalId;
19794
20023
  $[6] = isDragging;
19795
20024
  $[7] = storedProps;
19796
- $[8] = t5;
19797
- $[9] = t6;
20025
+ $[8] = t2;
20026
+ $[9] = t3;
19798
20027
  } else {
19799
- t6 = $[9];
20028
+ t3 = $[9];
19800
20029
  }
19801
- let t7;
19802
- if ($[10] !== t6) {
19803
- t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark", children: t6 });
19804
- $[10] = t6;
19805
- $[11] = t7;
20030
+ let t4;
20031
+ if ($[10] !== t3) {
20032
+ t4 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark", children: t3 });
20033
+ $[10] = t3;
20034
+ $[11] = t4;
19806
20035
  } else {
19807
- t7 = $[11];
20036
+ t4 = $[11];
19808
20037
  }
19809
- const t8 = size === "small" ? "row" : "column";
19810
- let t9;
19811
- if ($[12] !== addInIndex || $[13] !== canAddElements || $[14] !== copy || $[15] !== disabled || $[16] !== index || $[17] !== provided || $[18] !== remove || $[19] !== sortable || $[20] !== t8) {
19812
- t9 = /* @__PURE__ */ jsxRuntime.jsx(ArrayItemOptions, { direction: t8, disabled, remove, index, provided, addInIndex, canAddElements, sortable, copy });
20038
+ const t5 = size === "small" ? "row" : "column";
20039
+ let t6;
20040
+ if ($[12] !== addInIndex || $[13] !== canAddElements || $[14] !== copy || $[15] !== disabled || $[16] !== dragHandleProps || $[17] !== index || $[18] !== remove || $[19] !== sortable2 || $[20] !== t5) {
20041
+ t6 = /* @__PURE__ */ jsxRuntime.jsx(ArrayItemOptions, { dragHandleProps, direction: t5, disabled, remove, index, copy, canAddElements, sortable: sortable2, addInIndex });
19813
20042
  $[12] = addInIndex;
19814
20043
  $[13] = canAddElements;
19815
20044
  $[14] = copy;
19816
20045
  $[15] = disabled;
19817
- $[16] = index;
19818
- $[17] = provided;
20046
+ $[16] = dragHandleProps;
20047
+ $[17] = index;
19819
20048
  $[18] = remove;
19820
- $[19] = sortable;
19821
- $[20] = t8;
19822
- $[21] = t9;
20049
+ $[19] = sortable2;
20050
+ $[20] = t5;
20051
+ $[21] = t6;
19823
20052
  } else {
19824
- t9 = $[21];
20053
+ t6 = $[21];
19825
20054
  }
19826
- let t10;
19827
- if ($[22] !== t7 || $[23] !== t9) {
19828
- t10 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
19829
- t7,
19830
- t9
20055
+ let t7;
20056
+ if ($[22] !== t4 || $[23] !== t6) {
20057
+ t7 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
20058
+ t4,
20059
+ t6
19831
20060
  ] });
19832
- $[22] = t7;
19833
- $[23] = t9;
19834
- $[24] = t10;
20061
+ $[22] = t4;
20062
+ $[23] = t6;
20063
+ $[24] = t7;
19835
20064
  } else {
19836
- t10 = $[24];
20065
+ t7 = $[24];
19837
20066
  }
19838
- let t11;
19839
- if ($[25] !== provided.draggableProps || $[26] !== provided.innerRef || $[27] !== t10 || $[28] !== t4) {
19840
- t11 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: t1, ...t2, style: t3, className: t4, children: t10 });
19841
- $[25] = provided.draggableProps;
19842
- $[26] = provided.innerRef;
19843
- $[27] = t10;
19844
- $[28] = t4;
19845
- $[29] = t11;
20067
+ let t8;
20068
+ if ($[25] !== nodeRef || $[26] !== style || $[27] !== t1 || $[28] !== t7) {
20069
+ t8 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: nodeRef, style, className: t1, children: t7 });
20070
+ $[25] = nodeRef;
20071
+ $[26] = style;
20072
+ $[27] = t1;
20073
+ $[28] = t7;
20074
+ $[29] = t8;
19846
20075
  } else {
19847
- t11 = $[29];
20076
+ t8 = $[29];
19848
20077
  }
19849
- return t11;
20078
+ return t8;
19850
20079
  }
19851
20080
  function ArrayItemOptions({
20081
+ dragHandleProps,
19852
20082
  direction,
19853
20083
  disabled,
19854
20084
  remove,
19855
20085
  index,
19856
- provided,
19857
20086
  copy,
19858
20087
  canAddElements,
19859
- sortable,
20088
+ sortable: sortable2,
19860
20089
  addInIndex
19861
20090
  }) {
19862
20091
  const [menuOpen, setMenuOpen] = React.useState(false);
19863
20092
  const iconRef = React.useRef(null);
19864
- ui.useOutsideAlerter(iconRef, () => setMenuOpen(false));
19865
- return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(ui.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: [
19866
- /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", disabled: disabled || !canAddElements, onClick: (e) => {
20093
+ ui.useOutsideAlerter(iconRef, () => {
20094
+ if (menuOpen) setMenuOpen(false);
20095
+ });
20096
+ const showMenu = canAddElements ?? false;
20097
+ const handleIconButtonClick = (e) => {
20098
+ if (showMenu) {
20099
+ e.stopPropagation();
19867
20100
  e.preventDefault();
19868
- setMenuOpen(true);
19869
- }, onDragStart: (e_0) => {
19870
- setMenuOpen(false);
19871
- }, className: disabled || !sortable ? "cursor-inherit" : "cursor-grab", children: /* @__PURE__ */ jsxRuntime.jsx(ui.HandleIcon, {}) }),
19872
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Menu, { portalContainer: iconRef.current, open: menuOpen, trigger: /* @__PURE__ */ jsxRuntime.jsx("div", { tabIndex: -1 }), children: [
19873
- /* @__PURE__ */ jsxRuntime.jsxs(ui.MenuItem, { dense: true, onClick: (e_1) => {
20101
+ setMenuOpen((o) => !o);
20102
+ } else if (sortable2) ;
20103
+ else {
20104
+ e.stopPropagation();
20105
+ e.preventDefault();
20106
+ }
20107
+ };
20108
+ const title = !disabled && sortable2 && showMenu ? "Drag to move. Click for options" : !disabled && showMenu ? "Click for options" : !disabled && sortable2 ? "Drag to move" : void 0;
20109
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: iconRef, className: `pl-2 pt-1 pb-1 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`, children: [
20110
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { delayDuration: 400, open: menuOpen ? false : void 0, side: direction === "column" ? "left" : void 0, title, children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", disabled: disabled || !showMenu && !sortable2, ...sortable2 ? dragHandleProps : {}, onClick: handleIconButtonClick, onFocus: () => {
20111
+ if (sortable2 && menuOpen) setMenuOpen(false);
20112
+ }, className: ui.cls(disabled || !sortable2 && !showMenu ? "cursor-inherit" : "", sortable2 && !disabled ? "cursor-grab" : "", !sortable2 && showMenu && !disabled ? "cursor-pointer" : ""), children: /* @__PURE__ */ jsxRuntime.jsx(ui.HandleIcon, {}) }) }),
20113
+ showMenu && /* @__PURE__ */ jsxRuntime.jsxs(ui.Menu, { portalContainer: iconRef.current, open: menuOpen, trigger: /* @__PURE__ */ jsxRuntime.jsx("div", { tabIndex: -1 }), children: [
20114
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.MenuItem, { dense: true, onClick: (e_0) => {
19874
20115
  setMenuOpen(false);
19875
20116
  remove(index);
19876
20117
  }, children: [
@@ -19899,7 +20140,110 @@
19899
20140
  "Add below"
19900
20141
  ] })
19901
20142
  ] })
19902
- ] }) });
20143
+ ] });
20144
+ }
20145
+ function ArrayContainer({
20146
+ droppableId,
20147
+ addLabel,
20148
+ value,
20149
+ disabled = false,
20150
+ buildEntry,
20151
+ size = "medium",
20152
+ onInternalIdAdded,
20153
+ includeAddButton: deprecatedIncludeAddButton,
20154
+ canAddElements: canAddElementsProp = true,
20155
+ sortable: sortable$1 = true,
20156
+ newDefaultEntry,
20157
+ onValueChange,
20158
+ className,
20159
+ min = 0,
20160
+ max = Infinity
20161
+ }) {
20162
+ const canAddElements = (canAddElementsProp === void 0 ? true : canAddElementsProp) && // Default canAddElementsProp to true if undefined
20163
+ (deprecatedIncludeAddButton === void 0 || deprecatedIncludeAddButton);
20164
+ const hasValue = value && Array.isArray(value) && value.length > 0;
20165
+ const internalIdsRef = React.useRef(buildIdsMap(value));
20166
+ const [internalIds, setInternalIds] = React.useState(hasValue ? Object.values(internalIdsRef.current) : []);
20167
+ const itemCustomPropsRef = React.useRef({});
20168
+ const updateItemCustomProps = React.useCallback((internalId, customProps) => {
20169
+ itemCustomPropsRef.current[internalId] = customProps;
20170
+ }, []);
20171
+ const pointerSensor = core.useSensor(core.PointerSensor, {
20172
+ activationConstraint: {
20173
+ distance: 5
20174
+ }
20175
+ });
20176
+ const keyboardSensor = core.useSensor(core.KeyboardSensor, {});
20177
+ const sensors = core.useSensors(pointerSensor, keyboardSensor);
20178
+ React.useEffect(() => {
20179
+ if (hasValue && value && value.length !== internalIds.length) {
20180
+ const newInternalIds = value.map((v, index) => {
20181
+ const hashValue = getHashValue(v) + index;
20182
+ if (hashValue in internalIdsRef.current) {
20183
+ return internalIdsRef.current[hashValue];
20184
+ } else {
20185
+ const newInternalId = getRandomId();
20186
+ internalIdsRef.current[hashValue] = newInternalId;
20187
+ return newInternalId;
20188
+ }
20189
+ });
20190
+ setInternalIds(newInternalIds);
20191
+ }
20192
+ }, [hasValue, internalIds.length, value]);
20193
+ const insertInEnd = (e) => {
20194
+ e.preventDefault();
20195
+ if (disabled || (value ?? []).length >= max) return;
20196
+ const id = getRandomId();
20197
+ const newIds = [...internalIds, id];
20198
+ if (onInternalIdAdded) onInternalIdAdded(id);
20199
+ setInternalIds(newIds);
20200
+ onValueChange([...value ?? [], newDefaultEntry]);
20201
+ };
20202
+ const remove = (index_0) => {
20203
+ if ((value ?? []).length <= min) return;
20204
+ const newIds_0 = [...internalIds];
20205
+ newIds_0.splice(index_0, 1);
20206
+ setInternalIds(newIds_0);
20207
+ onValueChange(value.filter((_, i) => i !== index_0));
20208
+ };
20209
+ const copy = (index_1) => {
20210
+ if ((value ?? []).length >= max) return;
20211
+ const id_0 = getRandomId();
20212
+ const copyingItem = value[index_1];
20213
+ const newIds_1 = [...internalIds.slice(0, index_1 + 1), id_0, ...internalIds.slice(index_1 + 1)];
20214
+ if (onInternalIdAdded) onInternalIdAdded(id_0);
20215
+ setInternalIds(newIds_1);
20216
+ onValueChange([...value.slice(0, index_1 + 1), copyingItem, ...value.slice(index_1 + 1)]);
20217
+ };
20218
+ const addInIndex = (index_2) => {
20219
+ if ((value ?? []).length >= max) return;
20220
+ const id_1 = getRandomId();
20221
+ const newIds_2 = [...internalIds.slice(0, index_2), id_1, ...internalIds.slice(index_2)];
20222
+ if (onInternalIdAdded) onInternalIdAdded(id_1);
20223
+ setInternalIds(newIds_2);
20224
+ onValueChange([...value.slice(0, index_2), newDefaultEntry, ...value.slice(index_2)]);
20225
+ };
20226
+ const onDragEnd = (event) => {
20227
+ const {
20228
+ active,
20229
+ over
20230
+ } = event;
20231
+ if (!over || active.id === over.id) return;
20232
+ const oldIndex = internalIds.indexOf(active.id);
20233
+ const newIndex = internalIds.indexOf(over.id);
20234
+ if (oldIndex === -1 || newIndex === -1) return;
20235
+ const newIds_3 = arrayMove(internalIds, oldIndex, newIndex);
20236
+ setInternalIds(newIds_3);
20237
+ onValueChange(arrayMove(value, oldIndex, newIndex));
20238
+ };
20239
+ return sortable$1 ? /* @__PURE__ */ jsxRuntime.jsx(core.DndContext, { sensors, modifiers: [modifiers.restrictToVerticalAxis], collisionDetection: core.closestCenter, onDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: internalIds, strategy: sortable.verticalListSortingStrategy, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("space-y-1", className), id: droppableId, children: [
20240
+ hasValue && internalIds.map((internalId_0, index_3) => /* @__PURE__ */ jsxRuntime.jsx(SortableItem, { id: internalId_0, index: index_3, size, disabled, buildEntry, remove, copy, addInIndex, canAddElements, sortable: sortable$1, storedProps: itemCustomPropsRef.current[internalId_0], updateItemCustomProps }, `array_field_${internalId_0}`)),
20241
+ canAddElements && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || (value?.length ?? 0) >= max, startIcon: /* @__PURE__ */ jsxRuntime.jsx(ui.AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
20242
+ ] }) }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("space-y-1", className), id: droppableId, children: [
20243
+ hasValue && internalIds.map((internalId_1, index_4) => /* @__PURE__ */ jsxRuntime.jsx(ArrayContainerItem, { nodeRef: (node) => {
20244
+ }, 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}`)),
20245
+ canAddElements && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || (value?.length ?? 0) >= max, startIcon: /* @__PURE__ */ jsxRuntime.jsx(ui.AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
20246
+ ] });
19903
20247
  }
19904
20248
  function arrayMove(value, sourceIndex, destinationIndex) {
19905
20249
  const result = Array.from(value);
@@ -21510,7 +21854,7 @@
21510
21854
  };
21511
21855
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
21512
21856
  "hidden": selectedTab !== customView.key
21513
- }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
21857
+ }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, parentCollectionIds, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
21514
21858
  }).filter(Boolean);
21515
21859
  const globalLoading = dataLoading && !usedEntity;
21516
21860
  const jsonView = /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("relative flex-1 h-full overflow-auto w-full", {
@@ -21640,17 +21984,7 @@
21640
21984
  const parentCollectionIds = React.useMemo(() => {
21641
21985
  return navigationController.getParentCollectionIds(path);
21642
21986
  }, [navigationController, path]);
21643
- const collection = React.useMemo(() => {
21644
- if (props.collection) {
21645
- return props.collection;
21646
- }
21647
- const registryCollection = navigationController.getCollection(path);
21648
- if (registryCollection) {
21649
- return registryCollection;
21650
- }
21651
- console.error("ERROR: No collection found in path `", path, "`. Entity id: ", entityId);
21652
- throw Error("ERROR: No collection found in path `" + path + "`. Make sure you have defined a collection for this path in the root navigation.");
21653
- }, [navigationController, props.collection]);
21987
+ const collection = props.collection ?? navigationController.getCollection(path);
21654
21988
  React.useEffect(() => {
21655
21989
  function beforeunload(e) {
21656
21990
  if (blocked && collection) {