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

@superset-ui/dimension

Package Overview
Dependencies
Maintainers
12
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.13.0 to 0.13.3

15

esm/computeMaxFontSize.js

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

"use strict";
exports.__esModule = true;
exports.default = computeMaxFontSize;
var _getTextDimension = _interopRequireDefault(require("./getTextDimension"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -5,4 +14,2 @@

import getTextDimension from './getTextDimension';
function decreaseSizeUntil(startSize, computeDimension, condition) {

@@ -20,3 +27,3 @@ let size = startSize;

export default function computeMaxFontSize(input) {
function computeMaxFontSize(input) {
const {

@@ -41,3 +48,3 @@ idealFontSize,

function computeDimension(fontSize) {
return getTextDimension(_extends({}, rest, {
return (0, _getTextDimension.default)(_extends({}, rest, {
style: _extends({}, style, {

@@ -44,0 +51,0 @@ fontSize: fontSize + "px"

@@ -1,4 +0,14 @@

import getBBoxCeil from './svg/getBBoxCeil';
import { hiddenSvgFactory, textFactory } from './svg/factories';
import updateTextNode from './svg/updateTextNode';
"use strict";
exports.__esModule = true;
exports.default = getMultipleTextDimensions;
var _getBBoxCeil = _interopRequireDefault(require("./svg/getBBoxCeil"));
var _factories = require("./svg/factories");
var _updateTextNode = _interopRequireDefault(require("./svg/updateTextNode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -9,4 +19,3 @@ * get dimensions of multiple texts with same style

*/
export default function getMultipleTextDimensions(input, defaultDimension) {
function getMultipleTextDimensions(input, defaultDimension) {
const {

@@ -34,8 +43,8 @@ texts,

if (!textNode) {
svgNode = hiddenSvgFactory.createInContainer(container);
textNode = textFactory.createInContainer(svgNode);
svgNode = _factories.hiddenSvgFactory.createInContainer(container);
textNode = _factories.textFactory.createInContainer(svgNode);
} // Update text and get dimension
updateTextNode(textNode, {
(0, _updateTextNode.default)(textNode, {
className,

@@ -45,3 +54,3 @@ style,

});
const dimension = getBBoxCeil(textNode, defaultDimension); // Store result to cache
const dimension = (0, _getBBoxCeil.default)(textNode, defaultDimension); // Store result to cache

@@ -61,4 +70,5 @@ cache.set(text, dimension);

setTimeout(() => {
textFactory.removeFromContainer(svgNode);
hiddenSvgFactory.removeFromContainer(container);
_factories.textFactory.removeFromContainer(svgNode);
_factories.hiddenSvgFactory.removeFromContainer(container);
}, 500);

@@ -65,0 +75,0 @@ }

@@ -1,5 +0,15 @@

import updateTextNode from './svg/updateTextNode';
import getBBoxCeil from './svg/getBBoxCeil';
import { hiddenSvgFactory, textFactory } from './svg/factories';
export default function getTextDimension(input, defaultDimension) {
"use strict";
exports.__esModule = true;
exports.default = getTextDimension;
var _updateTextNode = _interopRequireDefault(require("./svg/updateTextNode"));
var _getBBoxCeil = _interopRequireDefault(require("./svg/getBBoxCeil"));
var _factories = require("./svg/factories");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getTextDimension(input, defaultDimension) {
const {

@@ -19,5 +29,7 @@ text,

const svgNode = hiddenSvgFactory.createInContainer(container);
const textNode = textFactory.createInContainer(svgNode);
updateTextNode(textNode, {
const svgNode = _factories.hiddenSvgFactory.createInContainer(container);
const textNode = _factories.textFactory.createInContainer(svgNode);
(0, _updateTextNode.default)(textNode, {
className,

@@ -27,3 +39,3 @@ style,

});
const dimension = getBBoxCeil(textNode, defaultDimension); // The nodes are added to the DOM briefly only to make getBBox works.
const dimension = (0, _getBBoxCeil.default)(textNode, defaultDimension); // The nodes are added to the DOM briefly only to make getBBox works.
// (If not added to DOM getBBox will always return 0x0.)

@@ -37,6 +49,7 @@ // After that the svg nodes are not needed.

setTimeout(() => {
textFactory.removeFromContainer(svgNode);
hiddenSvgFactory.removeFromContainer(container);
_factories.textFactory.removeFromContainer(svgNode);
_factories.hiddenSvgFactory.removeFromContainer(container);
}, 500);
return dimension;
}

@@ -1,6 +0,41 @@

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';
"use strict";
exports.__esModule = true;
var _exportNames = {
getTextDimension: true,
getMultipleTextDimensions: true,
computeMaxFontSize: true,
mergeMargin: true,
parseLength: true
};
exports.parseLength = exports.mergeMargin = exports.computeMaxFontSize = exports.getMultipleTextDimensions = exports.getTextDimension = void 0;
var _getTextDimension = _interopRequireDefault(require("./getTextDimension"));
exports.getTextDimension = _getTextDimension.default;
var _getMultipleTextDimensions = _interopRequireDefault(require("./getMultipleTextDimensions"));
exports.getMultipleTextDimensions = _getMultipleTextDimensions.default;
var _computeMaxFontSize = _interopRequireDefault(require("./computeMaxFontSize"));
exports.computeMaxFontSize = _computeMaxFontSize.default;
var _mergeMargin = _interopRequireDefault(require("./mergeMargin"));
exports.mergeMargin = _mergeMargin.default;
var _parseLength = _interopRequireDefault(require("./parseLength"));
exports.parseLength = _parseLength.default;
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _types[key];
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

"use strict";
exports.__esModule = true;
exports.default = mergeMargin;
function mergeOneSide(operation, a = 0, b = 0) {

@@ -7,3 +12,3 @@ if (Number.isNaN(a) || a === null) return b;

export default function mergeMargin(margin1 = {}, margin2 = {}, mode = 'expand') {
function mergeMargin(margin1 = {}, margin2 = {}, mode = 'expand') {
const {

@@ -10,0 +15,0 @@ top,

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

"use strict";
exports.__esModule = true;
exports.default = parseLength;
const HUNDRED_PERCENT = {

@@ -5,3 +9,4 @@ isDynamic: true,

};
export default function parseLength(input) {
function parseLength(input) {
if (input === 'auto' || input === '100%') {

@@ -8,0 +13,0 @@ return HUNDRED_PERCENT;

@@ -0,2 +1,7 @@

"use strict";
exports.__esModule = true;
exports.SVG_NS = void 0;
// eslint-disable-next-line import/prefer-default-export
export const SVG_NS = 'http://www.w3.org/2000/svg';
const SVG_NS = 'http://www.w3.org/2000/svg';
exports.SVG_NS = SVG_NS;

@@ -1,4 +0,10 @@

import { SVG_NS } from './constants';
export default function createHiddenSvgNode() {
const svgNode = document.createElementNS(SVG_NS, 'svg');
"use strict";
exports.__esModule = true;
exports.default = createHiddenSvgNode;
var _constants = require("./constants");
function createHiddenSvgNode() {
const svgNode = document.createElementNS(_constants.SVG_NS, 'svg');
svgNode.style.position = 'absolute'; // so it won't disrupt page layout

@@ -5,0 +11,0 @@

@@ -1,4 +0,10 @@

import { SVG_NS } from './constants';
export default function createTextNode() {
return document.createElementNS(SVG_NS, 'text');
"use strict";
exports.__esModule = true;
exports.default = createTextNode;
var _constants = require("./constants");
function createTextNode() {
return document.createElementNS(_constants.SVG_NS, 'text');
}

@@ -1,5 +0,17 @@

import LazyFactory from './LazyFactory';
import createHiddenSvgNode from './createHiddenSvgNode';
import createTextNode from './createTextNode';
export const hiddenSvgFactory = new LazyFactory(createHiddenSvgNode);
export const textFactory = new LazyFactory(createTextNode);
"use strict";
exports.__esModule = true;
exports.textFactory = exports.hiddenSvgFactory = void 0;
var _LazyFactory = _interopRequireDefault(require("./LazyFactory"));
var _createHiddenSvgNode = _interopRequireDefault(require("./createHiddenSvgNode"));
var _createTextNode = _interopRequireDefault(require("./createTextNode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const hiddenSvgFactory = new _LazyFactory.default(_createHiddenSvgNode.default);
exports.hiddenSvgFactory = hiddenSvgFactory;
const textFactory = new _LazyFactory.default(_createTextNode.default);
exports.textFactory = textFactory;

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

"use strict";
exports.__esModule = true;
exports.default = getBBoxCeil;
const DEFAULT_DIMENSION = {

@@ -5,3 +9,4 @@ height: 20,

};
export default function getBBoxCeil(node, defaultDimension = DEFAULT_DIMENSION) {
function getBBoxCeil(node, defaultDimension = DEFAULT_DIMENSION) {
const {

@@ -8,0 +13,0 @@ width,

@@ -0,4 +1,9 @@

"use strict";
exports.__esModule = true;
exports.default = void 0;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export default class LazyFactory {
class LazyFactory {
constructor(factoryFn) {

@@ -40,2 +45,4 @@ _defineProperty(this, "activeNodes", new Map());

}
}
exports.default = LazyFactory;

@@ -0,3 +1,8 @@

"use strict";
exports.__esModule = true;
exports.default = updateTextNode;
const STYLE_FIELDS = ['font', 'fontWeight', 'fontStyle', 'fontSize', 'fontFamily', 'letterSpacing'];
export default function updateTextNode(node, {
function updateTextNode(node, {
className,

@@ -4,0 +9,0 @@ style = {},

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

"use strict";
exports.__esModule = true;
exports.default = computeMaxFontSize;
var _getTextDimension = _interopRequireDefault(require("./getTextDimension"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -5,4 +14,2 @@

import getTextDimension from './getTextDimension';
function decreaseSizeUntil(startSize, computeDimension, condition) {

@@ -20,3 +27,3 @@ let size = startSize;

export default function computeMaxFontSize(input) {
function computeMaxFontSize(input) {
const {

@@ -41,3 +48,3 @@ idealFontSize,

function computeDimension(fontSize) {
return getTextDimension(_extends({}, rest, {
return (0, _getTextDimension.default)(_extends({}, rest, {
style: _extends({}, style, {

@@ -44,0 +51,0 @@ fontSize: fontSize + "px"

@@ -1,4 +0,14 @@

import getBBoxCeil from './svg/getBBoxCeil';
import { hiddenSvgFactory, textFactory } from './svg/factories';
import updateTextNode from './svg/updateTextNode';
"use strict";
exports.__esModule = true;
exports.default = getMultipleTextDimensions;
var _getBBoxCeil = _interopRequireDefault(require("./svg/getBBoxCeil"));
var _factories = require("./svg/factories");
var _updateTextNode = _interopRequireDefault(require("./svg/updateTextNode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -9,4 +19,3 @@ * get dimensions of multiple texts with same style

*/
export default function getMultipleTextDimensions(input, defaultDimension) {
function getMultipleTextDimensions(input, defaultDimension) {
const {

@@ -34,8 +43,8 @@ texts,

if (!textNode) {
svgNode = hiddenSvgFactory.createInContainer(container);
textNode = textFactory.createInContainer(svgNode);
svgNode = _factories.hiddenSvgFactory.createInContainer(container);
textNode = _factories.textFactory.createInContainer(svgNode);
} // Update text and get dimension
updateTextNode(textNode, {
(0, _updateTextNode.default)(textNode, {
className,

@@ -45,3 +54,3 @@ style,

});
const dimension = getBBoxCeil(textNode, defaultDimension); // Store result to cache
const dimension = (0, _getBBoxCeil.default)(textNode, defaultDimension); // Store result to cache

@@ -61,4 +70,5 @@ cache.set(text, dimension);

setTimeout(() => {
textFactory.removeFromContainer(svgNode);
hiddenSvgFactory.removeFromContainer(container);
_factories.textFactory.removeFromContainer(svgNode);
_factories.hiddenSvgFactory.removeFromContainer(container);
}, 500);

@@ -65,0 +75,0 @@ }

@@ -1,5 +0,15 @@

import updateTextNode from './svg/updateTextNode';
import getBBoxCeil from './svg/getBBoxCeil';
import { hiddenSvgFactory, textFactory } from './svg/factories';
export default function getTextDimension(input, defaultDimension) {
"use strict";
exports.__esModule = true;
exports.default = getTextDimension;
var _updateTextNode = _interopRequireDefault(require("./svg/updateTextNode"));
var _getBBoxCeil = _interopRequireDefault(require("./svg/getBBoxCeil"));
var _factories = require("./svg/factories");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getTextDimension(input, defaultDimension) {
const {

@@ -19,5 +29,7 @@ text,

const svgNode = hiddenSvgFactory.createInContainer(container);
const textNode = textFactory.createInContainer(svgNode);
updateTextNode(textNode, {
const svgNode = _factories.hiddenSvgFactory.createInContainer(container);
const textNode = _factories.textFactory.createInContainer(svgNode);
(0, _updateTextNode.default)(textNode, {
className,

@@ -27,3 +39,3 @@ style,

});
const dimension = getBBoxCeil(textNode, defaultDimension); // The nodes are added to the DOM briefly only to make getBBox works.
const dimension = (0, _getBBoxCeil.default)(textNode, defaultDimension); // The nodes are added to the DOM briefly only to make getBBox works.
// (If not added to DOM getBBox will always return 0x0.)

@@ -37,6 +49,7 @@ // After that the svg nodes are not needed.

setTimeout(() => {
textFactory.removeFromContainer(svgNode);
hiddenSvgFactory.removeFromContainer(container);
_factories.textFactory.removeFromContainer(svgNode);
_factories.hiddenSvgFactory.removeFromContainer(container);
}, 500);
return dimension;
}

@@ -1,6 +0,41 @@

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';
"use strict";
exports.__esModule = true;
var _exportNames = {
getTextDimension: true,
getMultipleTextDimensions: true,
computeMaxFontSize: true,
mergeMargin: true,
parseLength: true
};
exports.parseLength = exports.mergeMargin = exports.computeMaxFontSize = exports.getMultipleTextDimensions = exports.getTextDimension = void 0;
var _getTextDimension = _interopRequireDefault(require("./getTextDimension"));
exports.getTextDimension = _getTextDimension.default;
var _getMultipleTextDimensions = _interopRequireDefault(require("./getMultipleTextDimensions"));
exports.getMultipleTextDimensions = _getMultipleTextDimensions.default;
var _computeMaxFontSize = _interopRequireDefault(require("./computeMaxFontSize"));
exports.computeMaxFontSize = _computeMaxFontSize.default;
var _mergeMargin = _interopRequireDefault(require("./mergeMargin"));
exports.mergeMargin = _mergeMargin.default;
var _parseLength = _interopRequireDefault(require("./parseLength"));
exports.parseLength = _parseLength.default;
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _types[key];
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

"use strict";
exports.__esModule = true;
exports.default = mergeMargin;
function mergeOneSide(operation, a = 0, b = 0) {

@@ -7,3 +12,3 @@ if (Number.isNaN(a) || a === null) return b;

export default function mergeMargin(margin1 = {}, margin2 = {}, mode = 'expand') {
function mergeMargin(margin1 = {}, margin2 = {}, mode = 'expand') {
const {

@@ -10,0 +15,0 @@ top,

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

"use strict";
exports.__esModule = true;
exports.default = parseLength;
const HUNDRED_PERCENT = {

@@ -5,3 +9,4 @@ isDynamic: true,

};
export default function parseLength(input) {
function parseLength(input) {
if (input === 'auto' || input === '100%') {

@@ -8,0 +13,0 @@ return HUNDRED_PERCENT;

@@ -0,2 +1,7 @@

"use strict";
exports.__esModule = true;
exports.SVG_NS = void 0;
// eslint-disable-next-line import/prefer-default-export
export const SVG_NS = 'http://www.w3.org/2000/svg';
const SVG_NS = 'http://www.w3.org/2000/svg';
exports.SVG_NS = SVG_NS;

@@ -1,4 +0,10 @@

import { SVG_NS } from './constants';
export default function createHiddenSvgNode() {
const svgNode = document.createElementNS(SVG_NS, 'svg');
"use strict";
exports.__esModule = true;
exports.default = createHiddenSvgNode;
var _constants = require("./constants");
function createHiddenSvgNode() {
const svgNode = document.createElementNS(_constants.SVG_NS, 'svg');
svgNode.style.position = 'absolute'; // so it won't disrupt page layout

@@ -5,0 +11,0 @@

@@ -1,4 +0,10 @@

import { SVG_NS } from './constants';
export default function createTextNode() {
return document.createElementNS(SVG_NS, 'text');
"use strict";
exports.__esModule = true;
exports.default = createTextNode;
var _constants = require("./constants");
function createTextNode() {
return document.createElementNS(_constants.SVG_NS, 'text');
}

@@ -1,5 +0,17 @@

import LazyFactory from './LazyFactory';
import createHiddenSvgNode from './createHiddenSvgNode';
import createTextNode from './createTextNode';
export const hiddenSvgFactory = new LazyFactory(createHiddenSvgNode);
export const textFactory = new LazyFactory(createTextNode);
"use strict";
exports.__esModule = true;
exports.textFactory = exports.hiddenSvgFactory = void 0;
var _LazyFactory = _interopRequireDefault(require("./LazyFactory"));
var _createHiddenSvgNode = _interopRequireDefault(require("./createHiddenSvgNode"));
var _createTextNode = _interopRequireDefault(require("./createTextNode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const hiddenSvgFactory = new _LazyFactory.default(_createHiddenSvgNode.default);
exports.hiddenSvgFactory = hiddenSvgFactory;
const textFactory = new _LazyFactory.default(_createTextNode.default);
exports.textFactory = textFactory;

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

"use strict";
exports.__esModule = true;
exports.default = getBBoxCeil;
const DEFAULT_DIMENSION = {

@@ -5,3 +9,4 @@ height: 20,

};
export default function getBBoxCeil(node, defaultDimension = DEFAULT_DIMENSION) {
function getBBoxCeil(node, defaultDimension = DEFAULT_DIMENSION) {
const {

@@ -8,0 +13,0 @@ width,

@@ -0,4 +1,9 @@

"use strict";
exports.__esModule = true;
exports.default = void 0;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export default class LazyFactory {
class LazyFactory {
constructor(factoryFn) {

@@ -40,2 +45,4 @@ _defineProperty(this, "activeNodes", new Map());

}
}
exports.default = LazyFactory;

@@ -0,3 +1,8 @@

"use strict";
exports.__esModule = true;
exports.default = updateTextNode;
const STYLE_FIELDS = ['font', 'fontWeight', 'fontStyle', 'fontSize', 'fontFamily', 'letterSpacing'];
export default function updateTextNode(node, {
function updateTextNode(node, {
className,

@@ -4,0 +9,0 @@ style = {},

{
"name": "@superset-ui/dimension",
"version": "0.13.0",
"version": "0.13.3",
"description": "Superset UI dimension",

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

},
"gitHead": "72b0c99f843add947371c6ee45cc32d57db6b027"
"gitHead": "f72e2d6e13333b55b5d6f1e2d7d5ccaec3868da6"
}
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