New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.5.0 to 1.0.0

2

dist/index.d.ts
import React from 'react';
declare const SYMBOL_KEY = "__wrap_b";
declare const SYMBOL_NATIVE_KEY = "__wrap_n";
declare const SYMBOL_OBSERVER_KEY = "__wrap_o";

@@ -12,2 +13,3 @@ interface WrapperElement extends HTMLElement {

[SYMBOL_KEY]: RelayoutFn;
[SYMBOL_NATIVE_KEY]?: number;
}

@@ -14,0 +16,0 @@ }

4

dist/index.js
"use client"
var S=Object.create;var d=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(t,n)=>{for(var e in n)d(t,e,{get:n[e],enumerable:!0})},E=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of I(n))!L.call(t,r)&&r!==e&&d(t,r,{get:()=>n[r],enumerable:!(s=w(n,r))||s.enumerable});return t};var b=(t,n,e)=>(e=t!=null?S(W(t)):{},E(n||!t||!t.__esModule?d(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>E(d({},"__esModule",{value:!0}),t);var C={};M(C,{Balancer:()=>O,Provider:()=>N,default:()=>Y});module.exports=P(C);var i=b(require("react"));var l=b(require("react")),y=typeof window=="undefined",f=y?l.default.useEffect:l.default.useLayoutEffect,_=0,$=()=>++_,R=!1;function A(){let[t,n]=l.default.useState(R?$:void 0);return f(()=>{t===void 0&&n(++_),R=!0},[]),t===void 0?t:`rwb-${t.toString(32)}`}function v(){return l.default.useMemo(()=>"useId"in l.default?l.default.useId:A,[])()}var m="__wrap_b",g="__wrap_o",T=(t,n,e)=>{e=e||document.querySelector(`[data-br="${t}"]`);let s=e.parentElement,r=B=>e.style.maxWidth=B+"px";e.style.maxWidth="";let o=s.clientWidth,u=s.clientHeight,a=o/2-.25,c=o+.5,p;if(o){for(r(a),a=Math.max(e.scrollWidth,a);a+1<c;)p=Math.round((a+c)/2),r(p),s.clientHeight===u?c=p:a=p;r(c*n+o*(1-n))}e.__wrap_o||(typeof ResizeObserver!="undefined"?(e.__wrap_o=new ResizeObserver(()=>{self.__wrap_b(0,+e.dataset.brr,e)})).observe(s):process.env.NODE_ENV==="development"&&console.warn("The browser you are using does not support the ResizeObserver API. Please consider add polyfill for this API to avoid potential layout shifts or upgrade your browser. Read more: https://github.com/shuding/react-wrap-balancer#browser-support-information"))},H=T.toString(),h=(t,n,e="")=>i.default.createElement("script",{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:(t?"":`self.${m}=${H};`)+e},nonce:n}),x=i.default.createContext(!1),N=({nonce:t,children:n})=>i.default.createElement(x.Provider,{value:!0},h(!1,t),n),O=({ratio:t=1,nonce:n,children:e,...s})=>{let r=v(),o=i.default.useRef(),u=i.default.useContext(x),a=s.as||"span";return f(()=>{o.current&&(self[m]=T)(0,t,o.current)},[e,t]),f(()=>()=>{if(!o.current)return;let c=o.current[g];c&&(c.disconnect(),delete o.current[g])},[]),process.env.NODE_ENV==="development"&&e&&!Array.isArray(e)&&typeof e=="object"&&"type"in e&&typeof e.type=="string"&&e.type!=="span"&&console.warn(`<Balancer> should not wrap <${e.type}> inside. Instead, it should directly wrap text or inline nodes.
var w=Object.create;var f=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(t,n)=>{for(var e in n)f(t,e,{get:n[e],enumerable:!0})},b=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of W(n))!L.call(t,r)&&r!==e&&f(t,r,{get:()=>n[r],enumerable:!(s=I(n,r))||s.enumerable});return t};var _=(t,n,e)=>(e=t!=null?w($(t)):{},b(n||!t||!t.__esModule?f(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>b(f({},"__esModule",{value:!0}),t);var K={};M(K,{Balancer:()=>B,Provider:()=>H,default:()=>V});module.exports=P(K);var i=_(require("react"));var c=_(require("react")),E=typeof window=="undefined",m=E?c.default.useEffect:c.default.useLayoutEffect,S=0,Y=()=>++S,R=!1;function A(){let[t,n]=c.default.useState(R?Y:void 0);return m(()=>{t===void 0&&n(++S),R=!0},[]),t===void 0?t:`rwb-${t.toString(32)}`}function T(){return c.default.useMemo(()=>"useId"in c.default?c.default.useId:A,[])()}var y="__wrap_b",p="__wrap_n",v="__wrap_o",g=(t,n,e)=>{e=e||document.querySelector(`[data-br="${t}"]`);let s=e.parentElement,r=O=>e.style.maxWidth=O+"px";e.style.maxWidth="";let o=s.clientWidth,u=s.clientHeight,a=o/2-.25,l=o+.5,d;if(o){for(r(a),a=Math.max(e.scrollWidth,a);a+1<l;)d=Math.round((a+l)/2),r(d),s.clientHeight===u?l=d:a=d;r(l*n+o*(1-n))}e.__wrap_o||(typeof ResizeObserver!="undefined"?(e.__wrap_o=new ResizeObserver(()=>{self.__wrap_b(0,+e.dataset.brr,e)})).observe(s):process.env.NODE_ENV==="development"&&console.warn("The browser you are using does not support the ResizeObserver API. Please consider add polyfill for this API to avoid potential layout shifts or upgrade your browser. Read more: https://github.com/shuding/react-wrap-balancer#browser-support-information"))},N=g.toString(),C='(self.CSS&&CSS.supports("text-wrap","balance")?1:2)',h=(t,n,e="")=>(e&&(e=`self.${p}!=1&&${e}`),i.default.createElement("script",{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:(t?"":`self.${p}=self.${p}||${C};self.${y}=${N};`)+e},nonce:n})),x=i.default.createContext(!1),H=({nonce:t,children:n})=>i.default.createElement(x.Provider,{value:!0},h(!1,t),n),B=({ratio:t=1,nonce:n,children:e,...s})=>{let r=T(),o=i.default.useRef(),u=i.default.useContext(x),a=s.as||"span";return m(()=>{self[p]!==1&&o.current&&(self[y]=g)(0,t,o.current)},[e,t]),m(()=>{if(self[p]!==1)return()=>{if(!o.current)return;let l=o.current[v];l&&(l.disconnect(),delete o.current[v])}},[]),process.env.NODE_ENV==="development"&&e&&!Array.isArray(e)&&typeof e=="object"&&"type"in e&&typeof e.type=="string"&&e.type!=="span"&&console.warn(`<Balancer> should not wrap <${e.type}> inside. Instead, it should directly wrap text or inline nodes.

@@ -7,3 +7,3 @@ Try changing this:

To:
<${e.type}><Balancer>content</Balancer></${e.type}>`),i.default.createElement(i.default.Fragment,null,i.default.createElement(a,{...s,"data-br":r,"data-brr":t,ref:o,style:{display:"inline-block",verticalAlign:"top",textDecoration:"inherit"},suppressHydrationWarning:!0},e),h(u,n,`self.${m}("${r}",${t})`))};if(!y&&process.env.NODE_ENV!=="production"){let t=document.querySelector("[data-next-hide-fouc]");if(t){let n=s=>{for(let r of s)for(let o of Array.from(r.removedNodes)){if(o!==t)continue;e.disconnect();let u=document.querySelectorAll("[data-br]");for(let a of Array.from(u))self[m](0,+a.dataset.brr,a)}},e=new MutationObserver(n);e.observe(document.head,{childList:!0})}}var Y=O;0&&(module.exports={Balancer,Provider});
<${e.type}><Balancer>content</Balancer></${e.type}>`),i.default.createElement(i.default.Fragment,null,i.default.createElement(a,{...s,"data-br":r,"data-brr":t,ref:o,style:{display:"inline-block",verticalAlign:"top",textDecoration:"inherit",textWrap:"balance"},suppressHydrationWarning:!0},e),h(u,n,`self.${y}("${r}",${t})`))};if(!E&&process.env.NODE_ENV!=="production"){let t=document.querySelector("[data-next-hide-fouc]");if(t){let n=s=>{for(let r of s)for(let o of Array.from(r.removedNodes)){if(o!==t)continue;e.disconnect();let u=document.querySelectorAll("[data-br]");for(let a of Array.from(u))self[y](0,+a.dataset.brr,a)}},e=new MutationObserver(n);e.observe(document.head,{childList:!0})}}var V=B;0&&(module.exports={Balancer,Provider});
//# sourceMappingURL=index.js.map
{
"name": "react-wrap-balancer",
"version": "0.5.0",
"version": "1.0.0",
"description": "Simple React component that makes titles more readable.",
"repository": {
"type": "git",
"url": "https://github.com/shuding/react-wrap-balancer.git"
},
"homepage": "https://react-wrap-balancer.vercel.app",
"bugs": "https://github.com/shuding/react-wrap-balancer/issues",
"main": "dist/index.js",

@@ -6,0 +12,0 @@ "module": "dist/index.mjs",

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