@superset-ui/color
Advanced tools
Comparing version 0.11.0 to 0.11.3
@@ -7,2 +7,2 @@ function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}import CategoricalColorScale from"./CategoricalColorScale";import getCategoricalSchemeRegistry from"./CategoricalSchemeRegistrySingleton";import stringifyAndTrim from"./stringifyAndTrim";var CategoricalColorNamespace=/*#__PURE__*/function(){function a(a){_defineProperty(this,"name",void 0),_defineProperty(this,"forcedItems",void 0),_defineProperty(this,"scales",void 0),this.name=a,this.scales={},this.forcedItems={}}var b=a.prototype;return b.getScale=function(a){var b=a||getCategoricalSchemeRegistry().getDefaultKey()||"",c=this.scales[b];if(c)return c;var d=getCategoricalSchemeRegistry().get(b),e=new CategoricalColorScale(d&&d.colors||[],this.forcedItems);return this.scales[b]=e,e}/** | ||
* @param {*} forcedColor color | ||
*/,b.setColor=function setColor(a,b){return this.forcedItems[stringifyAndTrim(a)]=b,this},a}();export{CategoricalColorNamespace as default};var namespaces={};export var DEFAULT_NAMESPACE="GLOBAL";export function getNamespace(a){void 0===a&&(a=DEFAULT_NAMESPACE);var b=namespaces[a];if(b)return b;var c=new CategoricalColorNamespace(a);return namespaces[a]=c,c}export function getColor(a,b,c){return getNamespace(c).getScale(b).getColor(a)}export function getScale(a,b){return getNamespace(b).getScale(a)} | ||
*/,b.setColor=function c(a,b){return this.forcedItems[stringifyAndTrim(a)]=b,this},a}();export{CategoricalColorNamespace as default};var namespaces={};export var DEFAULT_NAMESPACE="GLOBAL";export function getNamespace(a){void 0===a&&(a=DEFAULT_NAMESPACE);var b=namespaces[a];if(b)return b;var c=new CategoricalColorNamespace(a);return namespaces[a]=c,c}export function getColor(a,b,c){return getNamespace(c).getScale(b).getColor(a)}export function getScale(a,b){return getNamespace(b).getScale(a)} |
@@ -6,9 +6,9 @@ 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 _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}import{ExtensibleFunction}from"@superset-ui/core";import stringifyAndTrim from"./stringifyAndTrim";var CategoricalColorScale=/*#__PURE__*/function(a){/** | ||
* (usually CategoricalColorNamespace) and supersede this.forcedColors | ||
*/function b(b,c){var d;return d=a.call(this,function(a){return d.getColor(a)})||this,_defineProperty(_assertThisInitialized(d),"colors",void 0),_defineProperty(_assertThisInitialized(d),"parentForcedColors",void 0),_defineProperty(_assertThisInitialized(d),"forcedColors",void 0),_defineProperty(_assertThisInitialized(d),"seen",void 0),d.colors=b,d.parentForcedColors=c,d.forcedColors={},d.seen={},d}_inheritsLoose(b,a);var c=b.prototype;return c.getColor=function getColor(a){var b=stringifyAndTrim(a),c=this.parentForcedColors&&this.parentForcedColors[b];if(c)return c;var d=this.forcedColors[b];if(d)return d;var e=this.seen[b],f=this.colors.length;if(void 0!==e)return this.colors[e%f];var g=Object.keys(this.seen).length;return this.seen[b]=g,this.colors[g%f]}/** | ||
*/function b(b,c){var d;return d=a.call(this,function(a){return d.getColor(a)})||this,_defineProperty(_assertThisInitialized(d),"colors",void 0),_defineProperty(_assertThisInitialized(d),"parentForcedColors",void 0),_defineProperty(_assertThisInitialized(d),"forcedColors",void 0),_defineProperty(_assertThisInitialized(d),"seen",void 0),d.colors=b,d.parentForcedColors=c,d.forcedColors={},d.seen={},d}_inheritsLoose(b,a);var c=b.prototype;return c.getColor=function h(a){var b=stringifyAndTrim(a),c=this.parentForcedColors&&this.parentForcedColors[b];if(c)return c;var d=this.forcedColors[b];if(d)return d;var e=this.seen[b],f=this.colors.length;if(void 0!==e)return this.colors[e%f];var g=Object.keys(this.seen).length;return this.seen[b]=g,this.colors[g%f]}/** | ||
* Enforce specific color for given value | ||
* @param {*} value value | ||
* @param {*} forcedColor forcedColor | ||
*/,c.setColor=function setColor(a,b){return this.forcedColors[stringifyAndTrim(a)]=b,this}/** | ||
*/,c.setColor=function c(a,b){return this.forcedColors[stringifyAndTrim(a)]=b,this}/** | ||
* Get a mapping of data values to colors | ||
* @returns an object where the key is the data value and the value is the hex color code | ||
*/,c.getColorMap=function getColorMap(){var a=this,b={},c=this.colors.length;return Object.keys(this.seen).forEach(function(d){b[d]=a.colors[a.seen[d]%c]}),_extends({},b,this.forcedColors,this.parentForcedColors)},b}(ExtensibleFunction);export{CategoricalColorScale as default}; | ||
*/,c.getColorMap=function d(){var a=this,b={},c=this.colors.length;return Object.keys(this.seen).forEach(function(d){b[d]=a.colors[a.seen[d]%c]}),_extends({},b,this.forcedColors,this.parentForcedColors)},b}(ExtensibleFunction);export{CategoricalColorScale as default}; |
@@ -1,1 +0,1 @@ | ||
function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}import{RegistryWithDefaultKey,OverwritePolicy}from"@superset-ui/core";var ColorSchemeRegistry=/*#__PURE__*/function(a){function b(){return a.call(this,{name:"ColorScheme",overwritePolicy:OverwritePolicy.WARN,setFirstItemAsDefault:!0})||this}_inheritsLoose(b,a);var c=b.prototype;return c.get=function get(b){return a.prototype.get.call(this,b)},b}(RegistryWithDefaultKey);export{ColorSchemeRegistry as default}; | ||
function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}import{RegistryWithDefaultKey,OverwritePolicy}from"@superset-ui/core";var ColorSchemeRegistry=/*#__PURE__*/function(a){function b(){return a.call(this,{name:"ColorScheme",overwritePolicy:OverwritePolicy.WARN,setFirstItemAsDefault:!0})||this}_inheritsLoose(b,a);var c=b.prototype;return c.get=function c(b){return a.prototype.get.call(this,b)},b}(RegistryWithDefaultKey);export{ColorSchemeRegistry as default}; |
@@ -1,4 +0,4 @@ | ||
function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}import{scaleLinear}from"d3-scale";import ColorScheme from"./ColorScheme";function range(a){for(var b=[],c=0;c<a;c+=1)b.push(c);return b}var SequentialScheme=/*#__PURE__*/function(a){function b(b){var c;c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"isDiverging",void 0);var d=b.isDiverging;return c.isDiverging=void 0!==d&&d,c}_inheritsLoose(b,a);var c=b.prototype;return c.createLinearScale=function createLinearScale(a){void 0===a&&(a=[0,1]);// Create matching domain | ||
function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}import{scaleLinear}from"d3-scale";import ColorScheme from"./ColorScheme";function range(a){for(var b=[],c=0;c<a;c+=1)b.push(c);return b}var SequentialScheme=/*#__PURE__*/function(a){function b(b){var c;c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"isDiverging",void 0);var d=b.isDiverging;return c.isDiverging=void 0!==d&&d,c}_inheritsLoose(b,a);var c=b.prototype;return c.createLinearScale=function e(a){void 0===a&&(a=[0,1]);// Create matching domain | ||
// because D3 continuous scale uses piecewise mapping | ||
// between domain and range. | ||
var b=scaleLinear().range(a),c=this.colors.length-1,d=range(this.colors.length).map(function(a){return b(a/c)});return scaleLinear().domain(d).range(this.colors).clamp(!0)},c.getColors=function getColors(a){if(void 0===a&&(a=this.colors.length),a===this.colors.length)return this.colors;var b=this.createLinearScale(),c=a-1;return range(a).map(function(a){return b(a/c)})},b}(ColorScheme);export{SequentialScheme as default}; | ||
var b=scaleLinear().range(a),c=this.colors.length-1,d=range(this.colors.length).map(function(a){return b(a/c)});return scaleLinear().domain(d).range(this.colors).clamp(!0)},c.getColors=function d(a){if(void 0===a&&(a=this.colors.length),a===this.colors.length)return this.colors;var b=this.createLinearScale(),c=a-1;return range(a).map(function(a){return b(a/c)})},b}(ColorScheme);export{SequentialScheme as default}; |
@@ -7,2 +7,2 @@ "use strict";exports.__esModule=!0,exports.getNamespace=getNamespace,exports.getColor=getColor,exports.getScale=getScale,exports.DEFAULT_NAMESPACE=exports.default=void 0;var _CategoricalColorScale=_interopRequireDefault(require("./CategoricalColorScale")),_CategoricalSchemeRegistrySingleton=_interopRequireDefault(require("./CategoricalSchemeRegistrySingleton")),_stringifyAndTrim=_interopRequireDefault(require("./stringifyAndTrim"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var CategoricalColorNamespace=/*#__PURE__*/function(){function a(a){_defineProperty(this,"name",void 0),_defineProperty(this,"forcedItems",void 0),_defineProperty(this,"scales",void 0),this.name=a,this.scales={},this.forcedItems={}}var b=a.prototype;return b.getScale=function(a){var b=a||(0,_CategoricalSchemeRegistrySingleton.default)().getDefaultKey()||"",c=this.scales[b];if(c)return c;var d=(0,_CategoricalSchemeRegistrySingleton.default)().get(b),e=new _CategoricalColorScale.default(d&&d.colors||[],this.forcedItems);return this.scales[b]=e,e}/** | ||
* @param {*} forcedColor color | ||
*/,b.setColor=function setColor(a,b){return this.forcedItems[(0,_stringifyAndTrim.default)(a)]=b,this},a}();exports.default=CategoricalColorNamespace;var namespaces={},DEFAULT_NAMESPACE="GLOBAL";exports.DEFAULT_NAMESPACE=DEFAULT_NAMESPACE;function getNamespace(a){void 0===a&&(a=DEFAULT_NAMESPACE);var b=namespaces[a];if(b)return b;var c=new CategoricalColorNamespace(a);return namespaces[a]=c,c}function getColor(a,b,c){return getNamespace(c).getScale(b).getColor(a)}function getScale(a,b){return getNamespace(b).getScale(a)} | ||
*/,b.setColor=function c(a,b){return this.forcedItems[(0,_stringifyAndTrim.default)(a)]=b,this},a}();exports.default=CategoricalColorNamespace;var namespaces={},DEFAULT_NAMESPACE="GLOBAL";exports.DEFAULT_NAMESPACE=DEFAULT_NAMESPACE;function getNamespace(a){void 0===a&&(a=DEFAULT_NAMESPACE);var b=namespaces[a];if(b)return b;var c=new CategoricalColorNamespace(a);return namespaces[a]=c,c}function getColor(a,b,c){return getNamespace(c).getScale(b).getColor(a)}function getScale(a,b){return getNamespace(b).getScale(a)} |
@@ -6,9 +6,9 @@ "use strict";exports.__esModule=!0,exports.default=void 0;var _core=require("@superset-ui/core"),_stringifyAndTrim=_interopRequireDefault(require("./stringifyAndTrim"));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 _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var CategoricalColorScale=/*#__PURE__*/function(a){/** | ||
* (usually CategoricalColorNamespace) and supersede this.forcedColors | ||
*/function b(b,c){var d;return d=a.call(this,function(a){return d.getColor(a)})||this,_defineProperty(_assertThisInitialized(d),"colors",void 0),_defineProperty(_assertThisInitialized(d),"parentForcedColors",void 0),_defineProperty(_assertThisInitialized(d),"forcedColors",void 0),_defineProperty(_assertThisInitialized(d),"seen",void 0),d.colors=b,d.parentForcedColors=c,d.forcedColors={},d.seen={},d}_inheritsLoose(b,a);var c=b.prototype;return c.getColor=function getColor(a){var b=(0,_stringifyAndTrim.default)(a),c=this.parentForcedColors&&this.parentForcedColors[b];if(c)return c;var d=this.forcedColors[b];if(d)return d;var e=this.seen[b],f=this.colors.length;if(void 0!==e)return this.colors[e%f];var g=Object.keys(this.seen).length;return this.seen[b]=g,this.colors[g%f]}/** | ||
*/function b(b,c){var d;return d=a.call(this,function(a){return d.getColor(a)})||this,_defineProperty(_assertThisInitialized(d),"colors",void 0),_defineProperty(_assertThisInitialized(d),"parentForcedColors",void 0),_defineProperty(_assertThisInitialized(d),"forcedColors",void 0),_defineProperty(_assertThisInitialized(d),"seen",void 0),d.colors=b,d.parentForcedColors=c,d.forcedColors={},d.seen={},d}_inheritsLoose(b,a);var c=b.prototype;return c.getColor=function h(a){var b=(0,_stringifyAndTrim.default)(a),c=this.parentForcedColors&&this.parentForcedColors[b];if(c)return c;var d=this.forcedColors[b];if(d)return d;var e=this.seen[b],f=this.colors.length;if(void 0!==e)return this.colors[e%f];var g=Object.keys(this.seen).length;return this.seen[b]=g,this.colors[g%f]}/** | ||
* Enforce specific color for given value | ||
* @param {*} value value | ||
* @param {*} forcedColor forcedColor | ||
*/,c.setColor=function setColor(a,b){return this.forcedColors[(0,_stringifyAndTrim.default)(a)]=b,this}/** | ||
*/,c.setColor=function c(a,b){return this.forcedColors[(0,_stringifyAndTrim.default)(a)]=b,this}/** | ||
* Get a mapping of data values to colors | ||
* @returns an object where the key is the data value and the value is the hex color code | ||
*/,c.getColorMap=function getColorMap(){var a=this,b={},c=this.colors.length;return Object.keys(this.seen).forEach(function(d){b[d]=a.colors[a.seen[d]%c]}),_extends({},b,this.forcedColors,this.parentForcedColors)},b}(_core.ExtensibleFunction);exports.default=CategoricalColorScale; | ||
*/,c.getColorMap=function d(){var a=this,b={},c=this.colors.length;return Object.keys(this.seen).forEach(function(d){b[d]=a.colors[a.seen[d]%c]}),_extends({},b,this.forcedColors,this.parentForcedColors)},b}(_core.ExtensibleFunction);exports.default=CategoricalColorScale; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _core=require("@superset-ui/core");exports.__esModule=!0,exports.default=void 0;function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var ColorSchemeRegistry=/*#__PURE__*/function(a){function b(){return a.call(this,{name:"ColorScheme",overwritePolicy:_core.OverwritePolicy.WARN,setFirstItemAsDefault:!0})||this}_inheritsLoose(b,a);var c=b.prototype;return c.get=function get(b){return a.prototype.get.call(this,b)},b}(_core.RegistryWithDefaultKey);exports.default=ColorSchemeRegistry; | ||
"use strict";var _core=require("@superset-ui/core");exports.__esModule=!0,exports.default=void 0;function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var ColorSchemeRegistry=/*#__PURE__*/function(a){function b(){return a.call(this,{name:"ColorScheme",overwritePolicy:_core.OverwritePolicy.WARN,setFirstItemAsDefault:!0})||this}_inheritsLoose(b,a);var c=b.prototype;return c.get=function c(b){return a.prototype.get.call(this,b)},b}(_core.RegistryWithDefaultKey);exports.default=ColorSchemeRegistry; |
@@ -1,4 +0,4 @@ | ||
"use strict";exports.__esModule=!0,exports.default=void 0;var _d3Scale=require("d3-scale"),_ColorScheme2=_interopRequireDefault(require("./ColorScheme"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function range(a){for(var b=[],c=0;c<a;c+=1)b.push(c);return b}var SequentialScheme=/*#__PURE__*/function(a){function b(b){var c;c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"isDiverging",void 0);var d=b.isDiverging;return c.isDiverging=void 0!==d&&d,c}_inheritsLoose(b,a);var c=b.prototype;return c.createLinearScale=function createLinearScale(a){void 0===a&&(a=[0,1]);// Create matching domain | ||
"use strict";exports.__esModule=!0,exports.default=void 0;var _d3Scale=require("d3-scale"),_ColorScheme2=_interopRequireDefault(require("./ColorScheme"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function range(a){for(var b=[],c=0;c<a;c+=1)b.push(c);return b}var SequentialScheme=/*#__PURE__*/function(a){function b(b){var c;c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"isDiverging",void 0);var d=b.isDiverging;return c.isDiverging=void 0!==d&&d,c}_inheritsLoose(b,a);var c=b.prototype;return c.createLinearScale=function e(a){void 0===a&&(a=[0,1]);// Create matching domain | ||
// because D3 continuous scale uses piecewise mapping | ||
// between domain and range. | ||
var b=(0,_d3Scale.scaleLinear)().range(a),c=this.colors.length-1,d=range(this.colors.length).map(function(a){return b(a/c)});return(0,_d3Scale.scaleLinear)().domain(d).range(this.colors).clamp(!0)},c.getColors=function getColors(a){if(void 0===a&&(a=this.colors.length),a===this.colors.length)return this.colors;var b=this.createLinearScale(),c=a-1;return range(a).map(function(a){return b(a/c)})},b}(_ColorScheme2.default);exports.default=SequentialScheme; | ||
var b=(0,_d3Scale.scaleLinear)().range(a),c=this.colors.length-1,d=range(this.colors.length).map(function(a){return b(a/c)});return(0,_d3Scale.scaleLinear)().domain(d).range(this.colors).clamp(!0)},c.getColors=function d(a){if(void 0===a&&(a=this.colors.length),a===this.colors.length)return this.colors;var b=this.createLinearScale(),c=a-1;return range(a).map(function(a){return b(a/c)})},b}(_ColorScheme2.default);exports.default=SequentialScheme; |
{ | ||
"name": "@superset-ui/color", | ||
"version": "0.11.0", | ||
"version": "0.11.3", | ||
"description": "Superset UI color", | ||
@@ -33,4 +33,5 @@ "sideEffects": false, | ||
"peerDependencies": { | ||
"@superset-ui/core": "^0.10.0" | ||
} | ||
"@superset-ui/core": "^0.11.0" | ||
}, | ||
"gitHead": "d7faf80543e315c578a8538976b59b4c2dd76397" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
54563
54
0