@rebasepro/admin 0.6.1 → 0.7.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 (134) hide show
  1. package/dist/{CollectionEditorDialog-HNXGxXdO.js → CollectionEditorDialog-iGgS4rLX.js} +233 -152
  2. package/dist/CollectionEditorDialog-iGgS4rLX.js.map +1 -0
  3. package/dist/{PropertyEditView-C2wp8kQ9.js → PropertyEditView-C9yhLyja.js} +129 -15
  4. package/dist/PropertyEditView-C9yhLyja.js.map +1 -0
  5. package/dist/{CollectionsStudioView-B1mN33GB.js → RouterCollectionsStudioView-Dqx27GD8.js} +61 -39
  6. package/dist/RouterCollectionsStudioView-Dqx27GD8.js.map +1 -0
  7. package/dist/collection_editor/extensibility_types.d.ts +135 -0
  8. package/dist/collection_editor/index.d.ts +6 -0
  9. package/dist/collection_editor/serializable_types.d.ts +374 -0
  10. package/dist/collection_editor/serializable_utils.d.ts +50 -0
  11. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
  12. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +12 -1
  13. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +13 -1
  14. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +24 -2
  15. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +2 -1
  16. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +4 -1
  17. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +12 -1
  18. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
  19. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
  20. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
  21. package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
  22. package/dist/collection_editor_ui.d.ts +4 -0
  23. package/dist/collection_editor_ui.js +33 -4
  24. package/dist/collection_editor_ui.js.map +1 -0
  25. package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +3 -3
  26. package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +3 -3
  27. package/dist/components/EntityEditView.d.ts +3 -2
  28. package/dist/components/RebaseCMS.d.ts +1 -1
  29. package/dist/form/EntityForm.d.ts +10 -9
  30. package/dist/form/EntityFormBinding.d.ts +27 -0
  31. package/dist/form/form_utils.d.ts +8 -0
  32. package/dist/form/index.d.ts +5 -1
  33. package/dist/{history-BO6VT85a.js → history-ChHgyyvM.js} +2 -2
  34. package/dist/{history-BO6VT85a.js.map → history-ChHgyyvM.js.map} +1 -1
  35. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  36. package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
  37. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
  38. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -1
  39. package/dist/hooks/navigation/utils.d.ts +1 -1
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +2 -2
  42. package/dist/routes/CustomViewRoute.d.ts +2 -1
  43. package/dist/{src-BYniefVu.js → src-DOX2nOyh.js} +1586 -1283
  44. package/dist/src-DOX2nOyh.js.map +1 -0
  45. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  46. package/dist/types/components/EntityFormProps.d.ts +59 -0
  47. package/dist/types/fields.d.ts +6 -1
  48. package/dist/util/dataControllerAdapter.d.ts +30 -0
  49. package/dist/util/navigation_utils.d.ts +1 -1
  50. package/dist/util/propertyConfigMapper.d.ts +17 -0
  51. package/package.json +18 -18
  52. package/src/collection_editor/extensibility_types.ts +168 -0
  53. package/src/collection_editor/index.ts +46 -0
  54. package/src/collection_editor/serializable_types.ts +487 -0
  55. package/src/collection_editor/serializable_utils.ts +588 -0
  56. package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +4 -4
  57. package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +134 -70
  58. package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +95 -78
  59. package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +23 -20
  60. package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +79 -27
  61. package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +9 -7
  62. package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +22 -5
  63. package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +3 -3
  64. package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +155 -10
  65. package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +6 -6
  66. package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +1 -0
  67. package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
  68. package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
  69. package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +4 -3
  70. package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
  71. package/src/collection_editor/useSafeSnackbarController.ts +9 -0
  72. package/src/collection_editor_ui.ts +6 -0
  73. package/src/components/DefaultDrawer.tsx +13 -3
  74. package/src/components/DrawerNavigationGroup.tsx +2 -2
  75. package/src/components/EntityCollectionView/EntityBoardCard.tsx +6 -6
  76. package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -11
  77. package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +40 -190
  78. package/src/components/EntityCollectionView/EntityCollectionListView.tsx +54 -183
  79. package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +6 -6
  80. package/src/components/EntityEditView.tsx +5 -4
  81. package/src/components/EntityEditViewFormActions.tsx +32 -26
  82. package/src/components/HomePage/ContentHomePage.tsx +13 -4
  83. package/src/components/RebaseCMS.tsx +3 -2
  84. package/src/components/RebaseNavigation.tsx +71 -7
  85. package/src/components/SelectableTable/SelectableTable.tsx +2 -2
  86. package/src/components/SideDialogs.tsx +0 -7
  87. package/src/components/common/default_entity_actions.tsx +9 -9
  88. package/src/contexts/BreacrumbsContext.tsx +15 -6
  89. package/src/editor/selectors/ai-selector.tsx +0 -1
  90. package/src/form/EntityForm.tsx +191 -428
  91. package/src/form/EntityFormActions.tsx +33 -47
  92. package/src/form/EntityFormBinding.tsx +323 -0
  93. package/src/form/components/FormLayout.tsx +1 -1
  94. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +7 -2
  95. package/src/form/form_utils.ts +163 -0
  96. package/src/form/index.tsx +14 -5
  97. package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +2 -2
  98. package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
  99. package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
  100. package/src/hooks/navigation/useAsyncResolver.ts +100 -0
  101. package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +15 -8
  102. package/src/hooks/navigation/useBuildNavigationStateController.tsx +12 -8
  103. package/src/hooks/navigation/useNavigationResolution.ts +33 -0
  104. package/src/hooks/navigation/useResolvedCollections.ts +29 -71
  105. package/src/hooks/navigation/useResolvedViews.tsx +40 -70
  106. package/src/hooks/navigation/useTopLevelNavigation.ts +20 -16
  107. package/src/hooks/navigation/utils.ts +7 -4
  108. package/src/index.ts +5 -0
  109. package/src/routes/CustomViewRoute.tsx +14 -6
  110. package/src/types/components/EntityFormActionsProps.tsx +1 -1
  111. package/src/types/components/EntityFormProps.tsx +68 -0
  112. package/src/types/fields.tsx +7 -1
  113. package/src/util/dataControllerAdapter.ts +93 -0
  114. package/src/util/navigation_utils.ts +1 -1
  115. package/src/util/propertyConfigMapper.ts +134 -0
  116. package/LICENSE +0 -21
  117. package/dist/CollectionEditorDialog-HNXGxXdO.js.map +0 -1
  118. package/dist/CollectionsStudioView-B1mN33GB.js.map +0 -1
  119. package/dist/PropertyEditView-C2wp8kQ9.js.map +0 -1
  120. package/dist/components/EntityCollectionView/Board.d.ts +0 -3
  121. package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
  122. package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
  123. package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
  124. package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
  125. package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -12
  126. package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
  127. package/dist/src-BYniefVu.js.map +0 -1
  128. package/src/components/EntityCollectionView/Board.tsx +0 -475
  129. package/src/components/EntityCollectionView/BoardColumn.tsx +0 -165
  130. package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -46
  131. package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
  132. package/src/components/EntityCollectionView/board_types.ts +0 -113
  133. package/src/hooks/navigation/useNavigationRegistry.ts +0 -164
  134. package/src/hooks/navigation/useNavigationURLs.ts +0 -56
@@ -1,5 +1,5 @@
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, Gn as useCollectionRegistryController, It as DEFAULT_FIELD_CONFIGS, _ as toSerializableProperty, a as namespaceToPropertiesPath, h as toSerializableCollection, i as namespaceToPropertiesOrderPath, n as getFullIdPath, nn as ArrayContainer, pn as FieldCaption, r as idToPropertiesPath, t as getFullId, zt as getFieldConfig } from "./src-DOX2nOyh.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";
@@ -13,6 +13,15 @@ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
13
13
  import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
14
14
  import { CSS } from "@dnd-kit/utilities";
15
15
  import { extractEnumFromValues } from "@rebasepro/schema-inference";
16
+ //#region src/collection_editor/useSafeSnackbarController.ts
17
+ function useSafeSnackbarController() {
18
+ try {
19
+ return useSnackbarController();
20
+ } catch {
21
+ return;
22
+ }
23
+ }
24
+ //#endregion
16
25
  //#region src/collection_editor/ui/collection_editor/EnumForm.tsx
17
26
  function EnumForm({ enumValues, onValuesChanged, onError, updateIds, disabled, allowDataInference, getData }) {
18
27
  const formex = useCreateFormex({
@@ -483,7 +492,7 @@ function ValidationPanel({ children }) {
483
492
  //#region src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx
484
493
  function EnumPropertyField({ multiselect, updateIds, disabled, showErrors, allowDataInference, getData, propertyNamespace }) {
485
494
  const { values, setFieldError, setFieldValue } = useFormex();
486
- const snackbarContext = useSnackbarController();
495
+ const snackbarContext = useSafeSnackbarController();
487
496
  const { t } = useTranslation();
488
497
  const enumValuesPath = multiselect ? "of.enum" : "enum";
489
498
  const defaultValue = getIn(values, "defaultValue");
@@ -499,7 +508,7 @@ function EnumPropertyField({ multiselect, updateIds, disabled, showErrors, allow
499
508
  const enumIds = value.filter((v) => Boolean(v?.id)).map((v) => v.id);
500
509
  if (defaultValue && !enumIds.includes(defaultValue)) {
501
510
  setFieldValue("defaultValue", void 0);
502
- snackbarContext.open({
511
+ snackbarContext?.open({
503
512
  type: "warning",
504
513
  message: "Default value was cleared"
505
514
  });
@@ -875,8 +884,8 @@ function PropertyFieldPreview({ property, propertyKey, onClick, hasError, includ
875
884
  return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx("div", {
876
885
  onClick,
877
886
  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"),
887
+ children: /* @__PURE__ */ jsxs("div", {
888
+ 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
889
  children: [
881
890
  /* @__PURE__ */ jsx(PropertyConfigBadge, {
882
891
  propertyConfig,
@@ -927,8 +936,8 @@ function NonEditablePropertyPreview({ name, selected, onClick, property }) {
927
936
  return /* @__PURE__ */ jsx("div", {
928
937
  onClick,
929
938
  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"),
939
+ children: /* @__PURE__ */ jsxs("div", {
940
+ 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
941
  children: [
933
942
  /* @__PURE__ */ jsxs("div", {
934
943
  className: "relative shrink-0",
@@ -1157,6 +1166,7 @@ function PropertyTreeEntry({ id, propertyKey, namespace, property, additionalFie
1157
1166
  }),
1158
1167
  /* @__PURE__ */ jsx("div", { children: !isPropertyBuilder(property) && !additionalField && editable ? /* @__PURE__ */ jsx(PropertyFieldPreview, {
1159
1168
  property,
1169
+ propertyKey,
1160
1170
  onClick: onPropertyClick ? () => onPropertyClick(propertyKey, namespace) : void 0,
1161
1171
  includeName: true,
1162
1172
  selected,
@@ -3167,7 +3177,7 @@ var PropertyEditView_exports = /* @__PURE__ */ __exportAll({
3167
3177
  WidgetSelectViewItem: () => WidgetSelectViewItem
3168
3178
  });
3169
3179
  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;
3180
+ 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
3181
  const initialValue = {
3172
3182
  id: "",
3173
3183
  name: ""
@@ -3254,6 +3264,10 @@ var PropertyForm = React.memo(function PropertyForm(props) {
3254
3264
  getData,
3255
3265
  allowDataInference,
3256
3266
  propertyConfigs,
3267
+ propertyTypePresets,
3268
+ hiddenPropertyTypes,
3269
+ renderExtraPropertyFields,
3270
+ collectionValues,
3257
3271
  ...formexController
3258
3272
  })
3259
3273
  });
@@ -3306,7 +3320,7 @@ function PropertyFormDialog({ open, onCancel, onOkClicked, onPropertyChanged, ge
3306
3320
  })
3307
3321
  });
3308
3322
  }
3309
- function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdateId = false, autoOpenTypeSelect, includeIdAndTitle, onPropertyChanged, onDelete, propertyNamespace, onDismiss, onError, showErrors, disabled, inArray, getData, allowDataInference, propertyConfigs }) {
3323
+ 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
3324
  const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);
3311
3325
  const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
3312
3326
  const [selectedFieldConfigId, setSelectedFieldConfigId] = useState(values?.type ? getFieldId(values) : void 0);
@@ -3347,6 +3361,31 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3347
3361
  nameFieldRef.current?.focus();
3348
3362
  }, 0);
3349
3363
  };
3364
+ const onPresetSelected = useCallback((preset) => {
3365
+ const widgetId = {
3366
+ "string": "text_field",
3367
+ "number": "number_input",
3368
+ "boolean": "switch",
3369
+ "date": "date_time",
3370
+ "reference": "reference",
3371
+ "relation": "relation",
3372
+ "map": "group",
3373
+ "array": "repeat",
3374
+ "vector": "vector_input",
3375
+ "geopoint": "text_field",
3376
+ "binary": "text_field"
3377
+ }[preset.baseType] || "text_field";
3378
+ setSelectedFieldConfigId(widgetId);
3379
+ setValues({
3380
+ ...updatePropertyFromWidget(values, widgetId, propertyConfigs),
3381
+ ...preset.defaults,
3382
+ propertyConfig: widgetId
3383
+ });
3384
+ }, [
3385
+ values,
3386
+ propertyConfigs,
3387
+ setValues
3388
+ ]);
3350
3389
  let childComponent;
3351
3390
  if (selectedFieldConfigId === "text_field" || selectedFieldConfigId === "multiline" || selectedFieldConfigId === "user_select" || selectedFieldConfigId === "email") childComponent = /* @__PURE__ */ jsx(StringPropertyField, {
3352
3391
  widgetId: selectedFieldConfigId,
@@ -3463,7 +3502,10 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3463
3502
  showError: Boolean(selectedWidgetError),
3464
3503
  existing,
3465
3504
  propertyConfigs,
3466
- inArray
3505
+ inArray,
3506
+ propertyTypePresets,
3507
+ hiddenPropertyTypes,
3508
+ onPresetSelected
3467
3509
  }), !!selectedWidgetError && /* @__PURE__ */ jsx(Typography, {
3468
3510
  variant: "caption",
3469
3511
  className: "ml-3.5",
@@ -3490,6 +3532,24 @@ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdat
3490
3532
  ref: nameFieldRef
3491
3533
  }),
3492
3534
  childComponent,
3535
+ renderExtraPropertyFields && collectionValues && /* @__PURE__ */ jsx("div", {
3536
+ className: "col-span-12 mt-4 px-2",
3537
+ children: renderExtraPropertyFields({
3538
+ metadata: values.metadata ?? {},
3539
+ onMetadataChange: (key, value) => {
3540
+ const currentMetadata = values.metadata ?? {};
3541
+ setValues({
3542
+ ...values,
3543
+ metadata: {
3544
+ ...currentMetadata,
3545
+ [key]: value
3546
+ }
3547
+ });
3548
+ },
3549
+ property: toSerializableProperty(values),
3550
+ collection: toSerializableCollection(collectionValues)
3551
+ })
3552
+ }),
3493
3553
  /* @__PURE__ */ jsx("div", {
3494
3554
  className: "col-span-12",
3495
3555
  children: /* @__PURE__ */ jsx(AdvancedPropertyValidation, { disabled })
@@ -3549,14 +3609,49 @@ var WIDGET_TYPE_MAP = {
3549
3609
  block: "Group",
3550
3610
  vector_input: "Number"
3551
3611
  };
3552
- function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenChange, disabled, showError, existing, propertyConfigs, inArray }) {
3612
+ var WIDGET_BASE_TYPE_MAP = {
3613
+ text_field: "string",
3614
+ multiline: "string",
3615
+ markdown: "string",
3616
+ url: "string",
3617
+ email: "string",
3618
+ select: "string",
3619
+ multi_select: "string",
3620
+ file_upload: "string",
3621
+ multi_file_upload: "string",
3622
+ reference_as_string: "string",
3623
+ user_select: "string",
3624
+ number_input: "number",
3625
+ number_select: "number",
3626
+ multi_number_select: "number",
3627
+ switch: "boolean",
3628
+ date_time: "date",
3629
+ reference: "reference",
3630
+ multi_references: "reference",
3631
+ relation: "relation",
3632
+ group: "map",
3633
+ key_value: "map",
3634
+ block: "map",
3635
+ repeat: "array",
3636
+ custom_array: "array",
3637
+ vector_input: "vector"
3638
+ };
3639
+ function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenChange, disabled, showError, existing, propertyConfigs, inArray, propertyTypePresets, hiddenPropertyTypes, onPresetSelected }) {
3553
3640
  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) => {
3641
+ const filteredFields = hiddenPropertyTypes && !propertyTypePresets ? allSupportedFields.filter(([key]) => {
3642
+ const baseType = WIDGET_BASE_TYPE_MAP[key];
3643
+ return !baseType || !hiddenPropertyTypes.includes(baseType);
3644
+ }) : allSupportedFields;
3645
+ const displayedWidgets = (inArray ? filteredFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.type !== "array") : filteredFields).map(([key, propertyConfig]) => ({ [key]: propertyConfig })).reduce((a, b) => {
3555
3646
  return {
3556
3647
  ...a,
3557
3648
  ...b
3558
3649
  };
3559
3650
  }, {});
3651
+ const activePreset = useMemo(() => {
3652
+ if (!propertyTypePresets || !initialProperty) return void 0;
3653
+ return propertyTypePresets.find((p) => p.detect?.(toSerializableProperty(initialProperty)));
3654
+ }, [propertyTypePresets, initialProperty]);
3560
3655
  const key = value;
3561
3656
  const propertyConfig = key ? DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key] : void 0;
3562
3657
  const baseProperty = propertyConfig?.property;
@@ -3593,7 +3688,26 @@ function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenC
3593
3688
  open,
3594
3689
  onOpenChange: (open) => onOpenChange(open, Boolean(value)),
3595
3690
  maxWidth: "4xl",
3596
- children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Select a property widget" }), /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("div", { children: groups.map((group) => {
3691
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: propertyTypePresets ? "Select a property type" : "Select a property widget" }), /* @__PURE__ */ jsx(DialogContent, { children: propertyTypePresets ? /* @__PURE__ */ jsx("div", {
3692
+ className: "grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4",
3693
+ children: propertyTypePresets.map((preset) => /* @__PURE__ */ jsx(Card, {
3694
+ onClick: () => {
3695
+ onPresetSelected?.(preset);
3696
+ onOpenChange(false, true);
3697
+ },
3698
+ className: cls("flex flex-row items-center px-4 py-2 m-1", activePreset?.id === preset.id && "ring-2 ring-primary"),
3699
+ children: /* @__PURE__ */ jsxs("div", {
3700
+ className: cls("flex flex-row items-center text-base min-h-[48px]"),
3701
+ children: [preset.icon && /* @__PURE__ */ jsx("div", {
3702
+ className: "mr-4 text-2xl",
3703
+ children: typeof preset.icon === "string" ? preset.icon : preset.icon
3704
+ }), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Typography, {
3705
+ variant: "label",
3706
+ children: preset.label
3707
+ }) })]
3708
+ })
3709
+ }, preset.id))
3710
+ }) : /* @__PURE__ */ jsx("div", { children: groups.map((group) => {
3597
3711
  return /* @__PURE__ */ jsxs("div", {
3598
3712
  className: "mt-4",
3599
3713
  children: [/* @__PURE__ */ jsx(Typography, {
@@ -3655,6 +3769,6 @@ function WidgetSelectViewItem({ onClick, initialProperty, propertyConfig, existi
3655
3769
  });
3656
3770
  }
3657
3771
  //#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 };
3772
+ 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
3773
 
3660
- //# sourceMappingURL=PropertyEditView-C2wp8kQ9.js.map
3774
+ //# sourceMappingURL=PropertyEditView-C9yhLyja.js.map