@vx/legend
Advanced tools
Comparing version
@@ -51,4 +51,5 @@ import _pt from "prop-types"; | ||
itemDirection = _ref$itemDirection === void 0 ? 'row' : _ref$itemDirection, | ||
legendLabelProps = _ref.legendLabelProps, | ||
children = _ref.children, | ||
legendItemProps = _objectWithoutPropertiesLoose(_ref, ["className", "style", "scale", "shape", "domain", "fill", "size", "labelFormat", "labelTransform", "shapeWidth", "shapeHeight", "shapeMargin", "shapeStyle", "labelAlign", "labelFlex", "labelMargin", "itemMargin", "direction", "itemDirection", "children"]); | ||
legendItemProps = _objectWithoutPropertiesLoose(_ref, ["className", "style", "scale", "shape", "domain", "fill", "size", "labelFormat", "labelTransform", "shapeWidth", "shapeHeight", "shapeMargin", "shapeStyle", "labelAlign", "labelFlex", "labelMargin", "itemMargin", "direction", "itemDirection", "legendLabelProps", "children"]); | ||
@@ -80,2 +81,4 @@ // `Scale extends ScaleType` constraint is tricky | ||
margin: shapeMargin, | ||
item: domain[i], | ||
itemIndex: i, | ||
label: label, | ||
@@ -85,3 +88,3 @@ fill: fill, | ||
shapeStyle: shapeStyle | ||
}), /*#__PURE__*/React.createElement(LegendLabel, { | ||
}), /*#__PURE__*/React.createElement(LegendLabel, _extends({ | ||
label: label.text, | ||
@@ -91,3 +94,3 @@ flex: labelFlex, | ||
align: labelAlign | ||
})); | ||
}, legendLabelProps))); | ||
})); | ||
@@ -94,0 +97,0 @@ } |
@@ -15,2 +15,4 @@ import _pt from "prop-types"; | ||
label = _ref.label, | ||
item = _ref.item, | ||
itemIndex = _ref.itemIndex, | ||
fill = _ref.fill, | ||
@@ -29,2 +31,4 @@ size = _ref.size, | ||
shape: shape, | ||
item: item, | ||
itemIndex: itemIndex, | ||
label: label, | ||
@@ -38,2 +42,3 @@ width: width, | ||
LegendShape.propTypes = { | ||
itemIndex: _pt.number.isRequired, | ||
margin: _pt.oneOfType([_pt.string, _pt.number]), | ||
@@ -40,0 +45,0 @@ fill: _pt.func, |
@@ -21,3 +21,3 @@ import _pt from "prop-types"; | ||
r: radius, | ||
fill: String(fill), | ||
fill: fill, | ||
style: style | ||
@@ -24,0 +24,0 @@ }))); |
@@ -6,2 +6,3 @@ 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); } | ||
import CircleShape from '../shapes/Circle'; | ||
import LineShape from '../shapes/Line'; | ||
@@ -22,2 +23,4 @@ var NO_OP = function NO_OP() { | ||
label = _ref.label, | ||
item = _ref.item, | ||
itemIndex = _ref.itemIndex, | ||
_ref$shapeStyle = _ref.shapeStyle, | ||
@@ -28,2 +31,4 @@ shapeStyle = _ref$shapeStyle === void 0 ? NO_OP : _ref$shapeStyle; | ||
height: height, | ||
item: item, | ||
itemIndex: itemIndex, | ||
label: label, | ||
@@ -36,7 +41,11 @@ fill: fill(_extends({}, label)), | ||
if (typeof shape === 'string') { | ||
if (shape === 'rect') { | ||
return /*#__PURE__*/React.createElement(RectShape, props); | ||
if (shape === 'circle') { | ||
return /*#__PURE__*/React.createElement(CircleShape, props); | ||
} | ||
return /*#__PURE__*/React.createElement(CircleShape, props); | ||
if (shape === 'line') { | ||
return /*#__PURE__*/React.createElement(LineShape, props); | ||
} | ||
return /*#__PURE__*/React.createElement(RectShape, props); | ||
} | ||
@@ -43,0 +52,0 @@ |
@@ -10,2 +10,1 @@ export { default as Legend } from './legends/Legend'; | ||
export { default as LegendShape } from './legends/Legend/LegendShape'; | ||
//# sourceMappingURL=index.d.ts.map |
import React from 'react'; | ||
import { LegendLabelProps } from './LegendLabel'; | ||
import { FlexDirection, ScaleType, FormattedLabel, LabelFormatter, LabelFormatterFactory, LegendShape as LegendShapeType } from '../../types'; | ||
@@ -44,4 +45,5 @@ export declare type LegendProps<Datum, Output, Scale = ScaleType<Datum, Output>> = { | ||
labelTransform?: LabelFormatterFactory<Datum, Output, Scale>; | ||
/** Additional props to be set on LegendLabel. */ | ||
legendLabelProps?: Partial<LegendLabelProps>; | ||
}; | ||
export default function Legend<Datum, Output, Scale = ScaleType<Datum, Output>>({ className, style, scale, shape, domain: inputDomain, fill, size, labelFormat, labelTransform, shapeWidth, shapeHeight, shapeMargin, shapeStyle, labelAlign, labelFlex, labelMargin, itemMargin, direction, itemDirection, children, ...legendItemProps }: LegendProps<Datum, Output, Scale>): JSX.Element; | ||
//# sourceMappingURL=index.d.ts.map | ||
export default function Legend<Datum, Output, Scale = ScaleType<Datum, Output>>({ className, style, scale, shape, domain: inputDomain, fill, size, labelFormat, labelTransform, shapeWidth, shapeHeight, shapeMargin, shapeStyle, labelAlign, labelFlex, labelMargin, itemMargin, direction, itemDirection, legendLabelProps, children, ...legendItemProps }: LegendProps<Datum, Output, Scale>): JSX.Element; |
@@ -70,4 +70,5 @@ "use strict"; | ||
itemDirection = _ref$itemDirection === void 0 ? 'row' : _ref$itemDirection, | ||
legendLabelProps = _ref.legendLabelProps, | ||
children = _ref.children, | ||
legendItemProps = _objectWithoutPropertiesLoose(_ref, ["className", "style", "scale", "shape", "domain", "fill", "size", "labelFormat", "labelTransform", "shapeWidth", "shapeHeight", "shapeMargin", "shapeStyle", "labelAlign", "labelFlex", "labelMargin", "itemMargin", "direction", "itemDirection", "children"]); | ||
legendItemProps = _objectWithoutPropertiesLoose(_ref, ["className", "style", "scale", "shape", "domain", "fill", "size", "labelFormat", "labelTransform", "shapeWidth", "shapeHeight", "shapeMargin", "shapeStyle", "labelAlign", "labelFlex", "labelMargin", "itemMargin", "direction", "itemDirection", "legendLabelProps", "children"]); | ||
@@ -99,2 +100,4 @@ // `Scale extends ScaleType` constraint is tricky | ||
margin: shapeMargin, | ||
item: domain[i], | ||
itemIndex: i, | ||
label: label, | ||
@@ -104,3 +107,3 @@ fill: fill, | ||
shapeStyle: shapeStyle | ||
}), /*#__PURE__*/_react.default.createElement(_LegendLabel.default, { | ||
}), /*#__PURE__*/_react.default.createElement(_LegendLabel.default, _extends({ | ||
label: label.text, | ||
@@ -110,3 +113,3 @@ flex: labelFlex, | ||
align: labelAlign | ||
})); | ||
}, legendLabelProps))); | ||
})); | ||
@@ -113,0 +116,0 @@ } |
@@ -11,2 +11,1 @@ import React from 'react'; | ||
export default function LegendItem({ flexDirection, alignItems, margin, display, children, ...restProps }: LegendItemProps & Omit<React.HTMLProps<HTMLDivElement>, keyof LegendItemProps>): JSX.Element; | ||
//# sourceMappingURL=LegendItem.d.ts.map |
import React from 'react'; | ||
export declare type LegendLabelProps = { | ||
export declare type LegendLabelOwnProps = { | ||
align?: string; | ||
@@ -9,3 +9,3 @@ label?: React.ReactNode; | ||
}; | ||
export default function LegendLabel({ flex, label, margin, align, children, ...restProps }: LegendLabelProps & Omit<React.HTMLProps<HTMLDivElement>, keyof LegendLabelProps>): JSX.Element; | ||
//# sourceMappingURL=LegendLabel.d.ts.map | ||
export declare type LegendLabelProps = LegendLabelOwnProps & Omit<React.HTMLProps<HTMLDivElement>, keyof LegendLabelOwnProps>; | ||
export default function LegendLabel({ flex, label, margin, align, children, ...restProps }: LegendLabelProps): JSX.Element; |
@@ -5,2 +5,4 @@ /// <reference types="react" /> | ||
label: FormattedLabel<Data, Output>; | ||
item: Data; | ||
itemIndex: number; | ||
margin?: string | number; | ||
@@ -14,3 +16,2 @@ shape?: LegendShapeType<Data, Output>; | ||
}; | ||
export default function LegendShape<Data, Output>({ shape, width, height, margin, label, fill, size, shapeStyle, }: LegendShapeProps<Data, Output>): JSX.Element; | ||
//# sourceMappingURL=LegendShape.d.ts.map | ||
export default function LegendShape<Data, Output>({ shape, width, height, margin, label, item, itemIndex, fill, size, shapeStyle, }: LegendShapeProps<Data, Output>): JSX.Element; |
@@ -25,2 +25,4 @@ "use strict"; | ||
label = _ref.label, | ||
item = _ref.item, | ||
itemIndex = _ref.itemIndex, | ||
fill = _ref.fill, | ||
@@ -39,2 +41,4 @@ size = _ref.size, | ||
shape: shape, | ||
item: item, | ||
itemIndex: itemIndex, | ||
label: label, | ||
@@ -49,2 +53,3 @@ width: width, | ||
LegendShape.propTypes = { | ||
itemIndex: _propTypes.default.number.isRequired, | ||
margin: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]), | ||
@@ -51,0 +56,0 @@ fill: _propTypes.default.func, |
@@ -10,2 +10,1 @@ /// <reference types="react" /> | ||
export default function Linear<Output>({ scale, domain: inputDomain, steps, ...restProps }: LegendLinearProps<Output>): JSX.Element; | ||
//# sourceMappingURL=Linear.d.ts.map |
@@ -11,2 +11,1 @@ /// <reference types="react" /> | ||
}, Output>(props: LegendOrdinalProps<Input, Output>): JSX.Element; | ||
//# sourceMappingURL=Ordinal.d.ts.map |
@@ -11,2 +11,1 @@ /// <reference types="react" /> | ||
export default function Quantile<Output>({ domain: inputDomain, scale, labelFormat, labelTransform: inputLabelTransform, labelDelimiter, ...restProps }: LegendQuantileProps<Output>): JSX.Element; | ||
//# sourceMappingURL=Quantile.d.ts.map |
@@ -8,2 +8,1 @@ /// <reference types="react" /> | ||
export default function Size<Datum>({ scale, domain: inputDomain, steps, labelFormat, labelTransform, ...restProps }: LegendSizeProps<Datum>): JSX.Element; | ||
//# sourceMappingURL=Size.d.ts.map |
@@ -11,2 +11,1 @@ /// <reference types="react" /> | ||
export default function Threshold<Datum extends StringNumberDate, Output>({ scale, domain: inputDomain, labelFormat, labelTransform: inputLabelTransform, labelDelimiter, labelLower, labelUpper, ...restProps }: LegendThresholdProps<Datum, Output>): JSX.Element; | ||
//# sourceMappingURL=Threshold.d.ts.map |
@@ -9,2 +9,1 @@ import React from 'react'; | ||
export default function ShapeCircle({ fill, width, height, style }: ShapeCircleProps): JSX.Element; | ||
//# sourceMappingURL=Circle.d.ts.map |
@@ -31,3 +31,3 @@ "use strict"; | ||
r: radius, | ||
fill: String(fill), | ||
fill: fill, | ||
style: style | ||
@@ -34,0 +34,0 @@ }))); |
@@ -9,2 +9,1 @@ import React from 'react'; | ||
export default function ShapeRect({ fill, width, height, style }: ShapeRectProps): JSX.Element; | ||
//# sourceMappingURL=Rect.d.ts.map |
@@ -25,3 +25,5 @@ /// <reference types="react" /> | ||
height?: string | number; | ||
label?: FormattedLabel<Data, Output>; | ||
label: FormattedLabel<Data, Output>; | ||
item: Data; | ||
itemIndex: number; | ||
fill?: string; | ||
@@ -31,3 +33,3 @@ size?: string | number; | ||
}; | ||
export declare type LegendShape<Data, Output> = 'rect' | 'circle' | React.FC<RenderShapeProvidedProps<Data, Output>> | React.ComponentClass<RenderShapeProvidedProps<Data, Output>>; | ||
export declare type LegendShape<Data, Output> = 'rect' | 'circle' | 'line' | React.FC<RenderShapeProvidedProps<Data, Output>> | React.ComponentClass<RenderShapeProvidedProps<Data, Output>>; | ||
export declare type FillAccessor<Datum, Output> = (label: FormattedLabel<Datum, Output>) => string | undefined; | ||
@@ -37,2 +39,1 @@ export declare type SizeAccessor<Datum, Output> = (label: FormattedLabel<Datum, Output>) => string | number | undefined; | ||
export declare type FlexDirection = 'inherit' | 'initial' | 'revert' | 'unset' | 'column' | 'column-reverse' | 'row' | 'row-reverse'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,2 +7,1 @@ import { LabelFormatter, ScaleType, ItemTransformer } from '../types'; | ||
}): ItemTransformer<Datum, Output>; | ||
//# sourceMappingURL=labelTransformFactory.d.ts.map |
@@ -6,2 +6,4 @@ import React from 'react'; | ||
label: FormattedLabel<Data, Output>; | ||
item: Data; | ||
itemIndex: number; | ||
fill?: FillAccessor<Data, Output>; | ||
@@ -13,4 +15,3 @@ size?: SizeAccessor<Data, Output>; | ||
}; | ||
export default function renderShape<Data, Output>({ shape, fill, size, width, height, label, shapeStyle, }: RenderShapeArgs<Data, Output>): React.FunctionComponentElement<RenderShapeProvidedProps<Data, Output>> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
export default function renderShape<Data, Output>({ shape, fill, size, width, height, label, item, itemIndex, shapeStyle, }: RenderShapeArgs<Data, Output>): React.FunctionComponentElement<RenderShapeProvidedProps<Data, Output>> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
export {}; | ||
//# sourceMappingURL=renderShape.d.ts.map |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _Line = _interopRequireDefault(require("../shapes/Line")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,2 +33,4 @@ | ||
label = _ref.label, | ||
item = _ref.item, | ||
itemIndex = _ref.itemIndex, | ||
_ref$shapeStyle = _ref.shapeStyle, | ||
@@ -37,2 +41,4 @@ shapeStyle = _ref$shapeStyle === void 0 ? NO_OP : _ref$shapeStyle; | ||
height: height, | ||
item: item, | ||
itemIndex: itemIndex, | ||
label: label, | ||
@@ -45,7 +51,11 @@ fill: fill(_extends({}, label)), | ||
if (typeof shape === 'string') { | ||
if (shape === 'rect') { | ||
return /*#__PURE__*/_react.default.createElement(_Rect.default, props); | ||
if (shape === 'circle') { | ||
return /*#__PURE__*/_react.default.createElement(_Circle.default, props); | ||
} | ||
return /*#__PURE__*/_react.default.createElement(_Circle.default, props); | ||
if (shape === 'line') { | ||
return /*#__PURE__*/_react.default.createElement(_Line.default, props); | ||
} | ||
return /*#__PURE__*/_react.default.createElement(_Rect.default, props); | ||
} | ||
@@ -52,0 +62,0 @@ |
@@ -8,2 +8,1 @@ export declare type ValueOrIdentity<T> = T | { | ||
export declare function valueOrIdentityString<T>(_: ValueOrIdentity<T>): string; | ||
//# sourceMappingURL=valueOrIdentity.d.ts.map |
{ | ||
"name": "@vx/legend", | ||
"version": "0.0.197", | ||
"version": "0.0.198", | ||
"description": "vx legend", | ||
@@ -40,3 +40,3 @@ "sideEffects": false, | ||
"@types/react": "*", | ||
"@vx/group": "0.0.197", | ||
"@vx/group": "0.0.198", | ||
"classnames": "^2.2.5", | ||
@@ -46,5 +46,5 @@ "prop-types": "^15.5.10" | ||
"devDependencies": { | ||
"@vx/scale": "0.0.197" | ||
"@vx/scale": "0.0.198" | ||
}, | ||
"gitHead": "c56b64bfbedde9ca06255b2eeff84b52c49d57ea" | ||
"gitHead": "4a418928be63a12834accbae246a69136c2e8c19" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
0
-100%88984
-15.67%69
-8%1518
-18.56%+ Added
- Removed
Updated