File size: 658 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React from 'react';

import { NoFormStyle } from '../form/context';
import { NoCompactStyle } from '../space/Compact';

const ContextIsolator: React.FC<
  Readonly<React.PropsWithChildren<Partial<Record<'space' | 'form', boolean>>>>
> = (props) => {
  const { space, form, children } = props;
  if (children === undefined || children === null) {
    return null;
  }
  let result: React.ReactNode = children;
  if (form) {
    result = (
      <NoFormStyle override status>
        {result}
      </NoFormStyle>
    );
  }
  if (space) {
    result = <NoCompactStyle>{result}</NoCompactStyle>;
  }
  return result;
};

export default ContextIsolator;