{"version":3,"file":"index.cjs","names":["Children"],"sources":["../../../src/components/ListBlock/ListBlock.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport {\n  Children,\n  cloneElement,\n  CSSProperties,\n  forwardRef,\n  isValidElement,\n  ReactElement,\n} from \"react\";\nimport { ListItemProps, ListItemVariant } from \"../ListItem\";\n\nexport interface ListBlockProps {\n  /** Controls the indicator shown on every ListItem. Defaults to \"number\". */\n  variant?: ListItemVariant;\n  children: ReactElement<ListItemProps> | ReactElement<ListItemProps>[];\n  className?: string;\n  style?: CSSProperties;\n}\n\nconst ListBlock = forwardRef<HTMLDivElement, ListBlockProps>((props, ref) => {\n  const { children, variant = \"number\", className, style } = props;\n\n  const childArray = Children.toArray(children);\n  const listHasSubtitle = childArray.some(\n    (child) => isValidElement(child) && !!(child as ReactElement<ListItemProps>).props.subtitle,\n  );\n\n  const enhancedChildren = Children.map(children, (child, index) => {\n    if (isValidElement(child)) {\n      return cloneElement(child as ReactElement<ListItemProps>, {\n        variant,\n        listHasSubtitle,\n        index,\n      });\n    }\n    return child;\n  });\n\n  return (\n    <div ref={ref} className={clsx(\"openui-list-block\", className)} style={style}>\n      {enhancedChildren}\n    </div>\n  );\n});\n\nListBlock.displayName = \"ListBlock\";\n\nexport { ListBlock };\n"],"mappings":";;;;;;;AAmBA,MAAM,aAAA,GAAA,MAAA,aAAwD,OAAO,QAAQ;CAC3E,MAAM,EAAE,UAAU,UAAU,UAAU,WAAW,UAAU;CAG3D,MAAM,kBADaA,MAAAA,SAAS,QAAQ,SACF,CAAC,MAChC,WAAA,GAAA,MAAA,gBAAyB,MAAM,IAAI,CAAC,CAAE,MAAsC,MAAM,SACpF;CAED,MAAM,mBAAmBA,MAAAA,SAAS,IAAI,WAAW,OAAO,UAAU;AAChE,OAAA,GAAA,MAAA,gBAAmB,MAAM,CACvB,SAAA,GAAA,MAAA,cAAoB,OAAsC;GACxD;GACA;GACA;GACD,CAAC;AAEJ,SAAO;GACP;AAEF,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAU;EAAK,YAAA,GAAA,KAAA,SAAgB,qBAAqB,UAAU;EAAS;YACpE;EACG,CAAA;EAER;AAEF,UAAU,cAAc"}