2024-06-21 02:10:21 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { NoFormStyle } from '../form/context';
|
|
|
|
import { NoCompactStyle } from '../space/Compact';
|
|
|
|
|
|
|
|
const ContextIsolator: React.FC<
|
2024-06-22 21:59:12 +08:00
|
|
|
Readonly<React.PropsWithChildren<Partial<Record<'space' | 'form', boolean>>>>
|
2024-06-21 02:10:21 +08:00
|
|
|
> = (props) => {
|
2024-06-22 21:59:12 +08:00
|
|
|
const { space, form, children } = props;
|
2024-06-21 02:10:21 +08:00
|
|
|
if (children === undefined || children === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
let result: React.ReactNode = children;
|
2024-06-22 21:59:12 +08:00
|
|
|
if (form) {
|
2024-06-21 02:10:21 +08:00
|
|
|
result = (
|
|
|
|
<NoFormStyle override status>
|
|
|
|
{result}
|
|
|
|
</NoFormStyle>
|
|
|
|
);
|
|
|
|
}
|
2024-06-22 21:59:12 +08:00
|
|
|
if (space) {
|
2024-06-21 02:10:21 +08:00
|
|
|
result = <NoCompactStyle>{result}</NoCompactStyle>;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ContextIsolator;
|