@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.
- package/dist/{CollectionEditorDialog-HNXGxXdO.js → CollectionEditorDialog-iGgS4rLX.js} +233 -152
- package/dist/CollectionEditorDialog-iGgS4rLX.js.map +1 -0
- package/dist/{PropertyEditView-C2wp8kQ9.js → PropertyEditView-C9yhLyja.js} +129 -15
- package/dist/PropertyEditView-C9yhLyja.js.map +1 -0
- package/dist/{CollectionsStudioView-B1mN33GB.js → RouterCollectionsStudioView-Dqx27GD8.js} +61 -39
- package/dist/RouterCollectionsStudioView-Dqx27GD8.js.map +1 -0
- package/dist/collection_editor/extensibility_types.d.ts +135 -0
- package/dist/collection_editor/index.d.ts +6 -0
- package/dist/collection_editor/serializable_types.d.ts +374 -0
- package/dist/collection_editor/serializable_utils.d.ts +50 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +13 -1
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +24 -2
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +4 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
- package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
- package/dist/collection_editor_ui.d.ts +4 -0
- package/dist/collection_editor_ui.js +33 -4
- package/dist/collection_editor_ui.js.map +1 -0
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +3 -3
- package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +3 -3
- package/dist/components/EntityEditView.d.ts +3 -2
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +10 -9
- package/dist/form/EntityFormBinding.d.ts +27 -0
- package/dist/form/form_utils.d.ts +8 -0
- package/dist/form/index.d.ts +5 -1
- package/dist/{history-BO6VT85a.js → history-ChHgyyvM.js} +2 -2
- package/dist/{history-BO6VT85a.js.map → history-ChHgyyvM.js.map} +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -1
- package/dist/hooks/navigation/utils.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/dist/routes/CustomViewRoute.d.ts +2 -1
- package/dist/{src-BYniefVu.js → src-DOX2nOyh.js} +1586 -1283
- package/dist/src-DOX2nOyh.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/EntityFormProps.d.ts +59 -0
- package/dist/types/fields.d.ts +6 -1
- package/dist/util/dataControllerAdapter.d.ts +30 -0
- package/dist/util/navigation_utils.d.ts +1 -1
- package/dist/util/propertyConfigMapper.d.ts +17 -0
- package/package.json +18 -18
- package/src/collection_editor/extensibility_types.ts +168 -0
- package/src/collection_editor/index.ts +46 -0
- package/src/collection_editor/serializable_types.ts +487 -0
- package/src/collection_editor/serializable_utils.ts +588 -0
- package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +134 -70
- package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +95 -78
- package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +23 -20
- package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +79 -27
- package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +9 -7
- package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +22 -5
- package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +3 -3
- package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +155 -10
- package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +6 -6
- package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +1 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
- package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +4 -3
- package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
- package/src/collection_editor/useSafeSnackbarController.ts +9 -0
- package/src/collection_editor_ui.ts +6 -0
- package/src/components/DefaultDrawer.tsx +13 -3
- package/src/components/DrawerNavigationGroup.tsx +2 -2
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +6 -6
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -11
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +40 -190
- package/src/components/EntityCollectionView/EntityCollectionListView.tsx +54 -183
- package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +6 -6
- package/src/components/EntityEditView.tsx +5 -4
- package/src/components/EntityEditViewFormActions.tsx +32 -26
- package/src/components/HomePage/ContentHomePage.tsx +13 -4
- package/src/components/RebaseCMS.tsx +3 -2
- package/src/components/RebaseNavigation.tsx +71 -7
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SideDialogs.tsx +0 -7
- package/src/components/common/default_entity_actions.tsx +9 -9
- package/src/contexts/BreacrumbsContext.tsx +15 -6
- package/src/editor/selectors/ai-selector.tsx +0 -1
- package/src/form/EntityForm.tsx +191 -428
- package/src/form/EntityFormActions.tsx +33 -47
- package/src/form/EntityFormBinding.tsx +323 -0
- package/src/form/components/FormLayout.tsx +1 -1
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +7 -2
- package/src/form/form_utils.ts +163 -0
- package/src/form/index.tsx +14 -5
- package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +2 -2
- package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
- package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
- package/src/hooks/navigation/useAsyncResolver.ts +100 -0
- package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +15 -8
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +12 -8
- package/src/hooks/navigation/useNavigationResolution.ts +33 -0
- package/src/hooks/navigation/useResolvedCollections.ts +29 -71
- package/src/hooks/navigation/useResolvedViews.tsx +40 -70
- package/src/hooks/navigation/useTopLevelNavigation.ts +20 -16
- package/src/hooks/navigation/utils.ts +7 -4
- package/src/index.ts +5 -0
- package/src/routes/CustomViewRoute.tsx +14 -6
- package/src/types/components/EntityFormActionsProps.tsx +1 -1
- package/src/types/components/EntityFormProps.tsx +68 -0
- package/src/types/fields.tsx +7 -1
- package/src/util/dataControllerAdapter.ts +93 -0
- package/src/util/navigation_utils.ts +1 -1
- package/src/util/propertyConfigMapper.ts +134 -0
- package/LICENSE +0 -21
- package/dist/CollectionEditorDialog-HNXGxXdO.js.map +0 -1
- package/dist/CollectionsStudioView-B1mN33GB.js.map +0 -1
- package/dist/PropertyEditView-C2wp8kQ9.js.map +0 -1
- package/dist/components/EntityCollectionView/Board.d.ts +0 -3
- package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
- package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
- package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -12
- package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
- package/dist/src-BYniefVu.js.map +0 -1
- package/src/components/EntityCollectionView/Board.tsx +0 -475
- package/src/components/EntityCollectionView/BoardColumn.tsx +0 -165
- package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -46
- package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
- package/src/components/EntityCollectionView/board_types.ts +0 -113
- package/src/hooks/navigation/useNavigationRegistry.ts +0 -164
- 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
|
|
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 =
|
|
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
|
|
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(
|
|
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-
|
|
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(
|
|
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-
|
|
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
|
-
|
|
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
|
|
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", {
|
|
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-
|
|
3774
|
+
//# sourceMappingURL=PropertyEditView-C9yhLyja.js.map
|