Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-wrap-balancer

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-wrap-balancer - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

10

dist/index.d.ts
import React from 'react';
declare type Props = {
/**
* The HTML tag to use for the wrapper element.
* @default 'span'
*/
as?: string;
/**
* The balance ratio of the wrapper width (0 <= ratio <= 1).
* 0 means the wrapper width is the same as the container width (no balance, browser default).
* 1 means the wrapper width is the minimum (full balance, most compact).
* @default 1
*/
ratio?: number;

@@ -6,0 +16,0 @@ children?: React.ReactNode;

2

dist/index.js
"use client"
var h=Object.create;var d=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of I(e))!L.call(t,n)&&n!==r&&d(t,n,{get:()=>e[n],enumerable:!(c=v(e,n))||c.enumerable});return t};var g=(t,e,r)=>(r=t!=null?h(S(t)):{},b(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),w=t=>b(d({},"__esModule",{value:!0}),t);var M={};R(M,{default:()=>A});module.exports=w(M);var i=g(require("react")),a="__wrap_balancer",E=typeof window=="undefined",m=E?i.default.useEffect:i.default.useLayoutEffect,y=(t,e,r)=>{let c,n=r||document.querySelector(`[data-br="${t}"]`),u=n.parentElement,o=_=>n.style.maxWidth=_+"px";n.style.maxWidth="";let s=u.clientWidth,l=u.clientHeight,p=s/2,f=s;if(s){for(;p+1<f;)o(c=~~((p+f)/2)),u.clientHeight==l?f=c:p=c;o(f*e+s*(1-e))}},x=y.toString();if(!E&&process.env.NODE_ENV!=="production"){let t=document.querySelector("[data-next-hide-fouc]");if(t){let e=c=>{for(let n of c)for(let u of n.removedNodes)if(u===t){r.disconnect();let o=document.querySelectorAll("[data-br]");for(let s of o)self[a](0,+s.dataset.brr,s)}},r=new MutationObserver(e);r.observe(document.head,{childList:!0})}}var O=({as:t="span",ratio:e=1,children:r,...c})=>{let n=t,u=i.default.useId(),o=i.default.useRef();return m(()=>{!o.current||(self[a]=y)(0,e,o.current)},[r,e]),m(()=>{if(!o.current)return;let s=o.current.parentElement;if(!s)return;let l=new ResizeObserver(()=>{!o.current||self[a](0,e,o.current)});return l.observe(s),()=>l.unobserve(s)},[]),i.default.createElement(i.default.Fragment,null,i.default.createElement(n,{...c,"data-br":u,"data-brr":e,ref:o,style:{display:"inline-block",verticalAlign:"top",textDecoration:"inherit"},suppressHydrationWarning:!0},r),i.default.createElement("script",{dangerouslySetInnerHTML:{__html:`self.${a}=${x};self.${a}("${u}",${e})`}}))},A=O;0&&(module.exports={});
var h=Object.create;var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},m=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!S.call(t,r)&&r!==n&&d(t,r,{get:()=>e[r],enumerable:!(o=_(e,r))||o.enumerable});return t};var H=(t,e,n)=>(n=t!=null?h(L(t)):{},m(e||!t||!t.__esModule?d(n,"default",{value:t,enumerable:!0}):n,t)),M=t=>m(d({},"__esModule",{value:!0}),t);var T={};g(T,{default:()=>R});module.exports=M(T);var l=H(require("react")),a="__wrap_balancer",E=typeof window=="undefined",b=E?l.default.useEffect:l.default.useLayoutEffect,p=(t,e,n)=>{n=n||document.querySelector(`[data-br="${t}"]`);let o=n.parentElement,r=y=>n.style.maxWidth=y+"px";n.style.maxWidth="";let i=o.clientWidth,s=o.clientHeight,c=i/2,u=i,f;if(i){for(;c+1<u;)f=~~((c+u)/2),r(f),o.clientHeight==s?u=f:c=f;r(u*e+i*(1-e))}},x=p.toString();if(!E&&process.env.NODE_ENV!=="production"){let t=document.querySelector("[data-next-hide-fouc]");if(t){let e=o=>{for(let r of o)for(let i of r.removedNodes)if(i===t){n.disconnect();let s=document.querySelectorAll("[data-br]");for(let c of s)self[a](0,+c.dataset.brr,c)}},n=new MutationObserver(e);n.observe(document.head,{childList:!0})}}var I=({as:t="span",ratio:e=1,children:n,...o})=>{let r=t,i=l.default.useId(),s=l.default.useRef();return b(()=>{!s.current||(self[a]=p)(0,e,s.current)},[n,e]),b(()=>{if(!s.current)return;let c=s.current.parentElement;if(!c)return;let u=new ResizeObserver(()=>{!s.current||self[a](0,e,s.current)});return u.observe(c),()=>u.unobserve(c)},[]),l.default.createElement(l.default.Fragment,null,l.default.createElement(r,{...o,"data-br":i,"data-brr":e,ref:s,style:{display:"inline-block",verticalAlign:"top",textDecoration:"inherit"},suppressHydrationWarning:!0},n),l.default.createElement("script",{dangerouslySetInnerHTML:{__html:`self.${a}=${x};self.${a}("${i}",${e})`}}))},R=I;0&&(module.exports={});
//# sourceMappingURL=index.js.map
{
"name": "react-wrap-balancer",
"version": "0.2.2",
"version": "0.2.3",
"description": "Better text wrapping.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc