@@ -44,62 +68,44 @@ const DynamicDocumentRoot = observer((props: Props) => {
return (
{edit ? (
-
setTitle(t)}
placeholder="Dynamische Document Root"
- onChange={(e) => {
- setTitle(e.target.value);
+ onEnter={() => {
+ meta.setName(title);
+ setEdit(false);
}}
- autoFocus
- className={clsx(styles.roomName)}
- onKeyDown={(e) => {
- const save = e.key === 'Enter' || ((e.ctrlKey || e.metaKey) && e.key === 's');
- if (save) {
- meta.setName(title);
- setEdit(false);
- e.preventDefault();
- e.stopPropagation();
- }
- if (e.key === 'Escape') {
- setEdit(false);
- }
+ onEscape={() => {
+ setEdit(false);
+ }}
+ onSave={() => {
+ meta.setName(title);
+ setEdit(false);
}}
/>
) : (
{meta.name}
)}
- {edit ? (
-
- ) : (
+ {!edit && (
{meta.roomType ? (componentStore.components.get(meta.roomType)?.name ?? '-') : '-'}
)}
-
+ {!edit && (
+
+ )}
{meta.parentRoot?.hasRWAccess && (
<>
-
diff --git a/src/components/shared/Button/index.tsx b/src/components/shared/Button/index.tsx
index 992432739..d46df96ee 100644
--- a/src/components/shared/Button/index.tsx
+++ b/src/components/shared/Button/index.tsx
@@ -20,6 +20,7 @@ export const POPUP_BUTTON_STYLE = clsx(
export interface Base {
onClick?: MouseEventHandler
;
onMouseDown?: MouseEventHandler;
+ onMouseUp?: MouseEventHandler;
title?: string;
href?: string;
target?: '_blank' | `_self`;
@@ -163,6 +164,7 @@ const Button = (props: Props) => {
disabled={props.disabled}
title={props.title}
onMouseDown={props.onMouseDown}
+ onMouseUp={props.onMouseUp}
>
{props.floatingIcon && {props.floatingIcon}}
diff --git a/src/components/shared/SelectInput/index.tsx b/src/components/shared/SelectInput/index.tsx
index cdfed749b..949c59351 100644
--- a/src/components/shared/SelectInput/index.tsx
+++ b/src/components/shared/SelectInput/index.tsx
@@ -3,23 +3,47 @@ import styles from './styles.module.scss';
import { observer } from 'mobx-react-lite';
import clsx from 'clsx';
-interface Props {
+interface Option {
+ value: string;
+ label?: string;
+ disabled?: boolean;
+}
+
+interface BaseProps {
defaultValue?: string;
placeholder?: string;
- /**
- * provide the labels in the same order as the options
- * to display them in the dropdown
- */
- labels?: string[];
onChange: (text: string) => void;
- options: string[];
value: string;
disabled?: boolean;
className?: string;
}
+interface SimpleProps extends BaseProps {
+ labels?: string[];
+ options: string[];
+}
+
+interface CustomizableProps extends BaseProps {
+ labels?: never[];
+ options: Option[];
+}
+
+type Props = SimpleProps | CustomizableProps;
+
const SelectInput = observer((props: Props) => {
- const { options, onChange, value } = props;
+ const { onChange, value } = props;
+ const options = React.useMemo