fixed up service editor
This commit is contained in:
1 parent
029df7932e
commit
5bef962977
8 files changed
+107
-44
No files matched your search
@@ -38,4 +38,9 @@
|
||||
max-width: 7em;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.input-autocomplete--popper {
|
||||
min-width: fit-content;
|
||||
/* max-width: 90vw; */
|
||||
}
|
||||
@@ -2,10 +2,11 @@ import "./InputAutoComplete.css";
|
||||
import Autocomplete from "@mui/material/Autocomplete";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { Badge } from "@mui/material";
|
||||
import { Badge, Popper } from "@mui/material";
|
||||
import { SearchItem } from "./extras";
|
||||
import { ReactNode } from "react";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { ModalStyleProps } from "../Modal/index";
|
||||
|
||||
export type BaseOption<T = {}> = {
|
||||
id: string;
|
||||
@@ -142,6 +143,16 @@ export function InputAutoComplete<T extends Option>(
|
||||
options={options}
|
||||
onChange={onChange}
|
||||
getOptionLabel={getLabel as any}
|
||||
PopperComponent={(props) => {
|
||||
return (
|
||||
<Popper
|
||||
{...props}
|
||||
className={[props.className, "input-autocomplete--popper"].join(
|
||||
" "
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
filterOptions={(opts, s) => {
|
||||
const searchTerm = s.inputValue;
|
||||
if (!searchTerm) {
|
||||
|
||||
@@ -4,25 +4,33 @@ import { Page } from "components/Page";
|
||||
import { SearchItem } from "./extras";
|
||||
|
||||
export default {
|
||||
title: 'Inputs/Extras/SearchItem',
|
||||
title: "Inputs/Extras/SearchItem",
|
||||
component: SearchItem,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
argTypes: {}
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
argTypes: {},
|
||||
} as ComponentMeta<typeof SearchItem>;
|
||||
|
||||
const Template: ComponentStory<typeof SearchItem> = (args) => {
|
||||
return (
|
||||
<Page>
|
||||
<div
|
||||
style={{
|
||||
width: "15em",
|
||||
height: "3em",
|
||||
border: "1px solid var(--primary-accent)",
|
||||
}}
|
||||
>
|
||||
<SearchItem {...args} />
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof SearchItem> = args => {
|
||||
return <Page>
|
||||
<SearchItem {...args} />
|
||||
</Page>
|
||||
|
||||
}
|
||||
|
||||
export const Simple = Template.bind({})
|
||||
export const Simple = Template.bind({});
|
||||
Simple.args = {
|
||||
id: "sensor.humidity_main_bedroom",
|
||||
label: 'Main Bedroom Humidity',
|
||||
label: "Main Bedroom Humidity",
|
||||
searchTerm: "bedroom",
|
||||
listProps: {},
|
||||
} as any
|
||||
onlyShowLabel: false,
|
||||
};
|
||||
@@ -1,9 +1,42 @@
|
||||
.input-extras--search-item--list {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 0.15em;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
|
||||
justify-content: center;
|
||||
align-items: flex-start !important;
|
||||
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
min-height: 2em;
|
||||
max-height: 100%;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: 20em;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.input-extras--search-item--list>small::before {
|
||||
.input-extras--search-item--list small {
|
||||
/* max-height: 2em; */
|
||||
max-width: 100%;
|
||||
width: fit-content;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.input-extras--search-item--list b {
|
||||
max-height: 1.5em;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
padding-right: 0.25em;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* .input-extras--search-item--list>small::before {
|
||||
content: "/ ";
|
||||
}
|
||||
} */
|
||||
@@ -36,34 +36,29 @@ export const SearchItem: FC<{
|
||||
searchTerm: string;
|
||||
onlyShowLabel?: boolean;
|
||||
}> = ({ listProps, label, id, searchTerm, onlyShowLabel = false }) => {
|
||||
const labelElm = (
|
||||
<b className="input-extras--search-item--list--label">
|
||||
<HighlightElm text={label} searchTerm={searchTerm} />
|
||||
</b>
|
||||
);
|
||||
const idElm = (
|
||||
<small className="input-extras--search-item--list--id">
|
||||
<HighlightElm text={id} searchTerm={searchTerm} />
|
||||
</small>
|
||||
);
|
||||
|
||||
let inner = (
|
||||
<>
|
||||
<b>
|
||||
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
|
||||
</b>{" "}
|
||||
<small>
|
||||
<HighlightElm text={id} searchTerm={searchTerm} />
|
||||
</small>
|
||||
{labelElm}
|
||||
{idElm}
|
||||
</>
|
||||
);
|
||||
|
||||
if (onlyShowLabel) {
|
||||
if (label) {
|
||||
inner = (
|
||||
<>
|
||||
<b>
|
||||
<HighlightElm text={prettyName(label)} searchTerm={searchTerm} />
|
||||
</b>{" "}
|
||||
</>
|
||||
);
|
||||
inner = labelElm;
|
||||
} else {
|
||||
inner = (
|
||||
<>
|
||||
<small>
|
||||
<HighlightElm text={id} searchTerm={searchTerm} />
|
||||
</small>
|
||||
</>
|
||||
);
|
||||
inner = idElm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user