@rebasepro/admin 0.6.1 → 0.8.0

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 (187) hide show
  1. package/dist/{CollectionEditorDialog-HNXGxXdO.js → CollectionEditorDialog-BO_aQ-Z4.js} +236 -155
  2. package/dist/CollectionEditorDialog-BO_aQ-Z4.js.map +1 -0
  3. package/dist/{PropertyEditView-C2wp8kQ9.js → PropertyEditView-DKzOpMjR.js} +190 -50
  4. package/dist/PropertyEditView-DKzOpMjR.js.map +1 -0
  5. package/dist/{CollectionsStudioView-B1mN33GB.js → RouterCollectionsStudioView-BQTIExjA.js} +61 -39
  6. package/dist/RouterCollectionsStudioView-BQTIExjA.js.map +1 -0
  7. package/dist/collection_editor/_cms_internals.d.ts +1 -1
  8. package/dist/collection_editor/api/generateCollectionApi.d.ts +3 -2
  9. package/dist/collection_editor/extensibility_types.d.ts +135 -0
  10. package/dist/collection_editor/index.d.ts +6 -0
  11. package/dist/collection_editor/serializable_types.d.ts +370 -0
  12. package/dist/collection_editor/serializable_utils.d.ts +50 -0
  13. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +3 -3
  14. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +12 -1
  15. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +13 -1
  16. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +24 -2
  17. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +2 -1
  18. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +4 -1
  19. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +12 -1
  20. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
  21. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
  22. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
  23. package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
  24. package/dist/collection_editor_ui.d.ts +4 -0
  25. package/dist/collection_editor_ui.js +33 -4
  26. package/dist/collection_editor_ui.js.map +1 -0
  27. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
  28. package/dist/components/EntityCollectionTable/index.d.ts +1 -1
  29. package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +3 -3
  30. package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +3 -3
  31. package/dist/components/EntityEditView.d.ts +3 -2
  32. package/dist/components/RebaseCMS.d.ts +1 -1
  33. package/dist/components/SelectableTable/SelectionStore.d.ts +12 -21
  34. package/dist/components/field_configs.d.ts +1 -1
  35. package/dist/editor/editor.d.ts +0 -6
  36. package/dist/editor.js +1 -3
  37. package/dist/editor.js.map +1 -1
  38. package/dist/form/EntityForm.d.ts +10 -9
  39. package/dist/form/EntityFormBinding.d.ts +27 -0
  40. package/dist/form/components/StorageUploadProgress.d.ts +6 -1
  41. package/dist/form/form_utils.d.ts +8 -0
  42. package/dist/form/index.d.ts +5 -2
  43. package/dist/{history-BO6VT85a.js → history-B3cqBzEV.js} +2 -2
  44. package/dist/{history-BO6VT85a.js.map → history-B3cqBzEV.js.map} +1 -1
  45. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  46. package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
  47. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
  48. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -1
  49. package/dist/hooks/navigation/utils.d.ts +1 -1
  50. package/dist/index.d.ts +3 -1
  51. package/dist/index.js +2 -2
  52. package/dist/preview/components/StorageThumbnail.d.ts +3 -1
  53. package/dist/routes/CustomViewRoute.d.ts +2 -1
  54. package/dist/{src-BYniefVu.js → src-cxV1ODRG.js} +1731 -1710
  55. package/dist/src-cxV1ODRG.js.map +1 -0
  56. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  57. package/dist/types/components/EntityFormProps.d.ts +59 -0
  58. package/dist/types/components/PropertyPreviewProps.d.ts +2 -1
  59. package/dist/types/fields.d.ts +10 -7
  60. package/dist/util/dataControllerAdapter.d.ts +30 -0
  61. package/dist/util/navigation_utils.d.ts +1 -1
  62. package/dist/util/propertyConfigMapper.d.ts +17 -0
  63. package/package.json +8 -8
  64. package/src/collection_editor/_cms_internals.ts +1 -1
  65. package/src/collection_editor/api/generateCollectionApi.ts +3 -2
  66. package/src/collection_editor/extensibility_types.ts +168 -0
  67. package/src/collection_editor/index.ts +46 -0
  68. package/src/collection_editor/pgColumnToProperty.ts +2 -2
  69. package/src/collection_editor/serializable_types.ts +474 -0
  70. package/src/collection_editor/serializable_utils.ts +576 -0
  71. package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +6 -6
  72. package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +170 -89
  73. package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +95 -78
  74. package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +23 -20
  75. package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +79 -27
  76. package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +9 -7
  77. package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +22 -5
  78. package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +3 -3
  79. package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +154 -18
  80. package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +6 -6
  81. package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +1 -0
  82. package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
  83. package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
  84. package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +4 -3
  85. package/src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx +35 -1
  86. package/src/collection_editor/ui/collection_editor/templates/blog_template.ts +1 -1
  87. package/src/collection_editor/ui/collection_editor/utils/supported_fields.tsx +0 -1
  88. package/src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts +7 -29
  89. package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
  90. package/src/collection_editor/useSafeSnackbarController.ts +9 -0
  91. package/src/collection_editor_ui.ts +6 -0
  92. package/src/components/DefaultDrawer.tsx +14 -4
  93. package/src/components/DrawerNavigationGroup.tsx +2 -2
  94. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +11 -9
  95. package/src/components/EntityCollectionTable/fields/TableMultipleRelationField.tsx +2 -1
  96. package/src/components/EntityCollectionTable/fields/TableRelationField.tsx +2 -1
  97. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +23 -20
  98. package/src/components/EntityCollectionTable/index.tsx +1 -1
  99. package/src/components/EntityCollectionTable/table_bindings.tsx +24 -44
  100. package/src/components/EntityCollectionView/EntityBoardCard.tsx +6 -6
  101. package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +13 -12
  102. package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +40 -190
  103. package/src/components/EntityCollectionView/EntityCollectionListView.tsx +66 -184
  104. package/src/components/EntityCollectionView/EntityCollectionView.tsx +8 -25
  105. package/src/components/EntityCollectionView/hooks/useCollectionInlineEditor.ts +1 -1
  106. package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +6 -6
  107. package/src/components/EntityCollectionView/useBoardDataController.tsx +12 -40
  108. package/src/components/EntityCollectionView/useEntityPreviewSlots.ts +3 -3
  109. package/src/components/EntityDetailView.tsx +2 -2
  110. package/src/components/EntityEditView.tsx +7 -6
  111. package/src/components/EntityEditViewFormActions.tsx +35 -29
  112. package/src/components/HomePage/ContentHomePage.tsx +14 -5
  113. package/src/components/RebaseCMS.tsx +3 -3
  114. package/src/components/RebaseNavigation.tsx +74 -9
  115. package/src/components/RelationSelector.tsx +2 -2
  116. package/src/components/SelectableTable/SelectableTable.tsx +13 -5
  117. package/src/components/SelectableTable/SelectionStore.ts +18 -48
  118. package/src/components/SideDialogs.tsx +0 -7
  119. package/src/components/common/default_entity_actions.tsx +22 -11
  120. package/src/components/field_configs.tsx +0 -14
  121. package/src/contexts/BreacrumbsContext.tsx +15 -6
  122. package/src/editor/editor.tsx +4 -7
  123. package/src/editor/selectors/ai-selector.tsx +0 -1
  124. package/src/form/EntityForm.tsx +191 -428
  125. package/src/form/EntityFormActions.tsx +35 -49
  126. package/src/form/EntityFormBinding.tsx +323 -0
  127. package/src/form/components/FormLayout.tsx +1 -1
  128. package/src/form/components/StorageUploadProgress.tsx +9 -2
  129. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +12 -1
  130. package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +4 -4
  131. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +7 -2
  132. package/src/form/field_bindings/RelationFieldBinding.tsx +5 -7
  133. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +19 -15
  134. package/src/form/form_utils.ts +163 -0
  135. package/src/form/index.tsx +14 -6
  136. package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +2 -2
  137. package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
  138. package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
  139. package/src/hooks/navigation/useAsyncResolver.ts +100 -0
  140. package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +15 -8
  141. package/src/hooks/navigation/useBuildNavigationStateController.tsx +12 -8
  142. package/src/hooks/navigation/useNavigationResolution.ts +33 -0
  143. package/src/hooks/navigation/useResolvedCollections.ts +29 -71
  144. package/src/hooks/navigation/useResolvedViews.tsx +40 -70
  145. package/src/hooks/navigation/useTopLevelNavigation.ts +20 -16
  146. package/src/hooks/navigation/utils.ts +7 -4
  147. package/src/index.ts +6 -1
  148. package/src/preview/PropertyPreview.tsx +1 -16
  149. package/src/preview/components/StorageThumbnail.tsx +24 -7
  150. package/src/routes/CustomViewRoute.tsx +14 -6
  151. package/src/types/components/EntityFormActionsProps.tsx +1 -1
  152. package/src/types/components/EntityFormProps.tsx +68 -0
  153. package/src/types/components/PropertyPreviewProps.tsx +1 -1
  154. package/src/types/fields.tsx +9 -8
  155. package/src/util/dataControllerAdapter.ts +93 -0
  156. package/src/util/navigation_utils.ts +1 -1
  157. package/src/util/previews.ts +20 -0
  158. package/src/util/propertyConfigMapper.ts +134 -0
  159. package/src/util/property_utils.tsx +1 -2
  160. package/dist/CollectionEditorDialog-HNXGxXdO.js.map +0 -1
  161. package/dist/CollectionsStudioView-B1mN33GB.js.map +0 -1
  162. package/dist/PropertyEditView-C2wp8kQ9.js.map +0 -1
  163. package/dist/components/EntityCollectionTable/fields/VirtualTableDateField.d.ts +0 -12
  164. package/dist/components/EntityCollectionTable/fields/VirtualTableInput.d.ts +0 -10
  165. package/dist/components/EntityCollectionTable/fields/VirtualTableNumberInput.d.ts +0 -9
  166. package/dist/components/EntityCollectionTable/fields/VirtualTableSwitch.d.ts +0 -8
  167. package/dist/components/EntityCollectionView/Board.d.ts +0 -3
  168. package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
  169. package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
  170. package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
  171. package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
  172. package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +0 -11
  173. package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -12
  174. package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
  175. package/dist/src-BYniefVu.js.map +0 -1
  176. package/src/components/EntityCollectionTable/fields/VirtualTableDateField.tsx +0 -39
  177. package/src/components/EntityCollectionTable/fields/VirtualTableInput.tsx +0 -90
  178. package/src/components/EntityCollectionTable/fields/VirtualTableNumberInput.tsx +0 -83
  179. package/src/components/EntityCollectionTable/fields/VirtualTableSwitch.tsx +0 -32
  180. package/src/components/EntityCollectionView/Board.tsx +0 -475
  181. package/src/components/EntityCollectionView/BoardColumn.tsx +0 -165
  182. package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -46
  183. package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
  184. package/src/components/EntityCollectionView/board_types.ts +0 -113
  185. package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +0 -141
  186. package/src/hooks/navigation/useNavigationRegistry.ts +0 -164
  187. package/src/hooks/navigation/useNavigationURLs.ts +0 -56
@@ -1,18 +1,28 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { Bt as ArrayContainer, Ct as getFieldConfig, Zt as FieldCaption, a as namespaceToPropertiesPath, bt as DEFAULT_FIELD_CONFIGS, i as namespaceToPropertiesOrderPath, kn as useCollectionRegistryController, n as getFullIdPath, r as idToPropertiesPath, t as getFullId, wt as getFieldId, yt as PropertyConfigBadge } from "./src-BYniefVu.js";
2
+ import { Bt as getFieldId, Ft as PropertyConfigBadge, It as DEFAULT_FIELD_CONFIGS, Wn as useCollectionRegistryController, _ as toSerializableProperty, a as namespaceToPropertiesPath, fn as FieldCaption, h as toSerializableCollection, i as namespaceToPropertiesOrderPath, n as getFullIdPath, r as idToPropertiesPath, t as getFullId, tn as ArrayContainer, zt as getFieldConfig } from "./src-cxV1ODRG.js";
3
3
  import React, { createContext, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { deepEqual } from "fast-equals";
5
5
  import { AlertTriangleIcon, ArrowDownToLineIcon, ArrowUpToLineIcon, Badge, BooleanSwitchWithLabel, Button, Card, CheckSquareIcon, CircularProgress, DebouncedTextField, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, ExpandablePanel, FileSearchIcon, FunctionSquareIcon, IconButton, InfoLabel, ListIcon, Menu, MenuItem, MinusCircleIcon, MoreVerticalIcon, MultiSelect, MultiSelectItem, Paper, PlusIcon, RefreshCcwIcon, Select, SelectItem, SettingsIcon, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
6
6
  import { isPropertyBuilder, resolveEnumValues } from "@rebasepro/common";
7
- import { AIModifiedIndicator, ConfirmationDialog, IconForView, useCustomizationController, useSnackbarController, useTranslation } from "@rebasepro/core";
7
+ import { AIModifiedIndicator, ConfirmationDialog, IconForView, useCustomizationController, useSnackbarController, useStorageSources, useTranslation } from "@rebasepro/core";
8
8
  import { Field, Formex, getIn, useCreateFormex, useFormex } from "@rebasepro/formex";
9
9
  import { isValidRegExp, mergeDeep, prettifyIdentifier, serializeRegExp, toSnakeCase } from "@rebasepro/utils";
10
+ import { DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
10
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
12
  import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
12
13
  import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
13
14
  import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
14
15
  import { CSS } from "@dnd-kit/utilities";
15
16
  import { extractEnumFromValues } from "@rebasepro/schema-inference";
17
+ //#region src/collection_editor/useSafeSnackbarController.ts
18
+ function useSafeSnackbarController() {
19
+ try {
20
+ return useSnackbarController();
21
+ } catch {
22
+ return;
23
+ }
24
+ }
25
+ //#endregion
16
26
  //#region src/collection_editor/ui/collection_editor/EnumForm.tsx
17
27
  function EnumForm({ enumValues, onValuesChanged, onError, updateIds, disabled, allowDataInference, getData }) {
18
28
  const formex = useCreateFormex({
@@ -483,7 +493,7 @@ function ValidationPanel({ children }) {
483
493
  //#region src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx
484
494
  function EnumPropertyField({ multiselect, updateIds, disabled, showErrors, allowDataInference, getData, propertyNamespace }) {
485
495
  const { values, setFieldError, setFieldValue } = useFormex();
486
- const snackbarContext = useSnackbarController();
496
+ const snackbarContext = useSafeSnackbarController();
487
497
  const { t } = useTranslation();
488
498
  const enumValuesPath = multiselect ? "of.enum" : "enum";
489
499
  const defaultValue = getIn(values, "defaultValue");
@@ -499,7 +509,7 @@ function EnumPropertyField({ multiselect, updateIds, disabled, showErrors, allow
499
509
  const enumIds = value.filter((v) => Boolean(v?.id)).map((v) => v.id);
500
510
  if (defaultValue && !enumIds.includes(defaultValue)) {
501
511
  setFieldValue("defaultValue", void 0);
502
- snackbarContext.open({
512
+ snackbarContext?.open({
503
513
  type: "warning",
504
514
  message: "Default value was cleared"
505
515
  });
@@ -560,8 +570,10 @@ var fileTypes = {
560
570
  function StoragePropertyField({ multiple, existing, disabled }) {
561
571
  const { values, setFieldValue } = useFormex();
562
572
  const { t } = useTranslation();
573
+ const storageSources = useStorageSources();
563
574
  const baseStoragePath = multiple ? "of.storage" : "storage";
564
575
  const acceptedFiles = `${baseStoragePath}.acceptedFiles`;
576
+ const storageSource = `${baseStoragePath}.storageSource`;
565
577
  `${baseStoragePath}`;
566
578
  const fileName = `${baseStoragePath}.fileName`;
567
579
  const maxSize = `${baseStoragePath}.maxSize`;
@@ -585,6 +597,8 @@ function StoragePropertyField({ multiple, existing, disabled }) {
585
597
  const storedValue = getIn(values, acceptedFiles);
586
598
  const fileTypesValue = Array.isArray(storedValue) ? storedValue : void 0;
587
599
  const allFileTypesSelected = !fileTypesValue || fileTypesValue.length === 0;
600
+ const sourceKeys = Object.keys(storageSources.sources).filter((key) => key !== DEFAULT_STORAGE_SOURCE_KEY);
601
+ const storageSourceValue = getIn(values, storageSource) ?? DEFAULT_STORAGE_SOURCE_KEY;
588
602
  const handleTypesChange = (value) => {
589
603
  if (!value) setFieldValue(acceptedFiles, void 0);
590
604
  else setFieldValue(acceptedFiles, value);
@@ -605,6 +619,27 @@ function StoragePropertyField({ multiple, existing, disabled }) {
605
619
  children: /* @__PURE__ */ jsxs("div", {
606
620
  className: "grid grid-cols-12 gap-2 p-4",
607
621
  children: [
622
+ sourceKeys.length > 0 && /* @__PURE__ */ jsx("div", {
623
+ className: "col-span-12",
624
+ children: /* @__PURE__ */ jsxs(Select, {
625
+ className: "w-full",
626
+ disabled,
627
+ name: storageSource,
628
+ value: storageSourceValue,
629
+ onValueChange: (value) => setFieldValue(storageSource, !value || value === DEFAULT_STORAGE_SOURCE_KEY ? void 0 : value),
630
+ label: "Storage backend",
631
+ renderValue: (key) => {
632
+ return storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "Default" : key);
633
+ },
634
+ children: [/* @__PURE__ */ jsx(SelectItem, {
635
+ value: DEFAULT_STORAGE_SOURCE_KEY,
636
+ children: "Default"
637
+ }), sourceKeys.map((key) => /* @__PURE__ */ jsx(SelectItem, {
638
+ value: key,
639
+ children: storageSources.registry[key]?.label ?? key
640
+ }, key))]
641
+ })
642
+ }),
608
643
  /* @__PURE__ */ jsx("div", {
609
644
  className: "col-span-12",
610
645
  children: /* @__PURE__ */ jsx(MultiSelect, {
@@ -875,8 +910,8 @@ function PropertyFieldPreview({ property, propertyKey, onClick, hasError, includ
875
910
  return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx("div", {
876
911
  onClick,
877
912
  className: onClick ? "cursor-pointer" : "",
878
- children: /* @__PURE__ */ jsxs(Paper, {
879
- className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-800 shadow-xs", (hasError ? "border-red-500 dark:border-red-500 border-red-500/100 dark:border-red-500/100 ring-0 dark:ring-0" : selected ? "border-primary" : "") || "border-surface-200 dark:border-surface-700", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
913
+ children: /* @__PURE__ */ jsxs("div", {
914
+ className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-900 shadow-xs", (hasError ? "border-red-500 dark:border-red-500 border-red-500/100 dark:border-red-500/100 ring-0 dark:ring-0" : selected ? "border-primary" : "") || "border-surface-200 dark:border-surface-700", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
880
915
  children: [
881
916
  /* @__PURE__ */ jsx(PropertyConfigBadge, {
882
917
  propertyConfig,
@@ -927,8 +962,8 @@ function NonEditablePropertyPreview({ name, selected, onClick, property }) {
927
962
  return /* @__PURE__ */ jsx("div", {
928
963
  onClick,
929
964
  className: onClick ? "cursor-pointer" : "",
930
- children: /* @__PURE__ */ jsxs(Paper, {
931
- className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-800 border-surface-200 dark:border-surface-700 shadow-xs", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
965
+ children: /* @__PURE__ */ jsxs("div", {
966
+ className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-900 border-surface-200 dark:border-surface-700 shadow-xs", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
932
967
  children: [
933
968
  /* @__PURE__ */ jsxs("div", {
934
969
  className: "relative shrink-0",
@@ -1157,6 +1192,7 @@ function PropertyTreeEntry({ id, propertyKey, namespace, property, additionalFie
1157
1192
  }),
1158
1193
  /* @__PURE__ */ jsx("div", { children: !isPropertyBuilder(property) && !additionalField && editable ? /* @__PURE__ */ jsx(PropertyFieldPreview, {
1159
1194
  property,
1195
+ propertyKey,
1160
1196
  onClick: onPropertyClick ? () => onPropertyClick(propertyKey, namespace) : void 0,
1161
1197
  includeName: true,
1162
1198
  selected,
@@ -2721,10 +2757,12 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2721
2757
  type: "string",
2722
2758
  propertyConfig: "text_field",
2723
2759
  storage: void 0,
2724
- multiline: void 0,
2725
- markdown: void 0,
2760
+ ui: {
2761
+ multiline: void 0,
2762
+ markdown: void 0,
2763
+ url: void 0
2764
+ },
2726
2765
  email: void 0,
2727
- url: void 0,
2728
2766
  enum: void 0,
2729
2767
  userSelect: void 0
2730
2768
  });
@@ -2732,21 +2770,25 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2732
2770
  type: "string",
2733
2771
  propertyConfig: "user_select",
2734
2772
  storage: void 0,
2735
- multiline: void 0,
2736
- markdown: void 0,
2773
+ ui: {
2774
+ multiline: void 0,
2775
+ markdown: void 0,
2776
+ url: void 0
2777
+ },
2737
2778
  email: void 0,
2738
- url: void 0,
2739
2779
  enum: void 0,
2740
2780
  userSelect: true
2741
2781
  });
2742
2782
  else if (selectedWidgetId === "multiline") updatedProperty = mergeDeep(propertyData, {
2743
2783
  type: "string",
2744
2784
  propertyConfig: "multiline",
2745
- multiline: true,
2785
+ ui: {
2786
+ multiline: true,
2787
+ markdown: void 0,
2788
+ url: void 0
2789
+ },
2746
2790
  storage: void 0,
2747
- markdown: void 0,
2748
2791
  email: void 0,
2749
- url: void 0,
2750
2792
  enum: void 0,
2751
2793
  userSelect: void 0
2752
2794
  });
@@ -2754,20 +2796,24 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2754
2796
  type: "string",
2755
2797
  propertyConfig: "markdown",
2756
2798
  storage: void 0,
2757
- multiline: void 0,
2758
- markdown: true,
2799
+ ui: {
2800
+ multiline: void 0,
2801
+ markdown: true,
2802
+ url: void 0
2803
+ },
2759
2804
  email: void 0,
2760
- url: void 0,
2761
2805
  userSelect: void 0
2762
2806
  });
2763
2807
  else if (selectedWidgetId === "url") updatedProperty = mergeDeep(propertyData, {
2764
2808
  type: "string",
2765
2809
  propertyConfig: "url",
2766
2810
  storage: void 0,
2767
- multiline: void 0,
2768
- markdown: void 0,
2811
+ ui: {
2812
+ multiline: void 0,
2813
+ markdown: void 0,
2814
+ url: true
2815
+ },
2769
2816
  email: void 0,
2770
- url: true,
2771
2817
  enum: void 0,
2772
2818
  userSelect: void 0
2773
2819
  });
@@ -2775,10 +2821,12 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2775
2821
  type: "string",
2776
2822
  propertyConfig: "email",
2777
2823
  storage: void 0,
2778
- multiline: void 0,
2779
- markdown: void 0,
2824
+ ui: {
2825
+ multiline: void 0,
2826
+ markdown: void 0,
2827
+ url: void 0
2828
+ },
2780
2829
  email: true,
2781
- url: void 0,
2782
2830
  enum: void 0,
2783
2831
  userSelect: void 0
2784
2832
  });
@@ -2786,10 +2834,12 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2786
2834
  type: "string",
2787
2835
  propertyConfig: "select",
2788
2836
  storage: void 0,
2789
- multiline: void 0,
2790
- markdown: void 0,
2837
+ ui: {
2838
+ multiline: void 0,
2839
+ markdown: void 0,
2840
+ url: void 0
2841
+ },
2791
2842
  email: void 0,
2792
- url: void 0,
2793
2843
  enum: propertyData.enum ?? [],
2794
2844
  userSelect: void 0
2795
2845
  });
@@ -2848,10 +2898,6 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
2848
2898
  type: "reference",
2849
2899
  propertyConfig: "reference"
2850
2900
  });
2851
- else if (selectedWidgetId === "reference_as_string") updatedProperty = mergeDeep(propertyData, {
2852
- type: "string",
2853
- propertyConfig: "reference_as_string"
2854
- });
2855
2901
  else if (selectedWidgetId === "multi_references") updatedProperty = mergeDeep(propertyData, {
2856
2902
  type: "array",
2857
2903
  propertyConfig: "multi_references",
@@ -2973,7 +3019,6 @@ var supportedFieldsIds = [
2973
3019
  "file_upload",
2974
3020
  "multi_file_upload",
2975
3021
  "reference",
2976
- "reference_as_string",
2977
3022
  "multi_references",
2978
3023
  "relation",
2979
3024
  "switch",
@@ -3167,7 +3212,7 @@ var PropertyEditView_exports = /* @__PURE__ */ __exportAll({
3167
3212
  WidgetSelectViewItem: () => WidgetSelectViewItem
3168
3213
  });
3169
3214
  var PropertyForm = React.memo(function PropertyForm(props) {
3170
- const { includeIdAndName = true, autoOpenTypeSelect, existingProperty, autoUpdateId, inArray, propertyKey, existingPropertyKeys, propertyNamespace, property, onPropertyChanged, onPropertyChangedImmediate = true, onDismiss, onDelete, onError, initialErrors, forceShowErrors, allowDataInference, getController, getData, propertyConfigs } = props;
3215
+ const { includeIdAndName = true, autoOpenTypeSelect, existingProperty, autoUpdateId, inArray, propertyKey, existingPropertyKeys, propertyNamespace, property, onPropertyChanged, onPropertyChangedImmediate = true, onDismiss, onDelete, onError, initialErrors, forceShowErrors, allowDataInference, getController, getData, propertyConfigs, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, collectionValues } = props;
3171
3216
  const initialValue = {
3172
3217
  id: "",
3173
3218
  name: ""
@@ -3254,6 +3299,10 @@ var PropertyForm = React.memo(function PropertyForm(props) {
3254
3299
  getData,
3255
3300
  allowDataInference,
3256
3301
  propertyConfigs,
3302
+ propertyTypePresets,
3303
+ hiddenPropertyTypes,
3304
+ renderExtraPropertyFields,
3305
+ collectionValues,
3257
3306
  ...formexController
3258
3307
  })
3259
3308
  });
@@ -3306,7 +3355,7 @@ function PropertyFormDialog({ open, onCancel, onOkClicked, onPropertyChanged, ge
3306
3355
  })
3307
3356
  });
3308
3357
  }
3309
- function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdateId = false, autoOpenTypeSelect, includeIdAndTitle, onPropertyChanged, onDelete, propertyNamespace, onDismiss, onError, showErrors, disabled, inArray, getData, allowDataInference, propertyConfigs }) {
3358
+ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdateId = false, autoOpenTypeSelect, includeIdAndTitle, onPropertyChanged, onDelete, propertyNamespace, onDismiss, onError, showErrors, disabled, inArray, getData, allowDataInference, propertyConfigs, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, collectionValues }) {
3310
3359
  const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);
3311
3360
  const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
3312
3361
  const [selectedFieldConfigId, setSelectedFieldConfigId] = useState(values?.type ? getFieldId(values) : void 0);
@@ -3347,6 +3396,31 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3347
3396
  nameFieldRef.current?.focus();
3348
3397
  }, 0);
3349
3398
  };
3399
+ const onPresetSelected = useCallback((preset) => {
3400
+ const widgetId = {
3401
+ "string": "text_field",
3402
+ "number": "number_input",
3403
+ "boolean": "switch",
3404
+ "date": "date_time",
3405
+ "reference": "reference",
3406
+ "relation": "relation",
3407
+ "map": "group",
3408
+ "array": "repeat",
3409
+ "vector": "vector_input",
3410
+ "geopoint": "text_field",
3411
+ "binary": "text_field"
3412
+ }[preset.baseType] || "text_field";
3413
+ setSelectedFieldConfigId(widgetId);
3414
+ setValues({
3415
+ ...updatePropertyFromWidget(values, widgetId, propertyConfigs),
3416
+ ...preset.defaults,
3417
+ propertyConfig: widgetId
3418
+ });
3419
+ }, [
3420
+ values,
3421
+ propertyConfigs,
3422
+ setValues
3423
+ ]);
3350
3424
  let childComponent;
3351
3425
  if (selectedFieldConfigId === "text_field" || selectedFieldConfigId === "multiline" || selectedFieldConfigId === "user_select" || selectedFieldConfigId === "email") childComponent = /* @__PURE__ */ jsx(StringPropertyField, {
3352
3426
  widgetId: selectedFieldConfigId,
@@ -3409,13 +3483,6 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3409
3483
  multiple: false,
3410
3484
  disabled
3411
3485
  });
3412
- else if (selectedFieldConfigId === "reference_as_string") childComponent = /* @__PURE__ */ jsx(ReferencePropertyField, {
3413
- showErrors,
3414
- existing,
3415
- asString: true,
3416
- multiple: false,
3417
- disabled
3418
- });
3419
3486
  else if (selectedFieldConfigId === "date_time") childComponent = /* @__PURE__ */ jsx(DateTimePropertyField, { disabled });
3420
3487
  else if (selectedFieldConfigId === "multi_references") childComponent = /* @__PURE__ */ jsx(ReferencePropertyField, {
3421
3488
  showErrors,
@@ -3463,7 +3530,10 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3463
3530
  showError: Boolean(selectedWidgetError),
3464
3531
  existing,
3465
3532
  propertyConfigs,
3466
- inArray
3533
+ inArray,
3534
+ propertyTypePresets,
3535
+ hiddenPropertyTypes,
3536
+ onPresetSelected
3467
3537
  }), !!selectedWidgetError && /* @__PURE__ */ jsx(Typography, {
3468
3538
  variant: "caption",
3469
3539
  className: "ml-3.5",
@@ -3490,6 +3560,24 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3490
3560
  ref: nameFieldRef
3491
3561
  }),
3492
3562
  childComponent,
3563
+ renderExtraPropertyFields && collectionValues && /* @__PURE__ */ jsx("div", {
3564
+ className: "col-span-12 mt-4 px-2",
3565
+ children: renderExtraPropertyFields({
3566
+ metadata: values.metadata ?? {},
3567
+ onMetadataChange: (key, value) => {
3568
+ const currentMetadata = values.metadata ?? {};
3569
+ setValues({
3570
+ ...values,
3571
+ metadata: {
3572
+ ...currentMetadata,
3573
+ [key]: value
3574
+ }
3575
+ });
3576
+ },
3577
+ property: toSerializableProperty(values),
3578
+ collection: toSerializableCollection(collectionValues)
3579
+ })
3580
+ }),
3493
3581
  /* @__PURE__ */ jsx("div", {
3494
3582
  className: "col-span-12",
3495
3583
  children: /* @__PURE__ */ jsx(AdvancedPropertyValidation, { disabled })
@@ -3539,7 +3627,6 @@ var WIDGET_TYPE_MAP = {
3539
3627
  multi_file_upload: "File",
3540
3628
  relation: "Relation",
3541
3629
  reference: "Reference",
3542
- reference_as_string: "Text",
3543
3630
  multi_references: "Reference",
3544
3631
  date_time: "Date",
3545
3632
  group: "Group",
@@ -3549,14 +3636,48 @@ var WIDGET_TYPE_MAP = {
3549
3636
  block: "Group",
3550
3637
  vector_input: "Number"
3551
3638
  };
3552
- function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenChange, disabled, showError, existing, propertyConfigs, inArray }) {
3639
+ var WIDGET_BASE_TYPE_MAP = {
3640
+ text_field: "string",
3641
+ multiline: "string",
3642
+ markdown: "string",
3643
+ url: "string",
3644
+ email: "string",
3645
+ select: "string",
3646
+ multi_select: "string",
3647
+ file_upload: "string",
3648
+ multi_file_upload: "string",
3649
+ user_select: "string",
3650
+ number_input: "number",
3651
+ number_select: "number",
3652
+ multi_number_select: "number",
3653
+ switch: "boolean",
3654
+ date_time: "date",
3655
+ reference: "reference",
3656
+ multi_references: "reference",
3657
+ relation: "relation",
3658
+ group: "map",
3659
+ key_value: "map",
3660
+ block: "map",
3661
+ repeat: "array",
3662
+ custom_array: "array",
3663
+ vector_input: "vector"
3664
+ };
3665
+ function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenChange, disabled, showError, existing, propertyConfigs, inArray, propertyTypePresets, hiddenPropertyTypes, onPresetSelected }) {
3553
3666
  const allSupportedFields = Object.entries(supportedFields).concat(Object.entries(propertyConfigs));
3554
- const displayedWidgets = (inArray ? allSupportedFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.type !== "array") : allSupportedFields).map(([key, propertyConfig]) => ({ [key]: propertyConfig })).reduce((a, b) => {
3667
+ const filteredFields = hiddenPropertyTypes && !propertyTypePresets ? allSupportedFields.filter(([key]) => {
3668
+ const baseType = WIDGET_BASE_TYPE_MAP[key];
3669
+ return !baseType || !hiddenPropertyTypes.includes(baseType);
3670
+ }) : allSupportedFields;
3671
+ const displayedWidgets = (inArray ? filteredFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.type !== "array") : filteredFields).map(([key, propertyConfig]) => ({ [key]: propertyConfig })).reduce((a, b) => {
3555
3672
  return {
3556
3673
  ...a,
3557
3674
  ...b
3558
3675
  };
3559
3676
  }, {});
3677
+ const activePreset = useMemo(() => {
3678
+ if (!propertyTypePresets || !initialProperty) return void 0;
3679
+ return propertyTypePresets.find((p) => p.detect?.(toSerializableProperty(initialProperty)));
3680
+ }, [propertyTypePresets, initialProperty]);
3560
3681
  const key = value;
3561
3682
  const propertyConfig = key ? DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key] : void 0;
3562
3683
  const baseProperty = propertyConfig?.property;
@@ -3593,7 +3714,26 @@ function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenC
3593
3714
  open,
3594
3715
  onOpenChange: (open) => onOpenChange(open, Boolean(value)),
3595
3716
  maxWidth: "4xl",
3596
- children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Select a property widget" }), /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("div", { children: groups.map((group) => {
3717
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: propertyTypePresets ? "Select a property type" : "Select a property widget" }), /* @__PURE__ */ jsx(DialogContent, { children: propertyTypePresets ? /* @__PURE__ */ jsx("div", {
3718
+ className: "grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4",
3719
+ children: propertyTypePresets.map((preset) => /* @__PURE__ */ jsx(Card, {
3720
+ onClick: () => {
3721
+ onPresetSelected?.(preset);
3722
+ onOpenChange(false, true);
3723
+ },
3724
+ className: cls("flex flex-row items-center px-4 py-2 m-1", activePreset?.id === preset.id && "ring-2 ring-primary"),
3725
+ children: /* @__PURE__ */ jsxs("div", {
3726
+ className: cls("flex flex-row items-center text-base min-h-[48px]"),
3727
+ children: [preset.icon && /* @__PURE__ */ jsx("div", {
3728
+ className: "mr-4 text-2xl",
3729
+ children: typeof preset.icon === "string" ? preset.icon : preset.icon
3730
+ }), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Typography, {
3731
+ variant: "label",
3732
+ children: preset.label
3733
+ }) })]
3734
+ })
3735
+ }, preset.id))
3736
+ }) : /* @__PURE__ */ jsx("div", { children: groups.map((group) => {
3597
3737
  return /* @__PURE__ */ jsxs("div", {
3598
3738
  className: "mt-4",
3599
3739
  children: [/* @__PURE__ */ jsx(Typography, {
@@ -3655,6 +3795,6 @@ function WidgetSelectViewItem({ onClick, initialProperty, propertyConfig, existi
3655
3795
  });
3656
3796
  }
3657
3797
  //#endregion
3658
- export { updatePropertyFromWidget as a, useAIModifiedPaths as c, supportedFields as i, PropertyForm as n, PropertyTree as o, PropertyFormDialog as r, AIModifiedPathsProvider as s, PropertyEditView_exports as t };
3798
+ export { updatePropertyFromWidget as a, useAIModifiedPaths as c, supportedFields as i, useSafeSnackbarController as l, PropertyForm as n, PropertyTree as o, PropertyFormDialog as r, AIModifiedPathsProvider as s, PropertyEditView_exports as t };
3659
3799
 
3660
- //# sourceMappingURL=PropertyEditView-C2wp8kQ9.js.map
3800
+ //# sourceMappingURL=PropertyEditView-DKzOpMjR.js.map