+ added bubble editor
+ initial numeric editor + entity id input
This commit is contained in:
1 parent
6be9f1ba12
commit
60ec7c3f29
7 files changed
+237
-8
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { FC, useState } from "react";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputText from "./InputText";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputBubblesStyles, useInputTextStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
textBoxFor?: string;
|
||||
value: string | string[];
|
||||
onChange: (v: string[]) => void;
|
||||
additionalTooltipFilters?: Record<string, string>;
|
||||
}
|
||||
export default function InputTextBubble({
|
||||
value="",
|
||||
label,
|
||||
textBoxFor,
|
||||
onChange,
|
||||
additionalTooltipFilters={},
|
||||
}: Props) {
|
||||
const {classes} = useInputBubblesStyles({});
|
||||
let selected: string[];
|
||||
if (typeof value === 'string') {
|
||||
selected = [value]
|
||||
} else {
|
||||
selected = value
|
||||
}
|
||||
const [text, setText] = useState('');
|
||||
const addNew = () => {
|
||||
if(text) {
|
||||
onChange([text].concat(selected))
|
||||
setText("")
|
||||
}
|
||||
};
|
||||
|
||||
return <InputText
|
||||
label={label}
|
||||
value={text}
|
||||
textBoxFor={textBoxFor}
|
||||
onChange={t => setText(t)}
|
||||
onEnter={() => addNew()}
|
||||
additionalTooltipFilters={additionalTooltipFilters}
|
||||
>
|
||||
<div className={classes.bubbles}>
|
||||
{selected.map((s, i) => <div className={classes.bubble} onClick={() => onChange([
|
||||
...selected.slice(0, i),
|
||||
...selected.slice(i+1),
|
||||
])}>
|
||||
{s}
|
||||
<span className={classes.deleteIcon}>X</span>
|
||||
</div>)}
|
||||
</div>
|
||||
<button className={classes.addBtn} onClick={() => addNew()}>+</button>
|
||||
</InputText>
|
||||
}
|
||||
|
||||
export const InputEntity: FC<{
|
||||
value: string | string[];
|
||||
onChange: (v: string[]) => void;
|
||||
}> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => <InputTextBubble
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
label="Entity ID"
|
||||
textBoxFor="entity_id"
|
||||
/>
|
||||
Reference in new issue
Block a user