mirror of
https://github.com/apache/superset.git
synced 2026-04-24 02:25:13 +00:00
feat: Adds a helper text option to the Select component (#21269)
Co-authored-by: Geido <60598000+geido@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
60db0bb47e
commit
fbe980779e
@@ -102,6 +102,11 @@ export interface AsyncSelectProps extends PickedSelectProps {
|
||||
* Can be any ReactNode.
|
||||
*/
|
||||
header?: ReactNode;
|
||||
/**
|
||||
* It adds a helper text on top of the Select options
|
||||
* with additional context to help with the interaction.
|
||||
*/
|
||||
helperText?: string;
|
||||
/**
|
||||
* It fires a request against the server after
|
||||
* the first interaction and not on render.
|
||||
@@ -182,6 +187,9 @@ const StyledSelect = styled(AntdSelect)`
|
||||
.ant-select-arrow .anticon:not(.ant-select-suffix) {
|
||||
pointer-events: none;
|
||||
}
|
||||
.ant-select-dropdown {
|
||||
padding: 0;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -224,6 +232,16 @@ const StyledLoadingText = styled.div`
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledHelperText = styled.div`
|
||||
${({ theme }) => `
|
||||
padding: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px;
|
||||
color: ${theme.colors.grayscale.base};
|
||||
font-size: ${theme.typography.sizes.s}px;
|
||||
cursor: default;
|
||||
border-bottom: 1px solid ${theme.colors.grayscale.light2};
|
||||
`}
|
||||
`;
|
||||
|
||||
const MAX_TAG_COUNT = 4;
|
||||
const TOKEN_SEPARATORS = [',', '\n', '\t', ';'];
|
||||
const DEFAULT_PAGE_SIZE = 100;
|
||||
@@ -297,6 +315,7 @@ const AsyncSelect = forwardRef(
|
||||
fetchOnlyOnSearch,
|
||||
filterOption = true,
|
||||
header = null,
|
||||
helperText,
|
||||
invertSelection = false,
|
||||
lazyLoading = true,
|
||||
loading,
|
||||
@@ -612,7 +631,16 @@ const AsyncSelect = forwardRef(
|
||||
if (isLoading && fullSelectOptions.length === 0) {
|
||||
return <StyledLoadingText>{t('Loading...')}</StyledLoadingText>;
|
||||
}
|
||||
return error ? <Error error={error} /> : originNode;
|
||||
return error ? (
|
||||
<Error error={error} />
|
||||
) : (
|
||||
<>
|
||||
{helperText && (
|
||||
<StyledHelperText role="note">{helperText}</StyledHelperText>
|
||||
)}
|
||||
{originNode}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// use a function instead of component since every rerender of the
|
||||
|
||||
Reference in New Issue
Block a user