@superset-ui/dimension
Advanced tools
Comparing version 0.11.10 to 0.11.15
@@ -1,1 +0,9 @@ | ||
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)}} | ||
import updateTextNode from"./svg/updateTextNode";import getBBoxCeil from"./svg/getBBoxCeil";import{hiddenSvgFactory,textFactory}from"./svg/factories";export default function getTextDimension(a,b){var c=a.text,d=a.className,e=a.style,f=a.container;// Empty string | ||
if(0===c.length)return{height:0,width:0};var g=hiddenSvgFactory.createInContainer(f),h=textFactory.createInContainer(g);updateTextNode(h,{className:d,style:e,text:c});var i=getBBoxCeil(h,b);// The nodes are added to the DOM briefly only to make getBBox works. | ||
// (If not added to DOM getBBox will always return 0x0.) | ||
// After that the svg nodes are not needed. | ||
// We delay its removal in case there are subsequent calls to this function | ||
// that can reuse the svg nodes. | ||
// Experiments have shown that reusing existing nodes | ||
// instead of deleting and adding new ones can save lot of time. | ||
return setTimeout(function(){textFactory.removeFromContainer(g),hiddenSvgFactory.removeFromContainer(f)},500),i} |
@@ -1,1 +0,1 @@ | ||
export{default as getTextDimension}from"./getTextDimension";export{default as computeMaxFontSize}from"./computeMaxFontSize";export{default as mergeMargin}from"./mergeMargin";export{default as parseLength}from"./parseLength";export*from"./types"; | ||
export{default as getTextDimension}from"./getTextDimension";export{default as getMultipleTextDimensions}from"./getMultipleTextDimensions";export{default as computeMaxFontSize}from"./computeMaxFontSize";export{default as mergeMargin}from"./mergeMargin";export{default as parseLength}from"./parseLength";export*from"./types"; |
@@ -1,1 +0,9 @@ | ||
"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)}} | ||
"use strict";exports.__esModule=!0,exports.default=getTextDimension;var _updateTextNode=_interopRequireDefault(require("./svg/updateTextNode")),_getBBoxCeil=_interopRequireDefault(require("./svg/getBBoxCeil")),_factories=require("./svg/factories");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function getTextDimension(a,b){var c=a.text,d=a.className,e=a.style,f=a.container;// Empty string | ||
if(0===c.length)return{height:0,width:0};var g=_factories.hiddenSvgFactory.createInContainer(f),h=_factories.textFactory.createInContainer(g);(0,_updateTextNode.default)(h,{className:d,style:e,text:c});var i=(0,_getBBoxCeil.default)(h,b);// The nodes are added to the DOM briefly only to make getBBox works. | ||
// (If not added to DOM getBBox will always return 0x0.) | ||
// After that the svg nodes are not needed. | ||
// We delay its removal in case there are subsequent calls to this function | ||
// that can reuse the svg nodes. | ||
// Experiments have shown that reusing existing nodes | ||
// instead of deleting and adding new ones can save lot of time. | ||
return setTimeout(function(){_factories.textFactory.removeFromContainer(g),_factories.hiddenSvgFactory.removeFromContainer(f)},500),i} |
export { default as getTextDimension } from './getTextDimension'; | ||
export { default as getMultipleTextDimensions } from './getMultipleTextDimensions'; | ||
export { default as computeMaxFontSize } from './computeMaxFontSize'; | ||
@@ -3,0 +4,0 @@ export { default as mergeMargin } from './mergeMargin'; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _exportNames={getTextDimension:!0,computeMaxFontSize:!0,mergeMargin:!0,parseLength:!0};var _getTextDimension=_interopRequireDefault(require("./getTextDimension"));var _computeMaxFontSize=_interopRequireDefault(require("./computeMaxFontSize"));var _mergeMargin=_interopRequireDefault(require("./mergeMargin"));var _parseLength=_interopRequireDefault(require("./parseLength"));var _types=require("./types");exports.__esModule=!0;exports.parseLength=exports.mergeMargin=exports.computeMaxFontSize=exports.getTextDimension=void 0;exports.getTextDimension=_getTextDimension.default;exports.computeMaxFontSize=_computeMaxFontSize.default;exports.mergeMargin=_mergeMargin.default;exports.parseLength=_parseLength.default;Object.keys(_types).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||(exports[a]=_types[a])});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
"use strict";var _exportNames={getTextDimension:!0,getMultipleTextDimensions:!0,computeMaxFontSize:!0,mergeMargin:!0,parseLength:!0};var _getTextDimension=_interopRequireDefault(require("./getTextDimension"));var _getMultipleTextDimensions=_interopRequireDefault(require("./getMultipleTextDimensions"));var _computeMaxFontSize=_interopRequireDefault(require("./computeMaxFontSize"));var _mergeMargin=_interopRequireDefault(require("./mergeMargin"));var _parseLength=_interopRequireDefault(require("./parseLength"));var _types=require("./types");exports.__esModule=!0;exports.parseLength=exports.mergeMargin=exports.computeMaxFontSize=exports.getMultipleTextDimensions=exports.getTextDimension=void 0;exports.getTextDimension=_getTextDimension.default;exports.getMultipleTextDimensions=_getMultipleTextDimensions.default;exports.computeMaxFontSize=_computeMaxFontSize.default;exports.mergeMargin=_mergeMargin.default;exports.parseLength=_parseLength.default;Object.keys(_types).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||(exports[a]=_types[a])});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} |
{ | ||
"name": "@superset-ui/dimension", | ||
"version": "0.11.10", | ||
"version": "0.11.15", | ||
"description": "Superset UI dimension", | ||
@@ -28,3 +28,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "54849c153d6571352ec1caeb8138e9be568feecc" | ||
"gitHead": "561880e93e6d19a671fe7613c261dbef388f305e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30271
45
128
5