mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
error and description state
This commit is contained in:
parent
24d0f3b9c5
commit
f766df3ee0
@ -16,7 +16,6 @@ const getSelectStyles = (theme, error) => {
|
|||||||
boxShadowColor = theme.colors.primary600;
|
boxShadowColor = theme.colors.primary600;
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
borderColor = theme.colors.danger600;
|
borderColor = theme.colors.danger600;
|
||||||
boxShadowColor = theme.colors.danger600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.isDisabled) {
|
if (state.isDisabled) {
|
||||||
|
@ -5,7 +5,7 @@ import { Badge } from '@strapi/design-system/Badge';
|
|||||||
import { Box } from '@strapi/design-system/Box';
|
import { Box } from '@strapi/design-system/Box';
|
||||||
import { BaseLink } from '@strapi/design-system/BaseLink';
|
import { BaseLink } from '@strapi/design-system/BaseLink';
|
||||||
import { Icon } from '@strapi/design-system/Icon';
|
import { Icon } from '@strapi/design-system/Icon';
|
||||||
import { FieldLabel } from '@strapi/design-system/Field';
|
import { FieldLabel, FieldError, FieldHint, Field } from '@strapi/design-system/Field';
|
||||||
import { TextButton } from '@strapi/design-system/TextButton';
|
import { TextButton } from '@strapi/design-system/TextButton';
|
||||||
|
|
||||||
import Cross from '@strapi/icons/Cross';
|
import Cross from '@strapi/icons/Cross';
|
||||||
@ -18,6 +18,8 @@ import { RelationList } from './components/RelationList';
|
|||||||
import ReactSelect from '../ReactSelect';
|
import ReactSelect from '../ReactSelect';
|
||||||
|
|
||||||
export const RelationInput = ({
|
export const RelationInput = ({
|
||||||
|
description,
|
||||||
|
error,
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
@ -33,12 +35,13 @@ export const RelationInput = ({
|
|||||||
placeholder,
|
placeholder,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Field error={error} name={name} hint={description} id={id}>
|
||||||
<Relation
|
<Relation
|
||||||
search={
|
search={
|
||||||
<>
|
<>
|
||||||
<FieldLabel htmlFor={id}>{label}</FieldLabel>
|
<FieldLabel>{label}</FieldLabel>
|
||||||
<ReactSelect
|
<ReactSelect
|
||||||
|
error={error}
|
||||||
inputId={id}
|
inputId={id}
|
||||||
isSearchable
|
isSearchable
|
||||||
isClear
|
isClear
|
||||||
@ -86,8 +89,12 @@ export const RelationInput = ({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</RelationList>
|
</RelationList>
|
||||||
</Relation>
|
<Box paddingTop={2}>
|
||||||
|
<FieldHint />
|
||||||
|
<FieldError />
|
||||||
</Box>
|
</Box>
|
||||||
|
</Relation>
|
||||||
|
</Field>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -123,9 +130,7 @@ RelationInput.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
RelationInput.propTypes = {
|
RelationInput.propTypes = {
|
||||||
// eslint-disable-next-line react/no-unused-prop-types
|
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
// eslint-disable-next-line react/no-unused-prop-types
|
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
// eslint-disable-next-line react/no-unused-prop-types
|
// eslint-disable-next-line react/no-unused-prop-types
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
@ -3,6 +3,7 @@ import React from 'react';
|
|||||||
|
|
||||||
import { Stack } from '@strapi/design-system/Stack';
|
import { Stack } from '@strapi/design-system/Stack';
|
||||||
import { Flex } from '@strapi/design-system/Flex';
|
import { Flex } from '@strapi/design-system/Flex';
|
||||||
|
import { Box } from '@strapi/design-system/Box';
|
||||||
|
|
||||||
export const Relation = ({ children, loadMore, search, ...props }) => {
|
export const Relation = ({ children, loadMore, search, ...props }) => {
|
||||||
return (
|
return (
|
||||||
@ -21,8 +22,7 @@ export const Relation = ({ children, loadMore, search, ...props }) => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
{loadMore}
|
{loadMore}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Box>{children}</Box>
|
||||||
{children}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user