UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

2 lines (1 loc) 943 B
"use strict";const y=require("react/jsx-runtime"),e=require("react"),l=require("../utils/deviceType.js"),x=({children:a,onWrapChange:i,className:f})=>{const t=e.useRef(null),[r,p]=e.useState(0),u=l()==="mobile"||l()==="tablet"||l()==="midTablet",c=e.useCallback(()=>{t.current&&(t.current.style.setProperty("display","flex","important"),r>0||u?t.current.style.setProperty("flex-wrap","wrap","important"):t.current.style.setProperty("flex-wrap","nowrap","important"))},[r,u]),n=e.useCallback(()=>{const s=t.current;let o=0;if(s&&s.children.length>1){const d=s.children[0].getBoundingClientRect().top;Array.from(s.children).forEach((m,w)=>{w>0&&m.getBoundingClientRect().top>d&&o++})}o!==r&&p(o)},[r]);return e.useEffect(()=>(n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)),[n]),e.useEffect(()=>{i&&i(r)},[r,i]),e.useEffect(()=>{c()},[c]),y.jsxs("div",{ref:t,className:f,children:[c(),a]})};module.exports=x;