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

@vx/legend

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/legend - npm Package Compare versions

Comparing version 0.0.179 to 0.0.181

27

build/index.js

@@ -61,2 +61,29 @@ 'use strict';

var _LegendItem = require('./legends/LegendItem');
Object.defineProperty(exports, 'LegendItem', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_LegendItem).default;
}
});
var _LegendLabel = require('./legends/LegendLabel');
Object.defineProperty(exports, 'LegendLabel', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_LegendLabel).default;
}
});
var _LegendShape = require('./legends/LegendShape');
Object.defineProperty(exports, 'LegendShape', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_LegendShape).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

7

build/legends/Legend.js

@@ -62,3 +62,4 @@ 'use strict';

labelFormat: _propTypes2.default.func,
labelTransform: _propTypes2.default.func
labelTransform: _propTypes2.default.func,
children: _propTypes2.default.func
};

@@ -104,6 +105,8 @@

itemDirection = _ref$itemDirection === undefined ? 'row' : _ref$itemDirection,
restProps = _objectWithoutProperties(_ref, ['className', 'style', 'shapeStyle', 'scale', 'shape', 'domain', 'fill', 'size', 'labelFormat', 'labelTransform', 'shapeWidth', 'shapeHeight', 'shapeMargin', 'labelAlign', 'labelFlex', 'labelMargin', 'itemMargin', 'direction', 'itemDirection']);
children = _ref.children,
restProps = _objectWithoutProperties(_ref, ['className', 'style', 'shapeStyle', 'scale', 'shape', 'domain', 'fill', 'size', 'labelFormat', 'labelTransform', 'shapeWidth', 'shapeHeight', 'shapeMargin', 'labelAlign', 'labelFlex', 'labelMargin', 'itemMargin', 'direction', 'itemDirection', 'children']);
domain = domain || scale.domain();
var labels = domain.map(labelTransform({ scale: scale, labelFormat: labelFormat }));
if (children) return children(labels);
return _react2.default.createElement(

@@ -110,0 +113,0 @@ 'div',

@@ -19,6 +19,2 @@ 'use strict';

var _additionalProps = require('../util/additionalProps');
var _additionalProps2 = _interopRequireDefault(_additionalProps);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -30,12 +26,18 @@

flexDirection: _propTypes2.default.string,
margin: _propTypes2.default.string,
label: _propTypes2.default.object.isRequired
alignItems: _propTypes2.default.string,
margin: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
children: _propTypes2.default.any
};
function LegendItem(_ref) {
var children = _ref.children,
flexDirection = _ref.flexDirection,
margin = _ref.margin,
label = _ref.label,
restProps = _objectWithoutProperties(_ref, ['children', 'flexDirection', 'margin', 'label']);
var _ref$flexDirection = _ref.flexDirection,
flexDirection = _ref$flexDirection === undefined ? 'row' : _ref$flexDirection,
_ref$alignItems = _ref.alignItems,
alignItems = _ref$alignItems === undefined ? 'center' : _ref$alignItems,
_ref$margin = _ref.margin,
margin = _ref$margin === undefined ? '0' : _ref$margin,
_ref$display = _ref.display,
display = _ref$display === undefined ? 'flex' : _ref$display,
children = _ref.children,
restProps = _objectWithoutProperties(_ref, ['flexDirection', 'alignItems', 'margin', 'display', 'children']);

@@ -47,10 +49,10 @@ return _react2.default.createElement(

style: {
display: 'flex',
alignItems: 'center',
display: display,
alignItems: alignItems,
flexDirection: flexDirection,
margin: margin
}
}, (0, _additionalProps2.default)(restProps, label)),
}, restProps),
children
);
}

@@ -19,6 +19,7 @@ 'use strict';

LegendLabel.propTypes = {
align: _propTypes2.default.string.isRequired,
flex: _propTypes2.default.string,
label: _propTypes2.default.string.isRequired,
margin: _propTypes2.default.string.isRequired
align: _propTypes2.default.string,
label: _propTypes2.default.any,
flex: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
margin: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
children: _propTypes2.default.any
};

@@ -30,4 +31,7 @@

label = _ref.label,
margin = _ref.margin,
align = _ref.align;
_ref$margin = _ref.margin,
margin = _ref$margin === undefined ? '5px 0' : _ref$margin,
_ref$align = _ref.align,
align = _ref$align === undefined ? 'left' : _ref$align,
children = _ref.children;

@@ -45,4 +49,4 @@ return _react2.default.createElement(

},
label
children || label
);
}

@@ -6,16 +6,2 @@ import React from 'react';

function callOrValue(maybeFn, data) {
if (typeof maybeFn === 'function') {
return maybeFn(data);
}
return maybeFn;
}
function additionalProps(restProps, data) {
return Object.keys(restProps).reduce(function (ret, cur) {
ret[cur] = callOrValue(restProps[cur], data);
return ret;
}, {});
}
var _extends = Object.assign || function (target) {

@@ -87,12 +73,18 @@ for (var i = 1; i < arguments.length; i++) {

flexDirection: PropTypes.string,
margin: PropTypes.string,
label: PropTypes.object.isRequired
alignItems: PropTypes.string,
margin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
children: PropTypes.any
};
function LegendItem(_ref) {
var children = _ref.children,
flexDirection = _ref.flexDirection,
margin = _ref.margin,
label = _ref.label,
restProps = objectWithoutProperties(_ref, ['children', 'flexDirection', 'margin', 'label']);
var _ref$flexDirection = _ref.flexDirection,
flexDirection = _ref$flexDirection === undefined ? 'row' : _ref$flexDirection,
_ref$alignItems = _ref.alignItems,
alignItems = _ref$alignItems === undefined ? 'center' : _ref$alignItems,
_ref$margin = _ref.margin,
margin = _ref$margin === undefined ? '0' : _ref$margin,
_ref$display = _ref.display,
display = _ref$display === undefined ? 'flex' : _ref$display,
children = _ref.children,
restProps = objectWithoutProperties(_ref, ['flexDirection', 'alignItems', 'margin', 'display', 'children']);

@@ -104,8 +96,8 @@ return React.createElement(

style: {
display: 'flex',
alignItems: 'center',
display: display,
alignItems: alignItems,
flexDirection: flexDirection,
margin: margin
}
}, additionalProps(restProps, label)),
}, restProps),
children

@@ -116,6 +108,7 @@ );

LegendLabel.propTypes = {
align: PropTypes.string.isRequired,
flex: PropTypes.string,
label: PropTypes.string.isRequired,
margin: PropTypes.string.isRequired
align: PropTypes.string,
label: PropTypes.any,
flex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
margin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
children: PropTypes.any
};

@@ -127,4 +120,7 @@

label = _ref.label,
margin = _ref.margin,
align = _ref.align;
_ref$margin = _ref.margin,
margin = _ref$margin === undefined ? '5px 0' : _ref$margin,
_ref$align = _ref.align,
align = _ref$align === undefined ? 'left' : _ref$align,
children = _ref.children;

@@ -142,3 +138,3 @@ return React.createElement(

},
label
children || label
);

@@ -300,3 +296,4 @@ }

labelFormat: PropTypes.func,
labelTransform: PropTypes.func
labelTransform: PropTypes.func,
children: PropTypes.func
};

@@ -342,6 +339,8 @@

itemDirection = _ref$itemDirection === undefined ? 'row' : _ref$itemDirection,
restProps = objectWithoutProperties(_ref, ['className', 'style', 'shapeStyle', 'scale', 'shape', 'domain', 'fill', 'size', 'labelFormat', 'labelTransform', 'shapeWidth', 'shapeHeight', 'shapeMargin', 'labelAlign', 'labelFlex', 'labelMargin', 'itemMargin', 'direction', 'itemDirection']);
children = _ref.children,
restProps = objectWithoutProperties(_ref, ['className', 'style', 'shapeStyle', 'scale', 'shape', 'domain', 'fill', 'size', 'labelFormat', 'labelTransform', 'shapeWidth', 'shapeHeight', 'shapeMargin', 'labelAlign', 'labelFlex', 'labelMargin', 'itemMargin', 'direction', 'itemDirection', 'children']);
domain = domain || scale.domain();
var labels = domain.map(labelTransform({ scale: scale, labelFormat: labelFormat }));
if (children) return children(labels);
return React.createElement(

@@ -681,2 +680,2 @@ 'div',

export { Legend, LegendQuantile, LegendLinear, LegendOrdinal, LegendThreshold, LegendSize };
export { Legend, LegendQuantile, LegendLinear, LegendOrdinal, LegendThreshold, LegendSize, LegendItem, LegendLabel, LegendShape };

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

!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("react"),require("prop-types"),require("@vx/group"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@vx/group","classnames"],a):a(e.vx=e.vx||{},e.React,e.PropTypes,e.vx,e.classNames)}(this,function(e,P,a,o,U){"use strict";P=P&&P.hasOwnProperty("default")?P.default:P,a=a&&a.hasOwnProperty("default")?a.default:a,U=U&&U.hasOwnProperty("default")?U.default:U;var k=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e},H=function(e,a){var r={};for(var l in e)0<=a.indexOf(l)||Object.prototype.hasOwnProperty.call(e,l)&&(r[l]=e[l]);return r},y=function(e,a){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,a){var r=[],l=!0,t=!1,n=void 0;try{for(var i,o=e[Symbol.iterator]();!(l=(i=o.next()).done)&&(r.push(i.value),!a||r.length!==a);l=!0);}catch(e){t=!0,n=e}finally{try{!l&&o.return&&o.return()}finally{if(t)throw n}}return r}(e,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")};function W(e){var t,n,a=e.children,r=e.flexDirection,l=e.margin,i=e.label,o=H(e,["children","flexDirection","margin","label"]);return P.createElement("div",k({className:"vx-legend-item",style:{display:"flex",alignItems:"center",flexDirection:r,margin:l}},(t=o,n=i,Object.keys(t).reduce(function(e,a){var r,l;return e[a]=(r=t[a],l=n,"function"==typeof r?r(l):r),e},{}))),a)}function I(e){var a=e.flex,r=void 0===a?"1":a,l=e.label,t=e.margin,n=e.align;return P.createElement("div",{className:"vx-legend-label",style:{justifyContent:n,display:"flex",flex:r,margin:t}},l)}function w(e){var a=e.fill,r=e.width,l=e.height,t=e.style;return P.createElement("div",{style:k({width:r,height:l,background:a},t)})}function E(e){var a=e.fill,r=e.width,l=e.height,t=e.style;"string"==typeof r&&(r=0),"string"==typeof l&&(l=0);var n=Math.max(r,l),i=n/2;return P.createElement("svg",{width:n,height:n},P.createElement(o.Group,{top:i,left:i},P.createElement("circle",{r:i,fill:a,style:t})))}function _(e){return e&&e.value?e.value:e}function C(e){var a,r,l,t,n,i,o,s,c,m,u,d,f,p=e.shape,b=void 0===p?w:p,v=e.width,y=e.height,h=e.margin,g=e.label,x=e.fill,T=e.size,F=e.shapeStyle;return P.createElement("div",{className:"vx-legend-shape",style:{display:"flex",width:T?T(k({},g)):v,height:T?T(k({},g)):y,margin:h}},(r=(a={shape:b,label:g,width:v,height:y,fill:x,shapeStyle:F}).shape,l=void 0===r?"rect":r,t=a.fill,n=void 0===t?_:t,i=a.size,o=void 0===i?_:i,s=a.width,c=a.height,m=a.label,u=a.shapeStyle,d=void 0===u?function(e){}:u,f={width:s,height:c,label:m,fill:n(k({},m)),size:o(k({},m)),style:d(k({},m))},"string"==typeof l?"rect"===l?P.createElement(w,f):P.createElement(E,f):P.isValidElement(l)?P.cloneElement(l,f):P.createElement(l,f)))}W.propTypes={flexDirection:a.string,margin:a.string,label:a.object.isRequired},I.propTypes={align:a.string.isRequired,flex:a.string,label:a.string.isRequired,margin:a.string.isRequired},w.propTypes={fill:a.any,width:a.oneOfType([a.number,a.string]),height:a.oneOfType([a.number,a.string]),style:a.object},E.propTypes={fill:a.any,width:a.oneOfType([a.number,a.string]),height:a.oneOfType([a.number,a.string]),style:a.object},C.propTypes={shape:a.any,width:a.any,height:a.any,margin:a.any,label:a.any,fill:a.any,size:a.any,shapeStyle:a.any},h.propTypes={className:a.string,style:a.any,domain:a.array,scale:a.oneOfType([a.func,a.object]).isRequired,shapeWidth:a.oneOfType([a.number,a.string]),shapeHeight:a.oneOfType([a.number,a.string]),shapeMargin:a.any,labelAlign:a.string,labelFlex:a.string,labelMargin:a.string,itemMargin:a.string,direction:a.string,itemDirection:a.string,fill:a.any,size:a.any,shape:a.any,shapeStyle:a.any,labelFormat:a.func,labelTransform:a.func};var G={display:"flex"};function h(e){var a=e.className,r=e.style,l=void 0===r?G:r,t=e.shapeStyle,n=e.scale,i=e.shape,o=e.domain,s=e.fill,c=void 0===s?_:s,m=e.size,u=void 0===m?_:m,d=e.labelFormat,f=void 0===d?_:d,p=e.labelTransform,b=void 0===p?Q:p,v=e.shapeWidth,y=void 0===v?15:v,h=e.shapeHeight,g=void 0===h?15:h,x=e.shapeMargin,T=void 0===x?"2px 4px 2px 0":x,F=e.labelAlign,w=void 0===F?"left":F,E=e.labelFlex,O=void 0===E?"1":E,D=e.labelMargin,q=void 0===D?"0 4px":D,L=e.itemMargin,j=void 0===L?"0":L,M=e.direction,S=void 0===M?"column":M,R=e.itemDirection,z=void 0===R?"row":R,N=H(e,["className","style","shapeStyle","scale","shape","domain","fill","size","labelFormat","labelTransform","shapeWidth","shapeHeight","shapeMargin","labelAlign","labelFlex","labelMargin","itemMargin","direction","itemDirection"]),A=(o=o||n.domain()).map(b({scale:n,labelFormat:f}));return P.createElement("div",{className:U("vx-legend",a),style:k({},l,{flexDirection:S})},A.map(function(e,a){var r=e.text;return P.createElement(W,k({key:"legend-"+e+"-"+a,margin:j,flexDirection:z,label:e},N),P.createElement(C,{shape:i,height:g,width:y,margin:T,label:e,fill:c,size:u,shapeStyle:t}),P.createElement(I,{label:r,flex:O,margin:q,align:w}))}))}function Q(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{datum:e,index:a,text:""+l(e,a),value:r(e)}}}function r(e){var s,a=e.scale,r=e.domain,l=e.labelFormat,t=void 0===l?function(e){return e}:l,n=e.labelTransform,i=e.labelDelimiter,o=void 0===i?"-":i,c=H(e,["scale","domain","labelFormat","labelTransform","labelDelimiter"]);return r=r||a.range(),n=n||(s={labelDelimiter:o}.labelDelimiter,function(e){var i=e.scale,o=e.labelFormat;return function(e,a){var r=i.invertExtent(e),l=y(r,2),t=l[0],n=l[1];return{extent:[t,n],text:o(t,a)+" "+s+" "+o(n,a),value:i(t),datum:e,index:a}}}),P.createElement(h,k({scale:a,domain:r,labelFormat:t,labelTransform:n},c))}function l(e){var a,r,l,t,n,i=e.scale,o=e.domain,s=e.steps,c=void 0===s?5:s,m=e.labelFormat,u=void 0===m?function(e){return e}:m,d=e.labelTransform,f=void 0===d?b:d,p=H(e,["scale","domain","steps","labelFormat","labelTransform"]);return o=o||(r=(a={steps:c,scale:i}).steps,l=a.scale.domain(),t=l[0],n=(l[l.length-1]-t)/(r-1),new Array(r).fill(1).reduce(function(e,a,r){return e.push(t+r*n),e},[])),P.createElement(h,k({scale:i,domain:o,labelFormat:u,labelTransform:f},p))}function b(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{text:""+l(e,a),value:r(e)}}}function t(e){var a=e.scale,r=e.domain,l=e.labelTransform,t=void 0===l?s:l,n=e.labelFormat,i=void 0===n?_:n,o=H(e,["scale","domain","labelTransform","labelFormat"]);return P.createElement(h,k({scale:a,domain:r,labelFormat:i,labelTransform:t},o))}function s(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{datum:e,index:a,text:""+l(e,a),value:r(e)}}}function n(e){var a,u,d,f,r=e.scale,l=e.domain,t=e.labelFormat,n=void 0===t?function(e){return e}:t,i=e.labelTransform,o=e.labelDelimiter,s=void 0===o?"to":o,c=e.labelLower,m=void 0===c?"Less than ":c,p=e.labelUpper,b=void 0===p?"More than ":p,v=H(e,["scale","domain","labelFormat","labelTransform","labelDelimiter","labelLower","labelUpper"]);return l=l||r.range(),i=i||(u=(a={labelDelimiter:s,labelLower:m,labelUpper:b}).labelDelimiter,d=a.labelLower,f=a.labelUpper,function(e){var s=e.scale,c=e.labelFormat;function m(e,a,r){var l=e(a,r);return 0===l?"0":l||""}return function(e,a){var r=s.invertExtent(e),l=y(r,2),t=l[0],n=l[1],i=" "+u+" ",o=void 0;return 0===t||t||0!==n&&!n?0!==t&&!t||0!==n&&!n?n||0!==t&&!t||(o=t+s.domain()[1],n=t,t=void 0,i=f):o=t:(o=n-1,i=d),{extent:[t,n],text:""+m(c,t,a)+i+m(c,n,a),value:s(o),datum:e,index:a}}}),P.createElement(h,k({scale:r,domain:l,labelFormat:n,labelTransform:i},v))}function v(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{text:""+l(e,a),value:r(e),datum:e,index:a}}}r.propTypes={scale:a.func.isRequired,domain:a.array,labelFormat:a.func,labelTransform:a.func,labelDelimiter:a.string},l.propTypes={scale:a.func.isRequired,domain:a.array,steps:a.number,labelFormat:a.func,labelTransform:a.func},t.propTypes={scale:a.func.isRequired,domain:a.array,labelTransform:a.func,labelFormat:a.func},n.propTypes={scale:a.func.isRequired,domain:a.array,labelTransform:a.func,labelFormat:a.func,labelDelimiter:a.string,labelLower:a.string,labelUpper:a.string},e.Legend=h,e.LegendQuantile=r,e.LegendLinear=l,e.LegendOrdinal=t,e.LegendThreshold=n,e.LegendSize=function(e){var a,r,l,t,n,i=e.scale,o=e.domain,s=e.steps,c=void 0===s?5:s,m=e.labelFormat,u=void 0===m?function(e){return e}:m,d=e.labelTransform,f=void 0===d?v:d,p=H(e,["scale","domain","steps","labelFormat","labelTransform"]);return o=o||(r=(a={steps:c,scale:i}).steps,l=a.scale.domain(),t=l[0],n=(l[l.length-1]-t)/(r-1),new Array(r).fill(1).reduce(function(e,a,r){return e.push(t+r*n),e},[])),P.createElement(h,k({scale:i,domain:o,labelFormat:u,labelTransform:f},p))},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("react"),require("prop-types"),require("@vx/group"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@vx/group","classnames"],a):a(e.vx=e.vx||{},e.React,e.PropTypes,e.vx,e.classNames)}(this,function(e,R,a,o,U){"use strict";R=R&&R.hasOwnProperty("default")?R.default:R,a=a&&a.hasOwnProperty("default")?a.default:a,U=U&&U.hasOwnProperty("default")?U.default:U;var H=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e},W=function(e,a){var r={};for(var l in e)0<=a.indexOf(l)||Object.prototype.hasOwnProperty.call(e,l)&&(r[l]=e[l]);return r},y=function(e,a){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,a){var r=[],l=!0,n=!1,t=void 0;try{for(var i,o=e[Symbol.iterator]();!(l=(i=o.next()).done)&&(r.push(i.value),!a||r.length!==a);l=!0);}catch(e){n=!0,t=e}finally{try{!l&&o.return&&o.return()}finally{if(n)throw t}}return r}(e,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")};function k(e){var a=e.flexDirection,r=void 0===a?"row":a,l=e.alignItems,n=void 0===l?"center":l,t=e.margin,i=void 0===t?"0":t,o=e.display,s=void 0===o?"flex":o,c=e.children,m=W(e,["flexDirection","alignItems","margin","display","children"]);return R.createElement("div",H({className:"vx-legend-item",style:{display:s,alignItems:n,flexDirection:r,margin:i}},m),c)}function _(e){var a=e.flex,r=void 0===a?"1":a,l=e.label,n=e.margin,t=void 0===n?"5px 0":n,i=e.align,o=void 0===i?"left":i,s=e.children;return R.createElement("div",{className:"vx-legend-label",style:{justifyContent:o,display:"flex",flex:r,margin:t}},s||l)}function w(e){var a=e.fill,r=e.width,l=e.height,n=e.style;return R.createElement("div",{style:H({width:r,height:l,background:a},n)})}function E(e){var a=e.fill,r=e.width,l=e.height,n=e.style;"string"==typeof r&&(r=0),"string"==typeof l&&(l=0);var t=Math.max(r,l),i=t/2;return R.createElement("svg",{width:t,height:t},R.createElement(o.Group,{top:i,left:i},R.createElement("circle",{r:i,fill:a,style:n})))}function C(e){return e&&e.value?e.value:e}function G(e){var a,r,l,n,t,i,o,s,c,m,d,u,f,p=e.shape,b=void 0===p?w:p,v=e.width,y=e.height,h=e.margin,g=e.label,x=e.fill,T=e.size,F=e.shapeStyle;return R.createElement("div",{className:"vx-legend-shape",style:{display:"flex",width:T?T(H({},g)):v,height:T?T(H({},g)):y,margin:h}},(r=(a={shape:b,label:g,width:v,height:y,fill:x,shapeStyle:F}).shape,l=void 0===r?"rect":r,n=a.fill,t=void 0===n?C:n,i=a.size,o=void 0===i?C:i,s=a.width,c=a.height,m=a.label,d=a.shapeStyle,u=void 0===d?function(e){}:d,f={width:s,height:c,label:m,fill:t(H({},m)),size:o(H({},m)),style:u(H({},m))},"string"==typeof l?"rect"===l?R.createElement(w,f):R.createElement(E,f):R.isValidElement(l)?R.cloneElement(l,f):R.createElement(l,f)))}k.propTypes={flexDirection:a.string,alignItems:a.string,margin:a.oneOfType([a.string,a.number]),children:a.any},_.propTypes={align:a.string,label:a.any,flex:a.oneOfType([a.string,a.number]),margin:a.oneOfType([a.string,a.number]),children:a.any},w.propTypes={fill:a.any,width:a.oneOfType([a.number,a.string]),height:a.oneOfType([a.number,a.string]),style:a.object},E.propTypes={fill:a.any,width:a.oneOfType([a.number,a.string]),height:a.oneOfType([a.number,a.string]),style:a.object},G.propTypes={shape:a.any,width:a.any,height:a.any,margin:a.any,label:a.any,fill:a.any,size:a.any,shapeStyle:a.any},h.propTypes={className:a.string,style:a.any,domain:a.array,scale:a.oneOfType([a.func,a.object]).isRequired,shapeWidth:a.oneOfType([a.number,a.string]),shapeHeight:a.oneOfType([a.number,a.string]),shapeMargin:a.any,labelAlign:a.string,labelFlex:a.string,labelMargin:a.string,itemMargin:a.string,direction:a.string,itemDirection:a.string,fill:a.any,size:a.any,shape:a.any,shapeStyle:a.any,labelFormat:a.func,labelTransform:a.func,children:a.func};var Q={display:"flex"};function h(e){var a=e.className,r=e.style,l=void 0===r?Q:r,n=e.shapeStyle,t=e.scale,i=e.shape,o=e.domain,s=e.fill,c=void 0===s?C:s,m=e.size,d=void 0===m?C:m,u=e.labelFormat,f=void 0===u?C:u,p=e.labelTransform,b=void 0===p?V:p,v=e.shapeWidth,y=void 0===v?15:v,h=e.shapeHeight,g=void 0===h?15:h,x=e.shapeMargin,T=void 0===x?"2px 4px 2px 0":x,F=e.labelAlign,w=void 0===F?"left":F,E=e.labelFlex,O=void 0===E?"1":E,D=e.labelMargin,L=void 0===D?"0 4px":D,M=e.itemMargin,S=void 0===M?"0":M,j=e.direction,q=void 0===j?"column":j,z=e.itemDirection,N=void 0===z?"row":z,A=e.children,P=W(e,["className","style","shapeStyle","scale","shape","domain","fill","size","labelFormat","labelTransform","shapeWidth","shapeHeight","shapeMargin","labelAlign","labelFlex","labelMargin","itemMargin","direction","itemDirection","children"]),I=(o=o||t.domain()).map(b({scale:t,labelFormat:f}));return A?A(I):R.createElement("div",{className:U("vx-legend",a),style:H({},l,{flexDirection:q})},I.map(function(e,a){var r=e.text;return R.createElement(k,H({key:"legend-"+e+"-"+a,margin:S,flexDirection:N,label:e},P),R.createElement(G,{shape:i,height:g,width:y,margin:T,label:e,fill:c,size:d,shapeStyle:n}),R.createElement(_,{label:r,flex:O,margin:L,align:w}))}))}function V(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{datum:e,index:a,text:""+l(e,a),value:r(e)}}}function r(e){var s,a=e.scale,r=e.domain,l=e.labelFormat,n=void 0===l?function(e){return e}:l,t=e.labelTransform,i=e.labelDelimiter,o=void 0===i?"-":i,c=W(e,["scale","domain","labelFormat","labelTransform","labelDelimiter"]);return r=r||a.range(),t=t||(s={labelDelimiter:o}.labelDelimiter,function(e){var i=e.scale,o=e.labelFormat;return function(e,a){var r=i.invertExtent(e),l=y(r,2),n=l[0],t=l[1];return{extent:[n,t],text:o(n,a)+" "+s+" "+o(t,a),value:i(n),datum:e,index:a}}}),R.createElement(h,H({scale:a,domain:r,labelFormat:n,labelTransform:t},c))}function l(e){var a,r,l,n,t,i=e.scale,o=e.domain,s=e.steps,c=void 0===s?5:s,m=e.labelFormat,d=void 0===m?function(e){return e}:m,u=e.labelTransform,f=void 0===u?b:u,p=W(e,["scale","domain","steps","labelFormat","labelTransform"]);return o=o||(r=(a={steps:c,scale:i}).steps,l=a.scale.domain(),n=l[0],t=(l[l.length-1]-n)/(r-1),new Array(r).fill(1).reduce(function(e,a,r){return e.push(n+r*t),e},[])),R.createElement(h,H({scale:i,domain:o,labelFormat:d,labelTransform:f},p))}function b(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{text:""+l(e,a),value:r(e)}}}function n(e){var a=e.scale,r=e.domain,l=e.labelTransform,n=void 0===l?s:l,t=e.labelFormat,i=void 0===t?C:t,o=W(e,["scale","domain","labelTransform","labelFormat"]);return R.createElement(h,H({scale:a,domain:r,labelFormat:i,labelTransform:n},o))}function s(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{datum:e,index:a,text:""+l(e,a),value:r(e)}}}function t(e){var a,d,u,f,r=e.scale,l=e.domain,n=e.labelFormat,t=void 0===n?function(e){return e}:n,i=e.labelTransform,o=e.labelDelimiter,s=void 0===o?"to":o,c=e.labelLower,m=void 0===c?"Less than ":c,p=e.labelUpper,b=void 0===p?"More than ":p,v=W(e,["scale","domain","labelFormat","labelTransform","labelDelimiter","labelLower","labelUpper"]);return l=l||r.range(),i=i||(d=(a={labelDelimiter:s,labelLower:m,labelUpper:b}).labelDelimiter,u=a.labelLower,f=a.labelUpper,function(e){var s=e.scale,c=e.labelFormat;function m(e,a,r){var l=e(a,r);return 0===l?"0":l||""}return function(e,a){var r=s.invertExtent(e),l=y(r,2),n=l[0],t=l[1],i=" "+d+" ",o=void 0;return 0===n||n||0!==t&&!t?0!==n&&!n||0!==t&&!t?t||0!==n&&!n||(o=n+s.domain()[1],t=n,n=void 0,i=f):o=n:(o=t-1,i=u),{extent:[n,t],text:""+m(c,n,a)+i+m(c,t,a),value:s(o),datum:e,index:a}}}),R.createElement(h,H({scale:r,domain:l,labelFormat:t,labelTransform:i},v))}function v(e){var r=e.scale,l=e.labelFormat;return function(e,a){return{text:""+l(e,a),value:r(e),datum:e,index:a}}}r.propTypes={scale:a.func.isRequired,domain:a.array,labelFormat:a.func,labelTransform:a.func,labelDelimiter:a.string},l.propTypes={scale:a.func.isRequired,domain:a.array,steps:a.number,labelFormat:a.func,labelTransform:a.func},n.propTypes={scale:a.func.isRequired,domain:a.array,labelTransform:a.func,labelFormat:a.func},t.propTypes={scale:a.func.isRequired,domain:a.array,labelTransform:a.func,labelFormat:a.func,labelDelimiter:a.string,labelLower:a.string,labelUpper:a.string},e.Legend=h,e.LegendQuantile=r,e.LegendLinear=l,e.LegendOrdinal=n,e.LegendThreshold=t,e.LegendSize=function(e){var a,r,l,n,t,i=e.scale,o=e.domain,s=e.steps,c=void 0===s?5:s,m=e.labelFormat,d=void 0===m?function(e){return e}:m,u=e.labelTransform,f=void 0===u?v:u,p=W(e,["scale","domain","steps","labelFormat","labelTransform"]);return o=o||(r=(a={steps:c,scale:i}).steps,l=a.scale.domain(),n=l[0],t=(l[l.length-1]-n)/(r-1),new Array(r).fill(1).reduce(function(e,a,r){return e.push(n+r*t),e},[])),R.createElement(h,H({scale:i,domain:o,labelFormat:d,labelTransform:f},p))},e.LegendItem=k,e.LegendLabel=_,e.LegendShape=G,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@vx/legend",
"version": "0.0.179",
"version": "0.0.181",
"description": "vx legend",

@@ -5,0 +5,0 @@ "sideEffects": false,

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