unpack props inside component bodies

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-02-27 15:31:15 +01:00
parent babbaa9391
commit 65454876fb
51 changed files with 253 additions and 297 deletions
@@ -38,16 +38,17 @@ export type HighlightedSearchResultTextProps = {
/**
* @public
*/
export const HighlightedSearchResultText = ({
text,
preTag,
postTag,
}: HighlightedSearchResultTextProps) => {
export const HighlightedSearchResultText = (
props: HighlightedSearchResultTextProps,
) => {
const { text, preTag, postTag } = props;
const classes = useStyles();
const terms = useMemo(
() => text.split(new RegExp(`(${preTag}.+?${postTag})`)),
[postTag, preTag, text],
);
return (
<>
{terms.map((t, idx) =>
@@ -40,22 +40,28 @@ export type SearchAutocompleteDefaultOptionProps = {
*
* @public
*/
export const SearchAutocompleteDefaultOption = ({
icon,
primaryText,
primaryTextTypographyProps,
secondaryText,
secondaryTextTypographyProps,
disableTextTypography,
}: SearchAutocompleteDefaultOptionProps) => (
<>
{icon ? <ListItemIcon>{icon}</ListItemIcon> : null}
<ListItemText
primary={primaryText}
primaryTypographyProps={primaryTextTypographyProps}
secondary={secondaryText}
secondaryTypographyProps={secondaryTextTypographyProps}
disableTypography={disableTextTypography}
/>
</>
);
export const SearchAutocompleteDefaultOption = (
props: SearchAutocompleteDefaultOptionProps,
) => {
const {
icon,
primaryText,
primaryTextTypographyProps,
secondaryText,
secondaryTextTypographyProps,
disableTextTypography,
} = props;
return (
<>
{icon ? <ListItemIcon>{icon}</ListItemIcon> : null}
<ListItemText
primary={primaryText}
primaryTypographyProps={primaryTextTypographyProps}
secondary={secondaryText}
secondaryTypographyProps={secondaryTextTypographyProps}
disableTypography={disableTextTypography}
/>
</>
);
};
@@ -208,10 +208,10 @@ export const SelectFilter = (props: SearchFilterComponentProps) => {
/**
* @public
*/
const SearchFilter = ({
component: Element,
...props
}: SearchFilterWrapperProps) => <Element {...props} />;
const SearchFilter = (props: SearchFilterWrapperProps) => {
const { component: Element, ...elementProps } = props;
return <Element {...elementProps} />;
};
SearchFilter.Checkbox = (
props: Omit<SearchFilterWrapperProps, 'component'> &