Socket
Socket
Sign inDemoInstall

@superset-ui/dimension

Package Overview
Dependencies
Maintainers
7
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superset-ui/dimension - npm Package Compare versions

Comparing version 0.9.3 to 0.10.0

2

esm/computeMaxFontSize.js

@@ -1,1 +0,1 @@

function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}import getTextDimension from"./getTextDimension";function decreaseSizeUntil(a,b,c){for(var d=a,e=b(d);!c(e);)d-=1,e=b(d);return d}export default function computeMaxFontSize(a){var c=Math.floor;function b(a){return getTextDimension(_extends({},i,{style:_extends({},h,{fontSize:a})}))}var d,e=a.idealFontSize,f=a.maxWidth,g=a.maxHeight,h=a.style,i=_objectWithoutPropertiesLoose(a,["idealFontSize","maxWidth","maxHeight","style"]);if(void 0!==e&&null!==e)d=e;else if(void 0===g||null===g)throw new Error("You must specify at least one of maxHeight or idealFontSize");else d=c(g);return void 0!==f&&null!==f&&(d=decreaseSizeUntil(d,b,function(a){return a.width<=f})),void 0!==g&&null!==g&&(d=decreaseSizeUntil(d,b,function(a){return a.height<=g})),d}
function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}import getTextDimension from"./getTextDimension";function decreaseSizeUntil(a,b,c){for(var d=a,e=b(d);!c(e);)d-=1,e=b(d);return d}export default function computeMaxFontSize(a){function b(a){return getTextDimension(_extends({},h,{style:_extends({},g,{fontSize:a})}))}var c,d=a.idealFontSize,e=a.maxWidth,f=a.maxHeight,g=a.style,h=_objectWithoutPropertiesLoose(a,["idealFontSize","maxWidth","maxHeight","style"]);if(void 0!==d&&null!==d)c=d;else if(void 0===f||null===f)throw new Error("You must specify at least one of maxHeight or idealFontSize");else c=Math.floor(f);return void 0!==e&&null!==e&&(c=decreaseSizeUntil(c,b,function(a){return a.width<=e})),void 0!==f&&null!==f&&(c=decreaseSizeUntil(c,b,function(a){return a.height<=f})),c}

@@ -1,1 +0,1 @@

var SVG_NS="http://www.w3.org/2000/svg",STYLE_FIELDS=["font","fontWeight","fontStyle","fontSize","fontFamily","letterSpacing"],DEFAULT_DIMENSION={height:20,width:100};export default function getTextDimension(a,b){var c=Math.ceil;void 0===b&&(b=DEFAULT_DIMENSION);var d=a.text,e=a.className,f=a.style,g=void 0===f?{}:f,h=a.container,i=void 0===h?document.body:h,j=document.createElementNS(SVG_NS,"text");j.textContent=d,void 0!==e&&null!==e&&j.setAttribute("class",e),STYLE_FIELDS.filter(function(a){return void 0!==g[a]&&null!==g[a]}).forEach(function(a){j.style[a]=""+g[a]});var k=document.createElementNS(SVG_NS,"svg");k.style.position="absolute",k.style.opacity="0",k.style.pointerEvents="none",k.appendChild(j),i.appendChild(k);var l=j.getBBox?j.getBBox():b;return i.removeChild(k),{height:c(l.height),width:c(l.width)}}
var SVG_NS="http://www.w3.org/2000/svg",STYLE_FIELDS=["font","fontWeight","fontStyle","fontSize","fontFamily","letterSpacing"],DEFAULT_DIMENSION={height:20,width:100};export default function getTextDimension(a,b){void 0===b&&(b=DEFAULT_DIMENSION);var c=a.text,d=a.className,e=a.style,f=void 0===e?{}:e,g=a.container,h=void 0===g?document.body:g,i=document.createElementNS(SVG_NS,"text");i.textContent=c,void 0!==d&&null!==d&&i.setAttribute("class",d),STYLE_FIELDS.filter(function(a){return void 0!==f[a]&&null!==f[a]}).forEach(function(a){i.style[a]=""+f[a]});var j=document.createElementNS(SVG_NS,"svg");j.style.position="absolute",j.style.opacity="0",j.style.pointerEvents="none",j.appendChild(i),h.appendChild(j);var k=i.getBBox?i.getBBox():b;return h.removeChild(j),{height:Math.ceil(k.height),width:Math.ceil(k.width)}}

@@ -1,1 +0,1 @@

"use strict";var _getTextDimension=_interopRequireDefault(require("./getTextDimension"));exports.__esModule=!0,exports.default=computeMaxFontSize;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function decreaseSizeUntil(a,b,c){for(var d=a,e=b(d);!c(e);)d-=1,e=b(d);return d}function computeMaxFontSize(a){var c=Math.floor;function b(a){return(0,_getTextDimension.default)(_extends({},i,{style:_extends({},h,{fontSize:a})}))}var d,e=a.idealFontSize,f=a.maxWidth,g=a.maxHeight,h=a.style,i=_objectWithoutPropertiesLoose(a,["idealFontSize","maxWidth","maxHeight","style"]);if(void 0!==e&&null!==e)d=e;else if(void 0===g||null===g)throw new Error("You must specify at least one of maxHeight or idealFontSize");else d=c(g);return void 0!==f&&null!==f&&(d=decreaseSizeUntil(d,b,function(a){return a.width<=f})),void 0!==g&&null!==g&&(d=decreaseSizeUntil(d,b,function(a){return a.height<=g})),d}
"use strict";var _getTextDimension=_interopRequireDefault(require("./getTextDimension"));exports.__esModule=!0,exports.default=computeMaxFontSize;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function decreaseSizeUntil(a,b,c){for(var d=a,e=b(d);!c(e);)d-=1,e=b(d);return d}function computeMaxFontSize(a){function b(a){return(0,_getTextDimension.default)(_extends({},h,{style:_extends({},g,{fontSize:a})}))}var c,d=a.idealFontSize,e=a.maxWidth,f=a.maxHeight,g=a.style,h=_objectWithoutPropertiesLoose(a,["idealFontSize","maxWidth","maxHeight","style"]);if(void 0!==d&&null!==d)c=d;else if(void 0===f||null===f)throw new Error("You must specify at least one of maxHeight or idealFontSize");else c=Math.floor(f);return void 0!==e&&null!==e&&(c=decreaseSizeUntil(c,b,function(a){return a.width<=e})),void 0!==f&&null!==f&&(c=decreaseSizeUntil(c,b,function(a){return a.height<=f})),c}

@@ -1,1 +0,1 @@

"use strict";exports.__esModule=!0,exports.default=getTextDimension;var SVG_NS="http://www.w3.org/2000/svg",STYLE_FIELDS=["font","fontWeight","fontStyle","fontSize","fontFamily","letterSpacing"],DEFAULT_DIMENSION={height:20,width:100};function getTextDimension(a,b){var c=Math.ceil;void 0===b&&(b=DEFAULT_DIMENSION);var d=a.text,e=a.className,f=a.style,g=void 0===f?{}:f,h=a.container,i=void 0===h?document.body:h,j=document.createElementNS(SVG_NS,"text");j.textContent=d,void 0!==e&&null!==e&&j.setAttribute("class",e),STYLE_FIELDS.filter(function(a){return void 0!==g[a]&&null!==g[a]}).forEach(function(a){j.style[a]=""+g[a]});var k=document.createElementNS(SVG_NS,"svg");k.style.position="absolute",k.style.opacity="0",k.style.pointerEvents="none",k.appendChild(j),i.appendChild(k);var l=j.getBBox?j.getBBox():b;return i.removeChild(k),{height:c(l.height),width:c(l.width)}}
"use strict";exports.__esModule=!0,exports.default=getTextDimension;var SVG_NS="http://www.w3.org/2000/svg",STYLE_FIELDS=["font","fontWeight","fontStyle","fontSize","fontFamily","letterSpacing"],DEFAULT_DIMENSION={height:20,width:100};function getTextDimension(a,b){void 0===b&&(b=DEFAULT_DIMENSION);var c=a.text,d=a.className,e=a.style,f=void 0===e?{}:e,g=a.container,h=void 0===g?document.body:g,i=document.createElementNS(SVG_NS,"text");i.textContent=c,void 0!==d&&null!==d&&i.setAttribute("class",d),STYLE_FIELDS.filter(function(a){return void 0!==f[a]&&null!==f[a]}).forEach(function(a){i.style[a]=""+f[a]});var j=document.createElementNS(SVG_NS,"svg");j.style.position="absolute",j.style.opacity="0",j.style.pointerEvents="none",j.appendChild(i),h.appendChild(j);var k=i.getBBox?i.getBBox():b;return h.removeChild(j),{height:Math.ceil(k.height),width:Math.ceil(k.width)}}
{
"name": "@superset-ui/dimension",
"version": "0.9.3",
"version": "0.10.0",
"description": "Superset UI dimension",

@@ -28,3 +28,3 @@ "sideEffects": false,

},
"gitHead": "ad9d288d7a1f2a6714ebd8cc332428b5b94c868e"
"gitHead": "72157160f25698dbb379e3c9db86873ff9d17204"
}
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