victory-legend 37.3.2 → 37.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import _range from "lodash/range";
2
- import _groupBy from "lodash/groupBy";
3
- import _defaults from "lodash/defaults";
1
+ import defaults from "lodash/defaults";
2
+ import groupBy from "lodash/groupBy";
3
+ import range from "lodash/range";
4
4
  import { Helpers, Style, TextSize } from "victory-core";
5
5
  const getColorScale = props => {
6
6
  const {
@@ -15,7 +15,7 @@ const getLabelStyles = props => {
15
15
  style
16
16
  } = props;
17
17
  return data.map((datum, index) => {
18
- const baseLabelStyles = _defaults({}, datum.labels, style.labels);
18
+ const baseLabelStyles = defaults({}, datum.labels, style.labels);
19
19
  return Helpers.evaluateStyle(baseLabelStyles, {
20
20
  datum,
21
21
  index,
@@ -33,11 +33,11 @@ const getStyles = function (props, styleObject) {
33
33
  width: "100%"
34
34
  };
35
35
  return {
36
- parent: _defaults(style.parent, styleObject.parent, parentStyleProps),
37
- data: _defaults({}, style.data, styleObject.data),
38
- labels: _defaults({}, style.labels, styleObject.labels),
39
- border: _defaults({}, style.border, styleObject.border),
40
- title: _defaults({}, style.title, styleObject.title)
36
+ parent: defaults(style.parent, styleObject.parent, parentStyleProps),
37
+ data: defaults({}, style.data, styleObject.data),
38
+ labels: defaults({}, style.labels, styleObject.labels),
39
+ border: defaults({}, style.border, styleObject.border),
40
+ title: defaults({}, style.title, styleObject.title)
41
41
  };
42
42
  };
43
43
  const getCalculatedValues = props => {
@@ -49,9 +49,7 @@ const getCalculatedValues = props => {
49
49
  const style = getStyles(props, defaultStyles);
50
50
  const colorScale = getColorScale(props);
51
51
  const isHorizontal = orientation === "horizontal";
52
- const borderPadding = Helpers.getPadding({
53
- padding: props.borderPadding
54
- });
52
+ const borderPadding = Helpers.getPadding(props.borderPadding);
55
53
  return Object.assign({}, props, {
56
54
  style,
57
55
  isHorizontal,
@@ -107,7 +105,7 @@ const groupData = props => {
107
105
  const getColumnWidths = (props, data) => {
108
106
  const gutter = props.gutter || {};
109
107
  const gutterWidth = typeof gutter === "object" ? (gutter.left || 0) + (gutter.right || 0) : gutter || 0;
110
- const dataByColumn = _groupBy(data, "column");
108
+ const dataByColumn = groupBy(data, "column");
111
109
  const columns = Object.keys(dataByColumn);
112
110
  return columns.reduce((memo, curr, index) => {
113
111
  const lengths = dataByColumn[curr].map(d => {
@@ -120,7 +118,7 @@ const getColumnWidths = (props, data) => {
120
118
  const getRowHeights = (props, data) => {
121
119
  const gutter = props.rowGutter || {};
122
120
  const gutterHeight = typeof gutter === "object" ? (gutter.top || 0) + (gutter.bottom || 0) : gutter || 0;
123
- const dataByRow = _groupBy(data, "row");
121
+ const dataByRow = groupBy(data, "row");
124
122
  return Object.keys(dataByRow).reduce((memo, curr, index) => {
125
123
  const rows = dataByRow[curr];
126
124
  const lengths = rows.map(d => {
@@ -145,8 +143,8 @@ const getOffset = (datum, rowHeights, columnWidths) => {
145
143
  row
146
144
  } = datum;
147
145
  return {
148
- x: _range(column).reduce((memo, curr) => memo + columnWidths[curr], 0),
149
- y: _range(row).reduce((memo, curr) => memo + rowHeights[curr], 0)
146
+ x: range(column).reduce((memo, curr) => memo + columnWidths[curr], 0),
147
+ y: range(row).reduce((memo, curr) => memo + rowHeights[curr], 0)
150
148
  };
151
149
  };
152
150
  const getAnchors = (titleOrientation, centerTitle) => {
@@ -172,7 +170,7 @@ const getTitleStyle = props => {
172
170
  const baseStyle = props.style && props.style.title || {};
173
171
  const componentStyle = titleComponent.props && titleComponent.props.style || {};
174
172
  const anchors = getAnchors(titleOrientation, centerTitle);
175
- return Array.isArray(componentStyle) ? componentStyle.map(obj => _defaults({}, obj, baseStyle, anchors)) : _defaults({}, componentStyle, baseStyle, anchors);
173
+ return Array.isArray(componentStyle) ? componentStyle.map(obj => defaults({}, obj, baseStyle, anchors)) : defaults({}, componentStyle, baseStyle, anchors);
176
174
  };
177
175
  const getTitleProps = (props, borderProps) => {
178
176
  const {
@@ -303,7 +301,7 @@ export const getBaseProps = (initialProps, fallbackProps) => {
303
301
  };
304
302
  return groupedData.reduce((childProps, datum, i) => {
305
303
  const color = colorScale[i % colorScale.length];
306
- const dataStyle = _defaults({}, datum.symbol, style.data, {
304
+ const dataStyle = defaults({}, datum.symbol, style.data, {
307
305
  fill: color
308
306
  });
309
307
  const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : i;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { BlockProps, ColorScalePropType, EventPropTypeInterface, OrientationTypes, PaddingProps, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictorySingleLabelableProps, VictoryStyleInterface, VictoryLabelStyleObject, EventsMixinClass } from "victory-core";
3
- export declare type VictoryLegendTTargetType = "data" | "labels" | "parent";
4
- export declare type VictoryLegendOrientationType = "horizontal" | "vertical";
3
+ export type VictoryLegendTTargetType = "data" | "labels" | "parent";
4
+ export type VictoryLegendOrientationType = "horizontal" | "vertical";
5
5
  export interface VictoryLegendProps extends VictoryCommonProps, VictoryDatableProps, VictorySingleLabelableProps {
6
6
  borderComponent?: React.ReactElement;
7
7
  borderPadding?: PaddingProps;
@@ -78,9 +78,9 @@ export declare const VictoryLegend: {
78
78
  getAllEvents(props: any): any;
79
79
  getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
80
80
  renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
81
- animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
81
+ animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement;
82
82
  renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
83
- renderData(props: any, shouldRenderDatum?: ((datum: any) => boolean) | undefined): React.DetailedReactHTMLElement<any, HTMLElement>;
83
+ renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
84
84
  context: unknown;
85
85
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
86
86
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -97,17 +97,17 @@ export declare const VictoryLegend: {
97
97
  UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
98
98
  componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
99
99
  UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
100
- componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent[];
100
+ componentEvents: Array<import("@/victory-core/lib/victory-util/events").ComponentEvent>;
101
101
  getSharedEventState: (key: string, value: string) => unknown;
102
102
  baseProps: Record<string, object>;
103
103
  dataKeys: string[];
104
104
  hasEvents: unknown;
105
105
  events: unknown;
106
106
  };
107
- getBaseProps?(props: import("victory-core").EventMixinCommonProps): Record<string, object>;
108
- role?: string | undefined;
107
+ getBaseProps?(props: import("victory-core").EventMixinCommonProps): import("victory-core").EventMixinCalculatedValues["baseProps"];
108
+ role?: import("victory-core").VictoryComponentRole;
109
109
  expectedComponents?: string[] | undefined;
110
- getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
110
+ getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: Array<React.ReactNode>, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
111
111
  animationWhitelist?: string[] | undefined;
112
112
  } & typeof VictoryLegendBase;
113
113
  export {};
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getDimensions = exports.getBaseProps = void 0;
7
- var _range2 = _interopRequireDefault(require("lodash/range"));
8
- var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
9
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
7
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
8
+ var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
9
+ var _range = _interopRequireDefault(require("lodash/range"));
10
10
  var _victoryCore = require("victory-core");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  const getColorScale = props => {
@@ -22,7 +22,7 @@ const getLabelStyles = props => {
22
22
  style
23
23
  } = props;
24
24
  return data.map((datum, index) => {
25
- const baseLabelStyles = (0, _defaults2.default)({}, datum.labels, style.labels);
25
+ const baseLabelStyles = (0, _defaults.default)({}, datum.labels, style.labels);
26
26
  return _victoryCore.Helpers.evaluateStyle(baseLabelStyles, {
27
27
  datum,
28
28
  index,
@@ -40,11 +40,11 @@ const getStyles = function (props, styleObject) {
40
40
  width: "100%"
41
41
  };
42
42
  return {
43
- parent: (0, _defaults2.default)(style.parent, styleObject.parent, parentStyleProps),
44
- data: (0, _defaults2.default)({}, style.data, styleObject.data),
45
- labels: (0, _defaults2.default)({}, style.labels, styleObject.labels),
46
- border: (0, _defaults2.default)({}, style.border, styleObject.border),
47
- title: (0, _defaults2.default)({}, style.title, styleObject.title)
43
+ parent: (0, _defaults.default)(style.parent, styleObject.parent, parentStyleProps),
44
+ data: (0, _defaults.default)({}, style.data, styleObject.data),
45
+ labels: (0, _defaults.default)({}, style.labels, styleObject.labels),
46
+ border: (0, _defaults.default)({}, style.border, styleObject.border),
47
+ title: (0, _defaults.default)({}, style.title, styleObject.title)
48
48
  };
49
49
  };
50
50
  const getCalculatedValues = props => {
@@ -56,9 +56,7 @@ const getCalculatedValues = props => {
56
56
  const style = getStyles(props, defaultStyles);
57
57
  const colorScale = getColorScale(props);
58
58
  const isHorizontal = orientation === "horizontal";
59
- const borderPadding = _victoryCore.Helpers.getPadding({
60
- padding: props.borderPadding
61
- });
59
+ const borderPadding = _victoryCore.Helpers.getPadding(props.borderPadding);
62
60
  return Object.assign({}, props, {
63
61
  style,
64
62
  isHorizontal,
@@ -114,7 +112,7 @@ const groupData = props => {
114
112
  const getColumnWidths = (props, data) => {
115
113
  const gutter = props.gutter || {};
116
114
  const gutterWidth = typeof gutter === "object" ? (gutter.left || 0) + (gutter.right || 0) : gutter || 0;
117
- const dataByColumn = (0, _groupBy2.default)(data, "column");
115
+ const dataByColumn = (0, _groupBy.default)(data, "column");
118
116
  const columns = Object.keys(dataByColumn);
119
117
  return columns.reduce((memo, curr, index) => {
120
118
  const lengths = dataByColumn[curr].map(d => {
@@ -127,7 +125,7 @@ const getColumnWidths = (props, data) => {
127
125
  const getRowHeights = (props, data) => {
128
126
  const gutter = props.rowGutter || {};
129
127
  const gutterHeight = typeof gutter === "object" ? (gutter.top || 0) + (gutter.bottom || 0) : gutter || 0;
130
- const dataByRow = (0, _groupBy2.default)(data, "row");
128
+ const dataByRow = (0, _groupBy.default)(data, "row");
131
129
  return Object.keys(dataByRow).reduce((memo, curr, index) => {
132
130
  const rows = dataByRow[curr];
133
131
  const lengths = rows.map(d => {
@@ -152,8 +150,8 @@ const getOffset = (datum, rowHeights, columnWidths) => {
152
150
  row
153
151
  } = datum;
154
152
  return {
155
- x: (0, _range2.default)(column).reduce((memo, curr) => memo + columnWidths[curr], 0),
156
- y: (0, _range2.default)(row).reduce((memo, curr) => memo + rowHeights[curr], 0)
153
+ x: (0, _range.default)(column).reduce((memo, curr) => memo + columnWidths[curr], 0),
154
+ y: (0, _range.default)(row).reduce((memo, curr) => memo + rowHeights[curr], 0)
157
155
  };
158
156
  };
159
157
  const getAnchors = (titleOrientation, centerTitle) => {
@@ -179,7 +177,7 @@ const getTitleStyle = props => {
179
177
  const baseStyle = props.style && props.style.title || {};
180
178
  const componentStyle = titleComponent.props && titleComponent.props.style || {};
181
179
  const anchors = getAnchors(titleOrientation, centerTitle);
182
- return Array.isArray(componentStyle) ? componentStyle.map(obj => (0, _defaults2.default)({}, obj, baseStyle, anchors)) : (0, _defaults2.default)({}, componentStyle, baseStyle, anchors);
180
+ return Array.isArray(componentStyle) ? componentStyle.map(obj => (0, _defaults.default)({}, obj, baseStyle, anchors)) : (0, _defaults.default)({}, componentStyle, baseStyle, anchors);
183
181
  };
184
182
  const getTitleProps = (props, borderProps) => {
185
183
  const {
@@ -311,7 +309,7 @@ const getBaseProps = (initialProps, fallbackProps) => {
311
309
  };
312
310
  return groupedData.reduce((childProps, datum, i) => {
313
311
  const color = colorScale[i % colorScale.length];
314
- const dataStyle = (0, _defaults2.default)({}, datum.symbol, style.data, {
312
+ const dataStyle = (0, _defaults.default)({}, datum.symbol, style.data, {
315
313
  fill: color
316
314
  });
317
315
  const eventKey = !_victoryCore.Helpers.isNil(datum.eventKey) ? datum.eventKey : i;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { BlockProps, ColorScalePropType, EventPropTypeInterface, OrientationTypes, PaddingProps, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictorySingleLabelableProps, VictoryStyleInterface, VictoryLabelStyleObject, EventsMixinClass } from "victory-core";
3
- export declare type VictoryLegendTTargetType = "data" | "labels" | "parent";
4
- export declare type VictoryLegendOrientationType = "horizontal" | "vertical";
3
+ export type VictoryLegendTTargetType = "data" | "labels" | "parent";
4
+ export type VictoryLegendOrientationType = "horizontal" | "vertical";
5
5
  export interface VictoryLegendProps extends VictoryCommonProps, VictoryDatableProps, VictorySingleLabelableProps {
6
6
  borderComponent?: React.ReactElement;
7
7
  borderPadding?: PaddingProps;
@@ -78,9 +78,9 @@ export declare const VictoryLegend: {
78
78
  getAllEvents(props: any): any;
79
79
  getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
80
80
  renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
81
- animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
81
+ animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement;
82
82
  renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
83
- renderData(props: any, shouldRenderDatum?: ((datum: any) => boolean) | undefined): React.DetailedReactHTMLElement<any, HTMLElement>;
83
+ renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
84
84
  context: unknown;
85
85
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
86
86
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -97,17 +97,17 @@ export declare const VictoryLegend: {
97
97
  UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
98
98
  componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
99
99
  UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
100
- componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent[];
100
+ componentEvents: Array<import("@/victory-core/lib/victory-util/events").ComponentEvent>;
101
101
  getSharedEventState: (key: string, value: string) => unknown;
102
102
  baseProps: Record<string, object>;
103
103
  dataKeys: string[];
104
104
  hasEvents: unknown;
105
105
  events: unknown;
106
106
  };
107
- getBaseProps?(props: import("victory-core").EventMixinCommonProps): Record<string, object>;
108
- role?: string | undefined;
107
+ getBaseProps?(props: import("victory-core").EventMixinCommonProps): import("victory-core").EventMixinCalculatedValues["baseProps"];
108
+ role?: import("victory-core").VictoryComponentRole;
109
109
  expectedComponents?: string[] | undefined;
110
- getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
110
+ getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: Array<React.ReactNode>, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
111
111
  animationWhitelist?: string[] | undefined;
112
112
  } & typeof VictoryLegendBase;
113
113
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-legend",
3
- "version": "37.3.2",
3
+ "version": "37.3.4",
4
4
  "description": "Legend Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
- "victory-core": "37.3.2"
24
+ "victory-core": "37.3.4"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=16.6.0"
@@ -180,32 +180,6 @@
180
180
  "pnpm-lock.yaml"
181
181
  ]
182
182
  },
183
- "format": {
184
- "command": "nps format:pkg",
185
- "files": [
186
- "src/**",
187
- "*.json",
188
- "../../.prettierignore",
189
- "../../.prettierrc.json"
190
- ],
191
- "output": [],
192
- "packageLocks": [
193
- "pnpm-lock.yaml"
194
- ]
195
- },
196
- "format:fix": {
197
- "command": "pnpm run format || nps format:pkg:fix",
198
- "files": [
199
- "src/**",
200
- "*.json",
201
- "../../.prettierignore",
202
- "../../.prettierrc.json"
203
- ],
204
- "output": [],
205
- "packageLocks": [
206
- "pnpm-lock.yaml"
207
- ]
208
- },
209
183
  "lint": {
210
184
  "command": "eslint src",
211
185
  "files": [
@@ -268,8 +242,6 @@
268
242
  "check": "wireit",
269
243
  "types:check": "wireit",
270
244
  "types:create": "wireit",
271
- "format": "wireit",
272
- "format:fix": "wireit",
273
245
  "lint": "wireit",
274
246
  "lint:fix": "wireit",
275
247
  "jest": "wireit"
@@ -1,4 +1,6 @@
1
- import { defaults, groupBy, range } from "lodash";
1
+ import defaults from "lodash/defaults";
2
+ import groupBy from "lodash/groupBy";
3
+ import range from "lodash/range";
2
4
  import { Helpers, Style, TextSize } from "victory-core";
3
5
  import { VictoryLegendProps } from "./victory-legend";
4
6
 
@@ -36,7 +38,7 @@ const getCalculatedValues = (props) => {
36
38
  const style = getStyles(props, defaultStyles);
37
39
  const colorScale = getColorScale(props);
38
40
  const isHorizontal = orientation === "horizontal";
39
- const borderPadding = Helpers.getPadding({ padding: props.borderPadding });
41
+ const borderPadding = Helpers.getPadding(props.borderPadding);
40
42
  return Object.assign({}, props, {
41
43
  style,
42
44
  isHorizontal,