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) 1.06 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("react/jsx-runtime"),e=require("react"),l=require("../utils/deviceType.js"),w=({children:a,onWrapChange:s,className:f})=>{const t=e.useRef(null),[r,d]=e.useState(0),u=l.default()==="mobile"||l.default()==="tablet"||l.default()==="midTablet",o=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 i=t.current;let c=0;if(i&&i.children.length>1){const p=i.children[0].getBoundingClientRect().top;Array.from(i.children).forEach((m,y)=>{y>0&&m.getBoundingClientRect().top>p&&c++})}c!==r&&d(c)},[r]);return e.useEffect(()=>(n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)),[n]),e.useEffect(()=>{s&&s(r)},[r,s]),e.useEffect(()=>{o()},[o]),b.jsxs("div",{ref:t,className:f,children:[o(),a]})};exports.default=w;