All files / src/section Row.tsx

73.33% Statements 11/15
33.33% Branches 3/9
50% Functions 1/2
78.57% Lines 11/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 29 30 31 32 33 34          22x           22x       22x 1136x 1134x 1134x 1134x   1134x     1134x 1134x             22x  
import { type TagType } from '../store/Types';
import { type SectionElement, useSectionStore } from '../store/Section';
import { useSectionRender } from '../utils/useRender';
import { type SectionElementResult } from '../store/Section';
 
export const Row = <K extends TagType>(props: SectionElement<K>) => {
  const { Row: Comp = {} } = useSectionStore();
  useSectionRender(Comp, props, 'Row');
  return null;
};
 
Row.displayName = 'JVR.Row';
 
export interface RowCompProps<T extends object> extends React.HTMLAttributes<HTMLDivElement>, SectionElementResult<T> {}
 
export const RowComp = <T extends object>(props: React.PropsWithChildren<RowCompProps<T>>) => {
  const { children, value, parentValue, keyName, keys, ...other } = props;
  const { Row: Comp = {} } = useSectionStore();
  const { as, render, children: _, ...reset } = Comp;
  const Elm = as || 'div';
  const child =
    render &&
    typeof render === 'function' &&
    render({ ...other, ...reset, children }, { value, keyName, parentValue, keys });
  Iif (child) return child;
  return (
    <Elm {...other} {...reset}>
      {children}
    </Elm>
  );
};
 
RowComp.displayName = 'JVR.RowComp';