@corva/ui 0.75.0-12 → 0.75.0-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),r=require("react"),n=require("@material-ui/core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),r=require("react"),n=require("lodash"),i=require("@material-ui/core"),u=require("classnames"),c=require("../../utils/formatting.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(u),l=i.makeStyles({root:{opacity:0,overflow:"visible",whiteSpace:"nowrap",textOverflow:"ellipsis"}});exports.MiddleTruncatedText=function(u){var o=u.children,a=u.className,d=u.showTooltip,v=void 0===d||d,f=u.customTooltipTitle,h=void 0===f?"":f,p=e.__rest(u,["children","className","showTooltip","customTooltipTitle"]),T=r.useRef(),g=r.useRef(),m=r.useRef(),_=r.useState({isTruncated:!1,content:o}),b=_[0],w=_[1],x=r.useRef(0),y=r.useRef(0),j=l();r.useEffect((function(){T.current&&g.current&&o&&(m.current&&m.current.unobserve(T.current),m.current=new ResizeObserver(n.debounce((function(e){var t,r,n,i=e[0].contentRect.width,u=null===(t=g.current)||void 0===t?void 0:t.getBoundingClientRect().width,s=null===(r=g.current)||void 0===r?void 0:r.innerHTML;x.current=Math.max(u,x.current);var l=y.current<i,a=Math.abs(i-x.current)<=2;if(e[0].target.scrollWidth<=e[0].target.clientWidth&&!l||a)(null===(n=T.current)||void 0===n?void 0:n.style)&&(T.current.style.opacity="1");else{var d=c.truncateInTheMiddle(o.toString(),i,x.current);i&&x.current&&x.current!==i&&(d!==s&&w({content:d,isTruncated:o.toString()!==d}),o.toString()===d&&w({content:o.toString(),isTruncated:!1}),y.current=i),T.current.style.opacity="1"}}))),m.current.observe(T.current))}),[b.content,o,T.current,g.current]);var R=t.jsx("div",e.__assign({className:s.default(j.root,a),ref:T},p,{children:t.jsx("span",e.__assign({ref:g},{children:b.content}))}));return v&&b.isTruncated?t.jsx(i.Tooltip,e.__assign({title:h||o},{children:R})):R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddleTruncatedText.d.ts","sourceRoot":"","sources":["../../../src/components/MiddleTruncatedText/MiddleTruncatedText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MiddleTruncatedText.d.ts","sourceRoot":"","sources":["../../../src/components/MiddleTruncatedText/MiddleTruncatedText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAgB3F,aAAK,KAAK,GAAG,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,GAAG;IAC/E,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,KAAK,CAkFzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as t,__assign as r}from'./../../ext-esm/tslib/tslib.es6.js';import{jsx as e}from"react/jsx-runtime";import{useRef as n,useState as o,useEffect as i}from"react";import{makeStyles as
|
|
1
|
+
import{__rest as t,__assign as r}from'./../../ext-esm/tslib/tslib.es6.js';import{jsx as e}from"react/jsx-runtime";import{useRef as n,useState as o,useEffect as i}from"react";import{debounce as c}from"lodash";import{makeStyles as u,Tooltip as l}from"@material-ui/core";import s from"classnames";import{truncateInTheMiddle as a}from"../../utils/formatting.js";var d=u({root:{opacity:0,overflow:"visible",whiteSpace:"nowrap",textOverflow:"ellipsis"}}),m=function(u){var m=u.children,v=u.className,p=u.showTooltip,f=void 0===p||p,h=u.customTooltipTitle,T=void 0===h?"":h,g=t(u,["children","className","showTooltip","customTooltipTitle"]),w=n(),b=n(),y=n(),S=o({isTruncated:!1,content:m}),x=S[0],j=S[1],M=n(0),N=n(0),R=d();i((function(){w.current&&b.current&&m&&(y.current&&y.current.unobserve(w.current),y.current=new ResizeObserver(c((function(t){var r,e,n,o=t[0].contentRect.width,i=null===(r=b.current)||void 0===r?void 0:r.getBoundingClientRect().width,c=null===(e=b.current)||void 0===e?void 0:e.innerHTML;M.current=Math.max(i,M.current);var u=N.current<o,l=Math.abs(o-M.current)<=2;if(t[0].target.scrollWidth<=t[0].target.clientWidth&&!u||l)(null===(n=w.current)||void 0===n?void 0:n.style)&&(w.current.style.opacity="1");else{var s=a(m.toString(),o,M.current);o&&M.current&&M.current!==o&&(s!==c&&j({content:s,isTruncated:m.toString()!==s}),m.toString()===s&&j({content:m.toString(),isTruncated:!1}),N.current=o),w.current.style.opacity="1"}}))),y.current.observe(w.current))}),[x.content,m,w.current,b.current]);var O=e("div",r({className:s(R.root,v),ref:w},g,{children:e("span",r({ref:b},{children:x.content}))}));return f&&x.isTruncated?e(l,r({title:T||m},{children:O})):O};export{m as MiddleTruncatedText};
|