Comparing version 1.3.2 to 1.3.3
@@ -1,1 +0,193 @@ | ||
"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 p(){}return p.splitNumber=function(e,t){var r=t.decimalDigits,a=t.groupSeparator,n=t.decimalSeparator,i=t.groupDigits,s=[],l=e.toFixed(r||0).split(".");if(0<l.length){for(var o=p.toGroups(l[0],i),u=0;u<o.length;u++)s.push({text:o[u],separator:0<u?a||",":void 0});if(2===l.length){var c=l[1];c&&s.push({text:c,isFraction:!0,separator:n||"."})}}return s},p.toGroups=function(e,t){if(0===t)return[e];var r=Math.abs(t||3),a=e.match(new RegExp("(\\d+?)(?=(\\d{"+r+"})+(?!\\d)|$)","g"));return a||[]},p}(),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,c={decimalDigits:n,decimalSeparator:e.decimalSeparator,groupSeparator:u,groupDigits:e.groupDigits},p=NumberUtil.splitNumber(t,c),f=NumberUtil.splitNumber(i||t,c),m=__assign({fontSize:"1em"},r),g=__assign({fontSize:"2em"},a),d=Math.max(f.length),y=__assign({},defaultContentStyle);return"top"===s?y.alignItems="flex-start":"center"===s&&(y.alignItems="center"),React.createElement("div",{className:l,style:__assign(__assign({},rootStyle),o)},React.createElement("div",{style:y},p.map(function(e,t){var r=e.text,a=e.separator;return React.createElement("div",{key:t,style:__assign(__assign({},emphasizer.emphasizeStyle(m,g,1,d,p.length-t)),numberPartStyle)},""+(a||"")+r)})))},TagUtil=function(){function e(){}return e.order=function(e,t){if("desc"===t||"middle"===t){var r=e.sort(function(e,t){return e.rate>t.rate?-1:e.rate<t.rate?1:0});if("middle"===t){var a=[];r.forEach(function(e,t){t%2==0?a.push(e):a.unshift(e)}),r=a}return r}if("asc"!==t&&"edge"!==t)return e;r=e.sort(function(e,t){return e.rate<t.rate?-1:e.rate>t.rate?1:0});if("edge"===t){var n=[];r.forEach(function(e,t){t%2==0?n.push(e):n.unshift(e)}),r=n}return r},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,o=t.map(function(e){return e.rate}),u=Math.min.apply(Math,o),c=Math.max.apply(Math,o),p=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)},p.map(function(e,t){var r=emphasizer.emphasizeStyle(a,n,u,c,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; | ||
'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(x, optionStyle) : React.createElement("div", { style: optionStyle }, x.text))); | ||
}))); | ||
}; | ||
exports.I2Number = I2Number; | ||
exports.TagCloud = TagCloud; |
{ | ||
"name": "i2ui", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "i2ui - Intuitively Understantable User Interface", | ||
@@ -35,7 +35,7 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "rollup -c --environment BUILD:production", | ||
"build": "rollup -c", | ||
"build-watch": "rollup -c -w", | ||
"install-all": "npm i && cd example && npm i", | ||
"start-example": "cd example && npm start", | ||
"deploy-example": "cd example && npm run deploy", | ||
"build-example": "npm run build && cd example && npm run build", | ||
"dev": "concurrently --kill-others \"npm run build-watch\" \"npm run start-example\"", | ||
@@ -42,0 +42,0 @@ "test": "jest", |
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
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 1 instance in 1 package
27102
415
0