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

i2ui

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i2ui - npm Package Compare versions

Comparing version 1.3.4 to 1.4.0

187

dist/index.esm.js

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

import React from 'react';
import { emphasizeStyle } from 'emphasizer';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var NumberUtil = /** @class */ (function () {
function NumberUtil() {
}
NumberUtil.splitNumber = function (value, options) {
var decimalDigits = options.decimalDigits, groupSeparator = options.groupSeparator, decimalSeparator = options.decimalSeparator, groupDigits = options.groupDigits;
var result = [];
var stringValue = value.toFixed(decimalDigits || 0);
var splits = stringValue.split('.');
if (splits.length > 0) {
var groups = NumberUtil.toGroups(splits[0], groupDigits);
for (var i = 0; i < groups.length; i++) {
result.push({
text: groups[i],
separator: i > 0 ? groupSeparator || ',' : undefined,
});
}
if (splits.length === 2) {
var fraction = splits[1];
if (fraction) {
result.push({
text: fraction,
isFraction: true,
separator: decimalSeparator || '.',
});
}
}
}
return result;
};
NumberUtil.toGroups = function (integer, groupDigits) {
if (groupDigits === 0) {
return [integer];
}
var digits = Math.abs(groupDigits || 3);
var output = integer.match(new RegExp("(\\d+?)(?=(\\d{" + digits + "})+(?!\\d)|$)", 'g'));
// integer.match(/(\d+?)(?=(\d{3})+(?!\d)|$)/g);
return output ? output : [];
};
return NumberUtil;
}());
var rootStyle = {
display: 'inline-block',
};
var defaultContentStyle = {
display: 'flex',
flexDirection: 'row',
alignItems: 'flex-end',
};
var numberPartStyle = {
lineHeight: '1em',
};
var I2Number = function (props) {
var value = props.value, fromStyle = props.fromStyle, toStyle = props.toStyle, decimalDigits = props.decimalDigits, basicMaxValue = props.basicMaxValue, align = props.verticalAlign, className = props.className, style = props.style, groupSeparator = props.groupSeparator, decimalSeparator = props.decimalSeparator, groupDigits = props.groupDigits;
var numberOptions = {
decimalDigits: decimalDigits,
decimalSeparator: decimalSeparator,
groupSeparator: groupSeparator,
groupDigits: groupDigits,
};
var splits = NumberUtil.splitNumber(value, numberOptions);
var basicSplits = NumberUtil.splitNumber(basicMaxValue || value, numberOptions);
var from = __assign({ fontSize: '1em' }, fromStyle);
var to = __assign({ fontSize: '2em' }, toStyle);
var maxRate = Math.max(basicSplits.length);
var contentStyle = __assign({}, defaultContentStyle);
if (align === 'top') {
contentStyle.alignItems = 'flex-start';
}
else if (align === 'center') {
contentStyle.alignItems = 'center';
}
return (React.createElement("div", { className: className, style: __assign(__assign({}, rootStyle), style) },
React.createElement("div", { style: contentStyle }, splits.map(function (_a, i) {
var text = _a.text, separator = _a.separator;
return (React.createElement("div", { key: i, style: __assign(__assign({}, emphasizeStyle(from, to, 1, maxRate, splits.length - i)), numberPartStyle) }, "" + (separator || '') + text));
}))));
};
var TagUtil = /** @class */ (function () {
function TagUtil() {
}
TagUtil.order = function (data, order) {
if (order === 'desc' || order === 'middle') {
var result = data.sort(function (a, b) {
if (a.rate > b.rate) {
return -1;
}
else if (a.rate < b.rate) {
return 1;
}
return 0;
});
if (order === 'middle') {
var temp_1 = [];
result.forEach(function (x, i) {
if (i % 2 === 0) {
temp_1.push(x);
}
else {
temp_1.unshift(x);
}
});
result = temp_1;
}
return result;
}
else if (order === 'asc' || order === 'edge') {
var result = data.sort(function (a, b) {
if (a.rate < b.rate) {
return -1;
}
else if (a.rate > b.rate) {
return 1;
}
return 0;
});
if (order === 'edge') {
var temp_2 = [];
result.forEach(function (x, i) {
if (i % 2 === 0) {
temp_2.push(x);
}
else {
temp_2.unshift(x);
}
});
result = temp_2;
}
return result;
}
return data;
};
return TagUtil;
}());
var TagCloud = function (props) {
var data = props.options, fromStyle = props.fromStyle, toStyle = props.toStyle, order = props.order, className = props.className, style = props.style, renderOption = props.renderOption;
var rates = data.map(function (x) { return x.rate; });
var min = Math.min.apply(Math, rates);
var max = Math.max.apply(Math, rates);
var orderData = TagUtil.order(data, order);
var rootStyle = {
display: 'flex',
flexWrap: 'wrap',
justifyItems: 'center',
alignItems: 'center',
justifyContent: 'center',
alignContent: 'center',
};
return (React.createElement("div", { className: className, style: __assign(__assign({}, rootStyle), style) }, orderData.map(function (x, i) {
var optionStyle = emphasizeStyle(fromStyle, toStyle, min, max, x.rate);
return (React.createElement(React.Fragment, { key: i }, renderOption ? (renderOption(__assign(__assign({}, x), { minRate: min, maxRate: max }), optionStyle)) : (React.createElement("div", { style: optionStyle }, x.text))));
})));
};
export { I2Number, TagCloud };
import React from"react";import{emphasizeStyle}from"emphasizer";var __assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},NumberUtil=function(){function o(){}return o.splitNumber=function(e,t){var r=t.decimalDigits,a=t.groupSeparator,n=t.decimalSeparator,t=t.groupDigits,i=[],r=e.toFixed(r||0).split(".");if(0<r.length){for(var s=o.toGroups(r[0],t),l=0;l<s.length;l++)i.push({text:s[l],separator:0<l?a||",":void 0});2!==r.length||(r=r[1])&&i.push({text:r,isFraction:!0,separator:n||"."})}return i},o.toGroups=function(e,t){if(0===t)return[e];t=Math.abs(t||3),t=e.match(new RegExp("(\\d+?)(?=(\\d{"+t+"})+(?!\\d)|$)","g"));return t||[]},o}(),rootStyle={display:"inline-block"},defaultContentStyle={display:"flex",flexDirection:"row",alignItems:"flex-end"},numberPartStyle={lineHeight:"1em"},I2Number=function(e){var t=e.value,r=e.fromStyle,a=e.toStyle,n=e.decimalDigits,i=e.basicMaxValue,s=e.verticalAlign,l=e.className,o=e.style,u=e.groupSeparator,e={decimalDigits:n,decimalSeparator:e.decimalSeparator,groupSeparator:u,groupDigits:e.groupDigits},c=NumberUtil.splitNumber(t,e),e=NumberUtil.splitNumber(i||t,e),m=__assign({fontSize:"1em"},r),p=__assign({fontSize:"2em"},a),g=Math.max(e.length),e=__assign({},defaultContentStyle);return"top"===s?e.alignItems="flex-start":"center"===s&&(e.alignItems="center"),React.createElement("div",{className:l,style:__assign(__assign({},rootStyle),o)},React.createElement("div",{style:e},c.map(function(e,t){var r=e.text,e=e.separator;return React.createElement("div",{key:t,style:__assign(__assign({},emphasizeStyle(m,p,1,g,c.length-t)),numberPartStyle)},""+(e||"")+r)})))},TagUtil=function(){function e(){}return e.order=function(e,t){if("desc"===t||"middle"===t){var r,a=e.sort(function(e,t){return e.rate>t.rate?-1:e.rate<t.rate?1:0});return"middle"===t&&(r=[],a.forEach(function(e,t){t%2==0?r.push(e):r.unshift(e)}),a=r),a}if("asc"!==t&&"edge"!==t)return e;var n,a=e.sort(function(e,t){return e.rate<t.rate?-1:e.rate>t.rate?1:0});return"edge"===t&&(n=[],a.forEach(function(e,t){t%2==0?n.push(e):n.unshift(e)}),a=n),a},e}(),TagCloud=function(e){var t=e.options,a=e.fromStyle,n=e.toStyle,r=e.order,i=e.className,s=e.style,l=e.renderOption,e=t.map(function(e){return e.rate}),o=Math.min.apply(Math,e),u=Math.max.apply(Math,e),r=TagUtil.order(t,r);return React.createElement("div",{className:i,style:__assign(__assign({},{display:"flex",flexWrap:"wrap",justifyItems:"center",alignItems:"center",justifyContent:"center",alignContent:"center"}),s)},r.map(function(e,t){var r=emphasizeStyle(a,n,o,u,e.rate);return React.createElement(React.Fragment,{key:t},l?l(e,r):React.createElement("div",{style:r},e.text))}))};export{I2Number,TagCloud};

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

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = _interopDefault(require('react'));
var emphasizer = require('emphasizer');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var NumberUtil = /** @class */ (function () {
function NumberUtil() {
}
NumberUtil.splitNumber = function (value, options) {
var decimalDigits = options.decimalDigits, groupSeparator = options.groupSeparator, decimalSeparator = options.decimalSeparator, groupDigits = options.groupDigits;
var result = [];
var stringValue = value.toFixed(decimalDigits || 0);
var splits = stringValue.split('.');
if (splits.length > 0) {
var groups = NumberUtil.toGroups(splits[0], groupDigits);
for (var i = 0; i < groups.length; i++) {
result.push({
text: groups[i],
separator: i > 0 ? groupSeparator || ',' : undefined,
});
}
if (splits.length === 2) {
var fraction = splits[1];
if (fraction) {
result.push({
text: fraction,
isFraction: true,
separator: decimalSeparator || '.',
});
}
}
}
return result;
};
NumberUtil.toGroups = function (integer, groupDigits) {
if (groupDigits === 0) {
return [integer];
}
var digits = Math.abs(groupDigits || 3);
var output = integer.match(new RegExp("(\\d+?)(?=(\\d{" + digits + "})+(?!\\d)|$)", 'g'));
// integer.match(/(\d+?)(?=(\d{3})+(?!\d)|$)/g);
return output ? output : [];
};
return NumberUtil;
}());
var rootStyle = {
display: 'inline-block',
};
var defaultContentStyle = {
display: 'flex',
flexDirection: 'row',
alignItems: 'flex-end',
};
var numberPartStyle = {
lineHeight: '1em',
};
var I2Number = function (props) {
var value = props.value, fromStyle = props.fromStyle, toStyle = props.toStyle, decimalDigits = props.decimalDigits, basicMaxValue = props.basicMaxValue, align = props.verticalAlign, className = props.className, style = props.style, groupSeparator = props.groupSeparator, decimalSeparator = props.decimalSeparator, groupDigits = props.groupDigits;
var numberOptions = {
decimalDigits: decimalDigits,
decimalSeparator: decimalSeparator,
groupSeparator: groupSeparator,
groupDigits: groupDigits,
};
var splits = NumberUtil.splitNumber(value, numberOptions);
var basicSplits = NumberUtil.splitNumber(basicMaxValue || value, numberOptions);
var from = __assign({ fontSize: '1em' }, fromStyle);
var to = __assign({ fontSize: '2em' }, toStyle);
var maxRate = Math.max(basicSplits.length);
var contentStyle = __assign({}, defaultContentStyle);
if (align === 'top') {
contentStyle.alignItems = 'flex-start';
}
else if (align === 'center') {
contentStyle.alignItems = 'center';
}
return (React.createElement("div", { className: className, style: __assign(__assign({}, rootStyle), style) },
React.createElement("div", { style: contentStyle }, splits.map(function (_a, i) {
var text = _a.text, separator = _a.separator;
return (React.createElement("div", { key: i, style: __assign(__assign({}, emphasizer.emphasizeStyle(from, to, 1, maxRate, splits.length - i)), numberPartStyle) }, "" + (separator || '') + text));
}))));
};
var TagUtil = /** @class */ (function () {
function TagUtil() {
}
TagUtil.order = function (data, order) {
if (order === 'desc' || order === 'middle') {
var result = data.sort(function (a, b) {
if (a.rate > b.rate) {
return -1;
}
else if (a.rate < b.rate) {
return 1;
}
return 0;
});
if (order === 'middle') {
var temp_1 = [];
result.forEach(function (x, i) {
if (i % 2 === 0) {
temp_1.push(x);
}
else {
temp_1.unshift(x);
}
});
result = temp_1;
}
return result;
}
else if (order === 'asc' || order === 'edge') {
var result = data.sort(function (a, b) {
if (a.rate < b.rate) {
return -1;
}
else if (a.rate > b.rate) {
return 1;
}
return 0;
});
if (order === 'edge') {
var temp_2 = [];
result.forEach(function (x, i) {
if (i % 2 === 0) {
temp_2.push(x);
}
else {
temp_2.unshift(x);
}
});
result = temp_2;
}
return result;
}
return data;
};
return TagUtil;
}());
var TagCloud = function (props) {
var data = props.options, fromStyle = props.fromStyle, toStyle = props.toStyle, order = props.order, className = props.className, style = props.style, renderOption = props.renderOption;
var rates = data.map(function (x) { return x.rate; });
var min = Math.min.apply(Math, rates);
var max = Math.max.apply(Math, rates);
var orderData = TagUtil.order(data, order);
var rootStyle = {
display: 'flex',
flexWrap: 'wrap',
justifyItems: 'center',
alignItems: 'center',
justifyContent: 'center',
alignContent: 'center',
};
return (React.createElement("div", { className: className, style: __assign(__assign({}, rootStyle), style) }, orderData.map(function (x, i) {
var optionStyle = emphasizer.emphasizeStyle(fromStyle, toStyle, min, max, x.rate);
return (React.createElement(React.Fragment, { key: i }, renderOption ? (renderOption(__assign(__assign({}, x), { minRate: min, maxRate: max }), optionStyle)) : (React.createElement("div", { style: optionStyle }, x.text))));
})));
};
exports.I2Number = I2Number;
exports.TagCloud = TagCloud;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),emphasizer=require("emphasizer"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},NumberUtil=function(){function o(){}return o.splitNumber=function(e,t){var r=t.decimalDigits,a=t.groupSeparator,n=t.decimalSeparator,t=t.groupDigits,i=[],r=e.toFixed(r||0).split(".");if(0<r.length){for(var s=o.toGroups(r[0],t),l=0;l<s.length;l++)i.push({text:s[l],separator:0<l?a||",":void 0});2!==r.length||(r=r[1])&&i.push({text:r,isFraction:!0,separator:n||"."})}return i},o.toGroups=function(e,t){if(0===t)return[e];t=Math.abs(t||3),t=e.match(new RegExp("(\\d+?)(?=(\\d{"+t+"})+(?!\\d)|$)","g"));return t||[]},o}(),rootStyle={display:"inline-block"},defaultContentStyle={display:"flex",flexDirection:"row",alignItems:"flex-end"},numberPartStyle={lineHeight:"1em"},I2Number=function(e){var t=e.value,r=e.fromStyle,a=e.toStyle,n=e.decimalDigits,i=e.basicMaxValue,s=e.verticalAlign,l=e.className,o=e.style,u=e.groupSeparator,e={decimalDigits:n,decimalSeparator:e.decimalSeparator,groupSeparator:u,groupDigits:e.groupDigits},c=NumberUtil.splitNumber(t,e),e=NumberUtil.splitNumber(i||t,e),p=__assign({fontSize:"1em"},r),m=__assign({fontSize:"2em"},a),f=Math.max(e.length),e=__assign({},defaultContentStyle);return"top"===s?e.alignItems="flex-start":"center"===s&&(e.alignItems="center"),React.createElement("div",{className:l,style:__assign(__assign({},rootStyle),o)},React.createElement("div",{style:e},c.map(function(e,t){var r=e.text,e=e.separator;return React.createElement("div",{key:t,style:__assign(__assign({},emphasizer.emphasizeStyle(p,m,1,f,c.length-t)),numberPartStyle)},""+(e||"")+r)})))},TagUtil=function(){function e(){}return e.order=function(e,t){if("desc"===t||"middle"===t){var r,a=e.sort(function(e,t){return e.rate>t.rate?-1:e.rate<t.rate?1:0});return"middle"===t&&(r=[],a.forEach(function(e,t){t%2==0?r.push(e):r.unshift(e)}),a=r),a}if("asc"!==t&&"edge"!==t)return e;var n,a=e.sort(function(e,t){return e.rate<t.rate?-1:e.rate>t.rate?1:0});return"edge"===t&&(n=[],a.forEach(function(e,t){t%2==0?n.push(e):n.unshift(e)}),a=n),a},e}(),TagCloud=function(e){var t=e.options,a=e.fromStyle,n=e.toStyle,r=e.order,i=e.className,s=e.style,l=e.renderOption,e=t.map(function(e){return e.rate}),o=Math.min.apply(Math,e),u=Math.max.apply(Math,e),r=TagUtil.order(t,r);return React.createElement("div",{className:i,style:__assign(__assign({},{display:"flex",flexWrap:"wrap",justifyItems:"center",alignItems:"center",justifyContent:"center",alignContent:"center"}),s)},r.map(function(e,t){var r=emphasizer.emphasizeStyle(a,n,o,u,e.rate);return React.createElement(React.Fragment,{key:t},l?l(e,r):React.createElement("div",{style:r},e.text))}))};exports.I2Number=I2Number,exports.TagCloud=TagCloud;

@@ -10,3 +10,3 @@ import React from 'react';

style?: React.CSSProperties;
renderOption?: (option: RenderedTagProps, style: React.CSSProperties) => React.ReactElement;
renderOption?: (option: TagProps, style: React.CSSProperties) => React.ReactElement;
}

@@ -16,8 +16,3 @@ export interface TagProps {

rate: number;
[key: string]: any;
}
export interface RenderedTagProps extends TagProps {
maxRate: number;
minRate: number;
}
export declare const TagCloud: React.FC<TagCloudProps>;

37

package.json
{
"name": "i2ui",
"version": "1.3.4",
"version": "1.4.0",
"description": "i2ui - Intuitively Understantable User Interface",

@@ -10,14 +10,22 @@ "main": "dist/index.js",

"@types/jest": "^24.0.20",
"@types/react": "^16.8.25",
"@types/react-dom": "^16.8.5",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"concurrently": "^4.1.1",
"eslint": "^6.2.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.3",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-varp": "^0.1.8",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^24.9.0",
"prepend-file": "^1.3.1",
"prettier": "^1.18.2",
"prettier": "^2.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rollup": "^1.19.4",

@@ -32,4 +40,4 @@ "rollup-plugin-scss": "^1.0.2",

"peerDependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": ">=16",
"react-dom": ">=16"
},

@@ -45,4 +53,5 @@ "scripts": {

"prepublishOnly": "npm run test && npm run lint",
"lint": "eslint ./src/**/*.ts ./src/**/*.tsx ./example/src/**/*.ts ./example/src/**/*.tsx",
"lint:fix": "npm run lint -- --fix"
"lint:old": "eslint ./src/**/*.ts ./src/**/*.tsx ./example/src/**/*.ts ./example/src/**/*.tsx",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},

@@ -49,0 +58,0 @@ "repository": {

@@ -0,0 +0,0 @@ # i2ui

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