@rebasepro/admin 0.2.1 → 0.2.4
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-BXIh2AXg.js → CollectionEditorDialog-D0VqpLPO.js} +73 -256
- package/dist/CollectionEditorDialog-D0VqpLPO.js.map +1 -0
- package/dist/{CollectionsStudioView-jR8iz_ja.js → CollectionsStudioView-Bc3Rxxc2.js} +5 -4
- package/dist/{CollectionsStudioView-jR8iz_ja.js.map → CollectionsStudioView-Bc3Rxxc2.js.map} +1 -1
- package/dist/{ExportCollectionAction-CMdiiv1L.js → ExportCollectionAction-Ckc-09BQ.js} +4 -3
- package/dist/ExportCollectionAction-Ckc-09BQ.js.map +1 -0
- package/dist/{ImportCollectionAction-C05lE0IW.js → ImportCollectionAction-BqjIrC3Z.js} +3 -2
- package/dist/{ImportCollectionAction-C05lE0IW.js.map → ImportCollectionAction-BqjIrC3Z.js.map} +1 -1
- package/dist/{PropertyEditView-BB5xjnhZ.js → PropertyEditView-CvRSV-A2.js} +430 -445
- package/dist/PropertyEditView-CvRSV-A2.js.map +1 -0
- package/dist/collection_editor/ConfigControllerProvider.d.ts +0 -5
- package/dist/collection_editor/index.d.ts +0 -1
- package/dist/collection_editor/types/collection_editor_controller.d.ts +0 -2
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +3 -3
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.d.ts +1 -7
- package/dist/collection_editor_ui.js +3 -3
- package/dist/components/ArrayContainer.d.ts +2 -2
- package/dist/components/DefaultAppBar.d.ts +18 -1
- package/dist/components/DefaultDrawer.d.ts +51 -3
- package/dist/components/EntityCollectionTable/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/table_bindings.d.ts +4 -3
- package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +4 -3
- package/dist/components/EntityEditView.d.ts +2 -1
- package/dist/components/HomePage/HomePageDnD.d.ts +3 -3
- package/dist/components/PropertyCollectionView.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +4 -1
- package/dist/components/SelectableTable/filters/BooleanFilterField.d.ts +2 -2
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -2
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +2 -2
- package/dist/components/admin/RolesView.d.ts +3 -3
- package/dist/components/admin/UsersView.d.ts +3 -3
- package/dist/components/app/Drawer.d.ts +8 -1
- package/dist/data_export/export/export.d.ts +3 -3
- package/dist/editor/components/editor-bubble.d.ts +5 -1
- package/dist/editor/components/image-bubble.d.ts +5 -1
- package/dist/editor/components/index.d.ts +3 -3
- package/dist/editor/components/table-bubble.d.ts +5 -1
- package/dist/editor/nodeViews/ReactNodeView.d.ts +4 -1
- package/dist/editor/useProseMirror.d.ts +2 -2
- package/dist/editor/utils/remove_classes.d.ts +1 -1
- package/dist/editor.js +15 -14
- package/dist/editor.js.map +1 -1
- package/dist/form/EntityForm.d.ts +2 -2
- package/dist/form/components/StorageUploadProgress.d.ts +2 -2
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/form/validation.d.ts +3 -3
- package/dist/hooks/navigation/useResolvedCollections.d.ts +6 -0
- package/dist/hooks/navigation/useResolvedViews.d.ts +3 -4
- package/dist/{index-BAM9KCmM.js → index-BCcLwgfe.js} +3 -2
- package/dist/{index-BAM9KCmM.js.map → index-BCcLwgfe.js.map} +1 -1
- package/dist/{index-D5OQhv-T.js → index-DY2k5TtG.js} +3 -3
- package/dist/index-DY2k5TtG.js.map +1 -0
- package/dist/{index-CoSNm3e3.js → index-UQOMHwt1.js} +3 -3
- package/dist/index-UQOMHwt1.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2813 -372
- package/dist/index.js.map +1 -1
- package/dist/{markdown-z2Ir7Cgo.js → markdown-DD2JDU1X.js} +2 -2
- package/dist/markdown-DD2JDU1X.js.map +1 -0
- package/dist/preview/components/UrlComponentPreview.d.ts +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/EntityFormProps.d.ts +2 -2
- package/dist/types/fields.d.ts +1 -1
- package/dist/{util-DtbWD7LF.js → util-ZM9gQuCv.js} +2104 -2071
- package/dist/util-ZM9gQuCv.js.map +1 -0
- package/package.json +10 -9
- package/src/collection_editor/ConfigControllerProvider.tsx +3 -13
- package/src/collection_editor/index.ts +1 -3
- package/src/collection_editor/types/collection_editor_controller.tsx +0 -3
- package/src/collection_editor/ui/EditorCollectionAction.tsx +1 -6
- package/src/collection_editor/ui/EditorCollectionActionStart.tsx +1 -6
- package/src/collection_editor/ui/EditorEntityAction.tsx +1 -6
- package/src/collection_editor/ui/HomePageEditorCollectionAction.tsx +7 -14
- package/src/collection_editor/ui/NewCollectionCard.tsx +1 -5
- package/src/collection_editor/ui/PropertyAddColumnComponent.tsx +3 -8
- package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +1 -10
- package/src/collection_editor/ui/collection_editor/CollectionJsonImportDialog.tsx +8 -12
- package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +21 -21
- package/src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/EnumForm.tsx +1 -1
- package/src/collection_editor/ui/collection_editor/properties/BlockPropertyField.tsx +3 -3
- package/src/collection_editor/ui/collection_editor/properties/CommonPropertyFields.tsx +3 -3
- package/src/collection_editor/ui/collection_editor/properties/DateTimePropertyField.tsx +8 -8
- package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +5 -5
- package/src/collection_editor/ui/collection_editor/properties/MapPropertyField.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.tsx +5 -5
- package/src/collection_editor/ui/collection_editor/properties/NumberPropertyField.tsx +5 -5
- package/src/collection_editor/ui/collection_editor/properties/ReferencePropertyField.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/properties/RelationPropertyField.tsx +37 -57
- package/src/collection_editor/ui/collection_editor/properties/RepeatPropertyField.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx +8 -8
- package/src/collection_editor/ui/collection_editor/properties/StringPropertyField.tsx +5 -5
- package/src/collection_editor/ui/collection_editor/properties/UrlPropertyField.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/properties/VectorPropertyField.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +1 -1
- package/src/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +4 -7
- package/src/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +4 -4
- package/src/collection_editor/validateCollectionJson.ts +88 -1
- package/src/components/ArrayContainer.tsx +3 -3
- package/src/components/DefaultAppBar.tsx +52 -31
- package/src/components/DefaultDrawer.tsx +279 -66
- package/src/components/DrawerNavigationItem.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +6 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +9 -7
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -5
- package/src/components/EntityCollectionTable/fields/VirtualTableNumberInput.tsx +12 -9
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +1 -1
- package/src/components/EntityCollectionTable/table_bindings.tsx +5 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +6 -4
- package/src/components/EntityCollectionView/hooks/useCollectionInlineEditor.ts +1 -1
- package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +7 -6
- package/src/components/EntityDetailView.tsx +46 -24
- package/src/components/EntityEditView.tsx +51 -28
- package/src/components/EntityEditViewFormActions.tsx +4 -4
- package/src/components/EntityPreview.tsx +9 -4
- package/src/components/HomePage/HomePageDnD.tsx +3 -2
- package/src/components/PropertyCollectionView.tsx +1 -1
- package/src/components/PropertyIdCopyTooltip.tsx +1 -1
- package/src/components/RebaseLayout.tsx +5 -1
- package/src/components/RebaseNavigation.tsx +2 -2
- package/src/components/RebaseRouteDefs.tsx +4 -7
- package/src/components/RebaseShell.tsx +16 -13
- package/src/components/SearchIconsView.tsx +1 -8
- package/src/components/SelectableTable/SelectableTable.tsx +8 -11
- package/src/components/SelectableTable/SelectionStore.ts +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +3 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +3 -3
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +5 -5
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +3 -3
- package/src/components/SideEntityProvider.tsx +2 -1
- package/src/components/admin/RolesView.tsx +7 -2
- package/src/components/admin/UsersView.tsx +12 -6
- package/src/components/app/Drawer.tsx +9 -1
- package/src/components/app/Scaffold.tsx +5 -1
- package/src/data_export/export/export.ts +17 -17
- package/src/data_import/components/DataNewPropertiesMapping.tsx +1 -1
- package/src/editor/components/editor-bubble.tsx +32 -9
- package/src/editor/components/image-bubble.tsx +27 -11
- package/src/editor/components/index.ts +3 -3
- package/src/editor/components/table-bubble.tsx +79 -17
- package/src/editor/extensions/HighlightDecorationExtension.ts +3 -2
- package/src/editor/nodeViews/ReactNodeView.tsx +1 -1
- package/src/editor/nodeViews/TaskItemComponent.tsx +9 -8
- package/src/editor/schema.ts +135 -59
- package/src/editor/selectors/link-selector.tsx +8 -5
- package/src/editor/useProseMirror.ts +2 -2
- package/src/editor/utils/remove_classes.ts +6 -5
- package/src/form/EntityForm.tsx +15 -15
- package/src/form/EntityFormActions.tsx +2 -2
- package/src/form/PropertyFieldBinding.tsx +64 -64
- package/src/form/components/FieldHelperText.tsx +4 -4
- package/src/form/components/StorageUploadProgress.tsx +2 -2
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -1
- package/src/form/field_bindings/BlockFieldBinding.tsx +54 -53
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +290 -289
- package/src/form/field_bindings/MapFieldBinding.tsx +2 -2
- package/src/form/field_bindings/MultiSelectFieldBinding.tsx +2 -2
- package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +8 -6
- package/src/form/field_bindings/RelationFieldBinding.tsx +4 -4
- package/src/form/field_bindings/RepeatFieldBinding.tsx +1 -1
- package/src/form/field_bindings/SelectFieldBinding.tsx +1 -1
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +84 -84
- package/src/form/field_bindings/SwitchFieldBinding.tsx +16 -16
- package/src/form/field_bindings/TextFieldBinding.tsx +77 -73
- package/src/form/field_bindings/UserSelectFieldBinding.tsx +17 -17
- package/src/form/validation.ts +43 -43
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +3 -5
- package/src/hooks/navigation/useResolvedCollections.ts +27 -7
- package/src/hooks/navigation/useResolvedViews.tsx +24 -44
- package/src/index.ts +2 -0
- package/src/preview/PropertyPreview.tsx +2 -2
- package/src/preview/components/ImagePreview.tsx +2 -1
- package/src/preview/components/UrlComponentPreview.tsx +11 -2
- package/src/preview/components/UserPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOfRelationsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +3 -2
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +6 -8
- package/src/preview/property_previews/ArrayPropertyEnumPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +4 -3
- package/src/preview/property_previews/NumberPropertyPreview.tsx +5 -3
- package/src/preview/property_previews/StringPropertyPreview.tsx +10 -8
- package/src/types/components/EntityFormActionsProps.tsx +1 -1
- package/src/types/components/EntityFormProps.tsx +2 -2
- package/src/types/fields.tsx +2 -2
- package/dist/CollectionEditorDialog-BXIh2AXg.js.map +0 -1
- package/dist/ContentHomePage-BQZWuOFb.js +0 -1784
- package/dist/ContentHomePage-BQZWuOFb.js.map +0 -1
- package/dist/ExportCollectionAction-CMdiiv1L.js.map +0 -1
- package/dist/PropertyEditView-BB5xjnhZ.js.map +0 -1
- package/dist/RoleChip-QtUFXeTp.js +0 -67
- package/dist/RoleChip-QtUFXeTp.js.map +0 -1
- package/dist/RolesView-CULIHWZ9.js +0 -437
- package/dist/RolesView-CULIHWZ9.js.map +0 -1
- package/dist/UsersView-D7_AtJ44.js +0 -408
- package/dist/UsersView-D7_AtJ44.js.map +0 -1
- package/dist/collection_editor/types/config_permissions.d.ts +0 -19
- package/dist/index-CoSNm3e3.js.map +0 -1
- package/dist/index-D5OQhv-T.js.map +0 -1
- package/dist/markdown-z2Ir7Cgo.js.map +0 -1
- package/dist/util-DtbWD7LF.js.map +0 -1
- package/src/collection_editor/types/config_permissions.ts +0 -20
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import type { FieldProps } from "../../types/fields";
|
|
3
2
|
import type { MapProperty } from "@rebasepro/types";
|
|
4
3
|
import React, { useEffect, useState } from "react";
|
|
@@ -39,19 +38,19 @@ type MapEditViewRowState = [number, {
|
|
|
39
38
|
* @group Form fields
|
|
40
39
|
*/
|
|
41
40
|
export function KeyValueFieldBinding({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}: FieldProps<MapProperty>) {
|
|
41
|
+
propertyKey,
|
|
42
|
+
value,
|
|
43
|
+
showError,
|
|
44
|
+
error,
|
|
45
|
+
disabled,
|
|
46
|
+
property,
|
|
47
|
+
setValue,
|
|
48
|
+
minimalistView,
|
|
49
|
+
includeDescription,
|
|
50
|
+
underlyingValueHasChanged,
|
|
51
|
+
autoFocus,
|
|
52
|
+
context
|
|
53
|
+
}: FieldProps<MapProperty>) {
|
|
55
54
|
|
|
56
55
|
const expanded = (property.ui?.expanded === undefined ? true : property.ui?.expanded) || autoFocus;
|
|
57
56
|
|
|
@@ -62,10 +61,10 @@ export function KeyValueFieldBinding({
|
|
|
62
61
|
const initialValues = getIn(context.formex.initialValues, propertyKey) as Record<string, unknown> | undefined;
|
|
63
62
|
|
|
64
63
|
const mapFormView = <MapEditView value={value}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
setValue={setValue}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
initialValue={initialValues}
|
|
67
|
+
fieldName={property.name ?? propertyKey}/>;
|
|
69
68
|
|
|
70
69
|
const title = <LabelWithIconAndTooltip
|
|
71
70
|
propertyKey={propertyKey}
|
|
@@ -78,22 +77,22 @@ export function KeyValueFieldBinding({
|
|
|
78
77
|
<>
|
|
79
78
|
|
|
80
79
|
{!minimalistView && <ExpandablePanel initiallyExpanded={expanded}
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
title={title}
|
|
81
|
+
innerClassName={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2"}>{mapFormView}</ExpandablePanel>}
|
|
83
82
|
|
|
84
83
|
{minimalistView && mapFormView}
|
|
85
84
|
|
|
86
85
|
<FieldHelperText includeDescription={includeDescription}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
showError={showError}
|
|
87
|
+
error={error}
|
|
88
|
+
disabled={disabled}
|
|
89
|
+
property={property}/>
|
|
91
90
|
|
|
92
91
|
</>
|
|
93
92
|
);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
interface MapEditViewParams<T extends Record<string,
|
|
95
|
+
interface MapEditViewParams<T extends Record<string, unknown>> {
|
|
97
96
|
value?: T;
|
|
98
97
|
initialValue?: T;
|
|
99
98
|
setValue: (value: (T | null)) => void;
|
|
@@ -101,13 +100,13 @@ interface MapEditViewParams<T extends Record<string, any>> {
|
|
|
101
100
|
disabled?: boolean
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
function MapEditView<T extends Record<string,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}: MapEditViewParams<T>) {
|
|
103
|
+
function MapEditView<T extends Record<string, unknown>>({
|
|
104
|
+
value,
|
|
105
|
+
initialValue,
|
|
106
|
+
setValue,
|
|
107
|
+
fieldName,
|
|
108
|
+
disabled
|
|
109
|
+
}: MapEditViewParams<T>) {
|
|
111
110
|
const [internalState, setInternalState] = React.useState<MapEditViewRowState[]>(
|
|
112
111
|
Object.keys(initialValue ?? {}).map((key) => [getRandomId(), {
|
|
113
112
|
key,
|
|
@@ -158,105 +157,105 @@ function MapEditView<T extends Record<string, any>>({
|
|
|
158
157
|
return <div className="py-1 flex flex-col gap-1">
|
|
159
158
|
{internalState
|
|
160
159
|
.map(([rowId, {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
160
|
+
key: fieldKey,
|
|
161
|
+
type
|
|
162
|
+
}], index) => {
|
|
163
|
+
const entryValue = fieldKey ? value?.[fieldKey] : "";
|
|
164
|
+
const onFieldKeyChange = (newKey: string) => {
|
|
165
|
+
|
|
166
|
+
setInternalState(internalState.map((currentRowId) => {
|
|
167
|
+
if (currentRowId[0] === rowId) {
|
|
168
|
+
return [rowId, {
|
|
169
|
+
key: newKey ?? "",
|
|
170
|
+
type: currentRowId[1].type
|
|
171
|
+
}];
|
|
172
|
+
}
|
|
173
|
+
return currentRowId;
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
if (typeof value === "object" && newKey in value) {
|
|
177
|
+
// if the key is already there, don't delete the previous value
|
|
178
|
+
return;
|
|
173
179
|
}
|
|
174
|
-
return currentRowId;
|
|
175
|
-
}));
|
|
176
|
-
|
|
177
|
-
if (typeof value === "object" && newKey in value) {
|
|
178
|
-
// if the key is already there, don't delete the previous value
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} else {
|
|
186
|
-
delete (newValue as Record<string, unknown>)[fieldKey];
|
|
187
|
-
}
|
|
188
|
-
setValue({
|
|
189
|
-
...newValue,
|
|
190
|
-
[newKey ?? ""]: entryValue
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
return <MapKeyValueRow rowId={rowId}
|
|
194
|
-
key={rowId}
|
|
195
|
-
fieldKey={fieldKey}
|
|
196
|
-
value={value ?? {} as T}
|
|
197
|
-
onDeleteClick={() => {
|
|
198
|
-
const newValue = { ...(value ?? {}) as T };
|
|
199
|
-
if (initialValue && fieldKey in initialValue) {
|
|
200
|
-
(newValue as Record<string, unknown>)[fieldKey] = undefined;
|
|
181
|
+
const newValue = { ...(value ?? {}) } as T;
|
|
182
|
+
if (typeof initialValue === "object" && fieldKey in initialValue) {
|
|
183
|
+
(newValue as Record<string, unknown>)[fieldKey] = undefined; // set to undefined to remove from the object, the driver will remove it from the backend
|
|
201
184
|
} else {
|
|
202
185
|
delete (newValue as Record<string, unknown>)[fieldKey];
|
|
203
186
|
}
|
|
204
|
-
setInternalState(internalState.filter((currentRowId) => currentRowId[0] !== rowId));
|
|
205
187
|
setValue({
|
|
206
|
-
...newValue
|
|
188
|
+
...newValue,
|
|
189
|
+
[newKey ?? ""]: entryValue
|
|
207
190
|
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
191
|
+
};
|
|
192
|
+
return <MapKeyValueRow rowId={rowId}
|
|
193
|
+
key={rowId}
|
|
194
|
+
fieldKey={fieldKey}
|
|
195
|
+
value={value ?? {} as T}
|
|
196
|
+
onDeleteClick={() => {
|
|
197
|
+
const newValue = { ...(value ?? {}) as T };
|
|
198
|
+
if (initialValue && fieldKey in initialValue) {
|
|
199
|
+
(newValue as Record<string, unknown>)[fieldKey] = undefined;
|
|
200
|
+
} else {
|
|
201
|
+
delete (newValue as Record<string, unknown>)[fieldKey];
|
|
202
|
+
}
|
|
203
|
+
setInternalState(internalState.filter((currentRowId) => currentRowId[0] !== rowId));
|
|
204
|
+
setValue({
|
|
205
|
+
...newValue
|
|
206
|
+
});
|
|
207
|
+
}}
|
|
208
|
+
onFieldKeyChange={onFieldKeyChange}
|
|
209
|
+
setValue={setValue}
|
|
210
|
+
entryValue={entryValue}
|
|
211
|
+
type={type}
|
|
212
|
+
disabled={disabled}
|
|
213
|
+
updatetype={updatetype}/>;
|
|
214
|
+
}
|
|
216
215
|
)}
|
|
217
216
|
|
|
218
217
|
<Button variant={"text"}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
218
|
+
size={"small"}
|
|
219
|
+
className="w-full"
|
|
220
|
+
disabled={disabled}
|
|
221
|
+
startIcon={<PlusIcon/>}
|
|
222
|
+
onClick={(e) => {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
setValue({
|
|
225
|
+
...(value ?? {} as T),
|
|
226
|
+
"": null
|
|
227
|
+
});
|
|
228
|
+
setInternalState([...internalState, [getRandomId(), {
|
|
229
|
+
key: "",
|
|
230
|
+
type: "string"
|
|
231
|
+
}]]);
|
|
232
|
+
}
|
|
233
|
+
}>
|
|
235
234
|
{fieldName ? t("add_to_field", { fieldName }) : t("add")}
|
|
236
235
|
</Button>
|
|
237
236
|
|
|
238
237
|
</div>;
|
|
239
238
|
}
|
|
240
239
|
|
|
241
|
-
function MapKeyValueRow<T extends Record<string,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}: {
|
|
240
|
+
function MapKeyValueRow<T extends Record<string, unknown>>({
|
|
241
|
+
rowId,
|
|
242
|
+
fieldKey,
|
|
243
|
+
value,
|
|
244
|
+
onFieldKeyChange,
|
|
245
|
+
onDeleteClick,
|
|
246
|
+
setValue,
|
|
247
|
+
entryValue,
|
|
248
|
+
type,
|
|
249
|
+
updatetype,
|
|
250
|
+
disabled
|
|
251
|
+
}: {
|
|
253
252
|
rowId: number,
|
|
254
253
|
fieldKey: string,
|
|
255
254
|
value: T,
|
|
256
255
|
onFieldKeyChange: (newKey: string) => void,
|
|
257
256
|
onDeleteClick: () => void,
|
|
258
257
|
setValue: (value: (T | null)) => void,
|
|
259
|
-
entryValue:
|
|
258
|
+
entryValue: unknown,
|
|
260
259
|
type: DataType,
|
|
261
260
|
disabled?: boolean,
|
|
262
261
|
updatetype: (rowId: number, type: DataType) => void
|
|
@@ -265,12 +264,12 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
265
264
|
const { locale } = useCustomizationController();
|
|
266
265
|
const { t } = useTranslation();
|
|
267
266
|
|
|
268
|
-
function buildInput(entryValue:
|
|
267
|
+
function buildInput(entryValue: unknown, fieldKey: string, type: DataType) {
|
|
269
268
|
if (type === "string" || type === "number") {
|
|
270
269
|
return <TextField
|
|
271
270
|
key={type}
|
|
272
271
|
placeholder={"value"}
|
|
273
|
-
value={entryValue}
|
|
272
|
+
value={entryValue as string | number | undefined}
|
|
274
273
|
type={type === "number" ? "number" : "text"}
|
|
275
274
|
size={"medium"}
|
|
276
275
|
disabled={disabled || !fieldKey}
|
|
@@ -301,74 +300,75 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
301
300
|
}
|
|
302
301
|
}}/>;
|
|
303
302
|
} else if (type === "date") {
|
|
304
|
-
return <DateTimeField value={entryValue}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
303
|
+
return <DateTimeField value={entryValue as Date | null | undefined}
|
|
304
|
+
size={"medium"}
|
|
305
|
+
locale={locale}
|
|
306
|
+
disabled={disabled || !fieldKey}
|
|
307
|
+
onChange={(date) => {
|
|
308
|
+
setValue({
|
|
309
|
+
...value,
|
|
310
|
+
[fieldKey]: date
|
|
311
|
+
});
|
|
312
|
+
}}/>;
|
|
314
313
|
} else if (type === "boolean") {
|
|
315
|
-
return <BooleanSwitchWithLabel value={entryValue}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
314
|
+
return <BooleanSwitchWithLabel value={entryValue as boolean | null}
|
|
315
|
+
size={"medium"}
|
|
316
|
+
position={"start"}
|
|
317
|
+
disabled={disabled || !fieldKey}
|
|
318
|
+
onValueChange={(newValue) => {
|
|
319
|
+
setValue({
|
|
320
|
+
...value,
|
|
321
|
+
[fieldKey]: newValue
|
|
322
|
+
});
|
|
323
|
+
}}/>;
|
|
325
324
|
} else if (type === "array") {
|
|
325
|
+
const arrayValue = (entryValue as string[]) || [];
|
|
326
326
|
return <div
|
|
327
327
|
className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
328
|
-
<ArrayContainer value={
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
328
|
+
<ArrayContainer value={arrayValue}
|
|
329
|
+
newDefaultEntry={""}
|
|
330
|
+
droppableId={rowId.toString()}
|
|
331
|
+
addLabel={fieldKey ? t("add_to_field", { fieldName: fieldKey }) : t("add")}
|
|
332
|
+
size={"small"}
|
|
333
|
+
disabled={disabled || !fieldKey}
|
|
334
|
+
canAddElements={true}
|
|
335
|
+
onValueChange={(newValue) => {
|
|
336
|
+
setValue({
|
|
337
|
+
...value,
|
|
338
|
+
[fieldKey]: newValue
|
|
339
|
+
});
|
|
340
|
+
}}
|
|
341
|
+
buildEntry={({
|
|
342
|
+
index,
|
|
343
|
+
internalId
|
|
344
|
+
}) => {
|
|
345
|
+
return <ArrayKeyValueRow
|
|
346
|
+
index={index}
|
|
347
|
+
id={internalId}
|
|
348
|
+
value={arrayValue[index]}
|
|
349
|
+
disabled={disabled || !fieldKey}
|
|
350
|
+
setValue={(newValue) => {
|
|
351
|
+
const newArrayValue = [...arrayValue] as any[];
|
|
352
|
+
newArrayValue[index] = newValue;
|
|
353
|
+
setValue({
|
|
354
|
+
...value,
|
|
355
|
+
[fieldKey]: newArrayValue
|
|
356
|
+
});
|
|
357
|
+
}}
|
|
358
|
+
/>
|
|
359
|
+
}}/>
|
|
360
360
|
</div>;
|
|
361
361
|
} else if (type === "map") {
|
|
362
362
|
return <div
|
|
363
363
|
className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
364
|
-
<MapEditView value={entryValue}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
364
|
+
<MapEditView value={entryValue as Record<string, unknown> | undefined}
|
|
365
|
+
fieldName={fieldKey}
|
|
366
|
+
setValue={(updatedValue) => {
|
|
367
|
+
setValue({
|
|
368
|
+
...value,
|
|
369
|
+
[fieldKey]: updatedValue
|
|
370
|
+
});
|
|
371
|
+
}}/>
|
|
372
372
|
</div>;
|
|
373
373
|
} else {
|
|
374
374
|
return <Typography
|
|
@@ -383,64 +383,64 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
return (<>
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
386
|
+
<Typography key={rowId.toString()}
|
|
387
|
+
component={"div"}
|
|
388
|
+
className="font-mono flex flex-row gap-1">
|
|
389
|
+
<div className="w-[300px] max-w-[30%]">
|
|
390
|
+
<TextField
|
|
391
|
+
value={fieldKey}
|
|
392
|
+
placeholder={"key"}
|
|
393
|
+
disabled={disabled || (entryValue !== undefined && entryValue !== null && entryValue !== "")}
|
|
394
|
+
size={"medium"}
|
|
395
|
+
onChange={(event) => {
|
|
396
|
+
onFieldKeyChange(event.target.value);
|
|
397
|
+
}}/>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<div className="grow">
|
|
401
|
+
{(type !== "map" && type !== "array") && buildInput(entryValue, fieldKey, type)}
|
|
402
|
+
</div>
|
|
403
|
+
<div className={"flex flex-col"}>
|
|
404
|
+
<Menu
|
|
405
|
+
trigger={<IconButton size={"smallest"}>
|
|
406
|
+
<ChevronDownIcon size={iconSize.small}/>
|
|
407
|
+
</IconButton>}
|
|
408
|
+
>
|
|
409
|
+
<MenuItem dense
|
|
410
|
+
onClick={() => doUpdatetype("string")}>string</MenuItem>
|
|
411
|
+
<MenuItem dense
|
|
412
|
+
onClick={() => doUpdatetype("number")}>number</MenuItem>
|
|
413
|
+
<MenuItem dense
|
|
414
|
+
onClick={() => doUpdatetype("boolean")}>boolean</MenuItem>
|
|
415
|
+
<MenuItem dense
|
|
416
|
+
onClick={() => doUpdatetype("date")}>date</MenuItem>
|
|
417
|
+
<MenuItem dense
|
|
418
|
+
onClick={() => doUpdatetype("map")}>map</MenuItem>
|
|
419
|
+
<MenuItem dense
|
|
420
|
+
onClick={() => doUpdatetype("array")}>array</MenuItem>
|
|
421
|
+
</Menu>
|
|
422
|
+
|
|
423
|
+
<IconButton aria-label="delete"
|
|
424
|
+
size={"smallest"}
|
|
425
|
+
onClick={onDeleteClick}>
|
|
426
|
+
<MinusIcon size={iconSize.smallest}/>
|
|
427
|
+
</IconButton>
|
|
428
|
+
</div>
|
|
429
|
+
</Typography>
|
|
430
|
+
|
|
431
|
+
{(type === "map" || type === "array") && buildInput(entryValue, fieldKey, type)}
|
|
432
432
|
|
|
433
|
-
|
|
433
|
+
</>
|
|
434
434
|
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
function ArrayKeyValueRow<T>({
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}: {
|
|
439
|
+
id,
|
|
440
|
+
index,
|
|
441
|
+
value,
|
|
442
|
+
setValue
|
|
443
|
+
}: {
|
|
444
444
|
id: number,
|
|
445
445
|
index: number,
|
|
446
446
|
value: T,
|
|
@@ -455,49 +455,50 @@ function ArrayKeyValueRow<T>({
|
|
|
455
455
|
setSelectedtype(type);
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
function buildInput(entryValue:
|
|
458
|
+
function buildInput(entryValue: unknown, type: DataType) {
|
|
459
459
|
if (type === "string" || type === "number") {
|
|
460
|
-
return <TextField value={entryValue}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
460
|
+
return <TextField value={entryValue as string | number | undefined}
|
|
461
|
+
type={type === "number" ? "number" : "text"}
|
|
462
|
+
size={"medium"}
|
|
463
|
+
onChange={(event) => {
|
|
464
|
+
if (type === "number") {
|
|
465
|
+
const numberValue = event.target.value ? parseFloat(event.target.value) : undefined;
|
|
466
|
+
if (numberValue && isNaN(numberValue)) {
|
|
467
|
+
setValue(null);
|
|
468
|
+
} else if (numberValue !== undefined && numberValue !== null) {
|
|
469
|
+
setValue(numberValue as T);
|
|
470
|
+
} else {
|
|
471
|
+
setValue(null);
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
setValue(event.target.value as T);
|
|
475
|
+
}
|
|
476
|
+
}}/>;
|
|
477
477
|
} else if (type === "date") {
|
|
478
|
-
return <DateTimeField value={entryValue}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
478
|
+
return <DateTimeField value={entryValue as Date | null | undefined}
|
|
479
|
+
size={"medium"}
|
|
480
|
+
locale={locale}
|
|
481
|
+
onChange={(date) => {
|
|
482
|
+
setValue(date as T);
|
|
483
|
+
}}/>;
|
|
484
484
|
} else if (type === "boolean") {
|
|
485
|
-
return <BooleanSwitchWithLabel value={entryValue}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
485
|
+
return <BooleanSwitchWithLabel value={entryValue as boolean | null}
|
|
486
|
+
size={"small"}
|
|
487
|
+
position={"start"}
|
|
488
|
+
onValueChange={(v) => {
|
|
489
|
+
setValue(v as T);
|
|
490
|
+
}}/>;
|
|
491
491
|
} else if (type === "array") {
|
|
492
492
|
return <Typography variant={"caption"}>
|
|
493
493
|
Arrays of arrays are not supported.
|
|
494
494
|
</Typography>;
|
|
495
495
|
} else if (type === "map") {
|
|
496
|
+
const mapValue = (entryValue && typeof entryValue === "object") ? (entryValue as Record<string, unknown>) : undefined;
|
|
496
497
|
return <div className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
|
|
497
|
-
<MapEditView value={
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
<MapEditView value={mapValue}
|
|
499
|
+
setValue={(updatedValue) => {
|
|
500
|
+
setValue(updatedValue as T | null);
|
|
501
|
+
}}/>
|
|
501
502
|
</div>;
|
|
502
503
|
} else {
|
|
503
504
|
return <Typography
|
|
@@ -508,36 +509,36 @@ function ArrayKeyValueRow<T>({
|
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
return (<>
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
512
|
+
<Typography key={id.toString()}
|
|
513
|
+
component={"div"}
|
|
514
|
+
className="font-mono flex min-h-12 flex-row gap-1 items-center">
|
|
515
|
+
|
|
516
|
+
<div className="grow">
|
|
517
|
+
{selectedtype !== "map" && buildInput(value, selectedtype)}
|
|
518
|
+
</div>
|
|
519
|
+
|
|
520
|
+
<Menu
|
|
521
|
+
trigger={<IconButton size={"small"}
|
|
522
|
+
className="h-7 w-7">
|
|
523
|
+
<ChevronDownIcon/>
|
|
524
|
+
</IconButton>}>
|
|
525
|
+
<MenuItem dense
|
|
526
|
+
onClick={() => doUpdatetype("string")}>string</MenuItem>
|
|
527
|
+
<MenuItem dense
|
|
528
|
+
onClick={() => doUpdatetype("number")}>number</MenuItem>
|
|
529
|
+
<MenuItem dense
|
|
530
|
+
onClick={() => doUpdatetype("boolean")}>boolean</MenuItem>
|
|
531
|
+
<MenuItem dense
|
|
532
|
+
onClick={() => doUpdatetype("map")}>map</MenuItem>
|
|
533
|
+
<MenuItem dense
|
|
534
|
+
onClick={() => doUpdatetype("date")}>date</MenuItem>
|
|
535
|
+
</Menu>
|
|
536
|
+
|
|
537
|
+
</Typography>
|
|
538
|
+
|
|
539
|
+
{selectedtype === "map" && buildInput(value, selectedtype)}
|
|
540
|
+
|
|
541
|
+
</>
|
|
541
542
|
|
|
542
543
|
);
|
|
543
544
|
}
|
|
@@ -546,7 +547,7 @@ function getRandomId() {
|
|
|
546
547
|
return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER));
|
|
547
548
|
}
|
|
548
549
|
|
|
549
|
-
function gettype(value:
|
|
550
|
+
function gettype(value: unknown): DataType | undefined {
|
|
550
551
|
if (typeof value === "string" || value === null) {
|
|
551
552
|
return "string";
|
|
552
553
|
} else if (typeof value === "number") {
|
|
@@ -557,7 +558,7 @@ function gettype(value: any): DataType | undefined {
|
|
|
557
558
|
return "array";
|
|
558
559
|
} else if (value instanceof Date) {
|
|
559
560
|
return "date";
|
|
560
|
-
} else if (value
|
|
561
|
+
} else if (value && typeof value === "object" && "isEntityReference" in value && typeof (value as Record<string, unknown>).isEntityReference === "function" && (value as Record<string, (...args: unknown[]) => unknown>).isEntityReference()) {
|
|
561
562
|
return "reference";
|
|
562
563
|
} else if (value instanceof GeoPoint) {
|
|
563
564
|
return "geopoint";
|