mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 16:16:20 +00:00
Merge pull request #14400 from strapi/relations/proptypes-fix
[RelationInput] fix proptypes
This commit is contained in:
commit
5710491285
@ -156,7 +156,7 @@ const RelationInput = ({
|
||||
inputId={id}
|
||||
isSearchable
|
||||
isClear
|
||||
loadingMessage={() => loadingMessage}
|
||||
loadingMessage={loadingMessage}
|
||||
onChange={(relation) => {
|
||||
setValue(null);
|
||||
onRelationAdd(relation);
|
||||
|
||||
@ -50,5 +50,5 @@ Relation.propTypes = {
|
||||
search: PropTypes.node,
|
||||
loadMore: PropTypes.node,
|
||||
size: PropTypes.number.isRequired,
|
||||
totalNumberOfRelations: PropTypes.string,
|
||||
totalNumberOfRelations: PropTypes.number,
|
||||
};
|
||||
|
||||
@ -19,34 +19,34 @@ const ShadowBox = styled(Box)`
|
||||
|
||||
&:before {
|
||||
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
||||
content: ${({ overflow }) =>
|
||||
overflow === 'top-bottom' || overflow === 'top' ? "''" : undefined};
|
||||
content: ${({ overflowDirection }) =>
|
||||
overflowDirection === 'top-bottom' || overflowDirection === 'top' ? "''" : undefined};
|
||||
background: linear-gradient(rgba(33, 33, 52, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
|
||||
top: 0;
|
||||
}
|
||||
|
||||
&:after {
|
||||
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
|
||||
content: ${({ overflow }) =>
|
||||
overflow === 'top-bottom' || overflow === 'bottom' ? "''" : undefined};
|
||||
content: ${({ overflowDirection }) =>
|
||||
overflowDirection === 'top-bottom' || overflowDirection === 'bottom' ? "''" : undefined};
|
||||
background: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(33, 33, 52, 0.1) 100%);
|
||||
bottom: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
export const RelationList = ({ children, ...props }) => {
|
||||
export const RelationList = ({ children, overflow, ...props }) => {
|
||||
return (
|
||||
<ShadowBox {...props}>
|
||||
<ShadowBox overflowDirection={overflow} {...props}>
|
||||
<Stack spacing={1}>{children}</Stack>
|
||||
</ShadowBox>
|
||||
);
|
||||
};
|
||||
|
||||
RelationList.defaultProps = {
|
||||
overflow: undefined,
|
||||
overflow: '',
|
||||
};
|
||||
|
||||
RelationList.propTypes = {
|
||||
children: PropTypes.node.isRequired,
|
||||
overflow: PropTypes.oneOf(['top-bottom', 'bottom', 'top']),
|
||||
overflow: PropTypes.oneOf(['top-bottom', 'bottom', 'top', '']),
|
||||
};
|
||||
|
||||
@ -18,7 +18,7 @@ const setup = (props) =>
|
||||
|
||||
describe('Content-Manager || RelationInput || Option', () => {
|
||||
it('should render custom Option with published state title', () => {
|
||||
setup({ options: [{ mainField: 'relation 1', publicationState: 'published' }] });
|
||||
setup({ options: [{ id: 1, mainField: 'relation 1', publicationState: 'published' }] });
|
||||
|
||||
act(() => {
|
||||
fireEvent.mouseDown(screen.getByRole('button'));
|
||||
@ -29,7 +29,7 @@ describe('Content-Manager || RelationInput || Option', () => {
|
||||
});
|
||||
|
||||
it('should render custom Option with draft state title', () => {
|
||||
setup({ options: [{ mainField: 'relation 1', publicationState: 'draft' }] });
|
||||
setup({ options: [{ id: 1, mainField: 'relation 1', publicationState: 'draft' }] });
|
||||
|
||||
act(() => {
|
||||
fireEvent.mouseDown(screen.getByRole('button'));
|
||||
|
||||
@ -63,7 +63,7 @@ const setup = (props) =>
|
||||
name="some-relation-1"
|
||||
label="Some Relation"
|
||||
labelLoadMore="Load more"
|
||||
loadingMessage="Relations are loading"
|
||||
loadingMessage={() => 'Relations are loading'}
|
||||
numberOfRelationsToDisplay={5}
|
||||
onRelationAdd={() => jest.fn()}
|
||||
onSearchOpen={() => jest.fn()}
|
||||
@ -79,6 +79,7 @@ const setup = (props) =>
|
||||
}}
|
||||
relations={FIXTURES_RELATIONS}
|
||||
searchResults={FIXTURES_SEARCH}
|
||||
size={8}
|
||||
{...props}
|
||||
/>
|
||||
</IntlProvider>
|
||||
|
||||
@ -584,7 +584,6 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] =
|
||||
>
|
||||
<div
|
||||
class="c16"
|
||||
overflow=""
|
||||
>
|
||||
<div
|
||||
class="c4 c5"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user