victory-box-plot 36.5.3 → 36.6.2

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.
@@ -14,6 +14,16 @@ import {
14
14
  DefaultTransitions,
15
15
  CommonProps,
16
16
  UserProps,
17
+ EventPropTypeInterface,
18
+ DomainPropType,
19
+ DomainPaddingPropType,
20
+ OrientationTypes,
21
+ StringOrNumberOrCallback,
22
+ VictoryDatableProps,
23
+ VictoryCommonProps,
24
+ VictoryStyleObject,
25
+ VictoryLabelStyleObject,
26
+ EventsMixinClass,
17
27
  } from "victory-core";
18
28
  import { getDomain, getData, getBaseProps } from "./helper-methods";
19
29
 
@@ -49,8 +59,76 @@ const options = {
49
59
  ],
50
60
  };
51
61
 
52
- class VictoryBoxPlot extends React.Component {
53
- static animationWhitelist = [
62
+ export type VictoryBoxPlotLabelType =
63
+ | boolean
64
+ | (string | number)[]
65
+ | { (): any }
66
+ | { (data: any): string | null };
67
+
68
+ export interface VictoryBoxPlotStyleInterface {
69
+ parent?: VictoryStyleObject;
70
+ max?: VictoryStyleObject;
71
+ maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
72
+ min?: VictoryStyleObject;
73
+ minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
74
+ median?: VictoryStyleObject;
75
+ medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
76
+ q1?: VictoryStyleObject;
77
+ q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
78
+ q3?: VictoryStyleObject;
79
+ q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
80
+ }
81
+
82
+ export interface VictoryBoxPlotLabelOrientationInterface {
83
+ max?: OrientationTypes;
84
+ min?: OrientationTypes;
85
+ median?: OrientationTypes;
86
+ q1?: OrientationTypes;
87
+ q3?: OrientationTypes;
88
+ }
89
+
90
+ export interface VictoryBoxPlotProps
91
+ extends VictoryCommonProps,
92
+ VictoryDatableProps {
93
+ boxWidth?: number;
94
+ datum?: any;
95
+ domain?: DomainPropType;
96
+ domainPadding?: DomainPaddingPropType;
97
+ events?: EventPropTypeInterface<string, StringOrNumberOrCallback>[];
98
+ eventKey?: StringOrNumberOrCallback;
99
+ horizontal?: boolean;
100
+ labelOrientation?: OrientationTypes | VictoryBoxPlotLabelOrientationInterface;
101
+ labels?: boolean;
102
+ max?: StringOrNumberOrCallback | string[];
103
+ maxComponent?: React.ReactElement;
104
+ maxLabelComponent?: React.ReactElement;
105
+ maxLabels?: VictoryBoxPlotLabelType;
106
+ median?: StringOrNumberOrCallback | string[];
107
+ medianComponent?: React.ReactElement;
108
+ medianLabelComponent?: React.ReactElement;
109
+ medianLabels?: VictoryBoxPlotLabelType;
110
+ min?: StringOrNumberOrCallback | string[];
111
+ minComponent?: React.ReactElement;
112
+ minLabelComponent?: React.ReactElement;
113
+ minLabels?: VictoryBoxPlotLabelType;
114
+ q1?: StringOrNumberOrCallback | string[];
115
+ q1Component?: React.ReactElement;
116
+ q1LabelComponent?: React.ReactElement;
117
+ q1Labels?: VictoryBoxPlotLabelType;
118
+ q3?: StringOrNumberOrCallback | string[];
119
+ q3Component?: React.ReactElement;
120
+ q3LabelComponent?: React.ReactElement;
121
+ q3Labels?: VictoryBoxPlotLabelType;
122
+ style?: VictoryBoxPlotStyleInterface;
123
+ text?: StringOrNumberOrCallback | string[];
124
+ whiskerWidth?: number;
125
+ }
126
+
127
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
128
+ interface VictoryBoxPlotBase extends EventsMixinClass<VictoryBoxPlotProps> {}
129
+
130
+ class VictoryBoxPlotBase extends React.Component<VictoryBoxPlotProps> {
131
+ static animationWhitelist: Array<keyof VictoryBoxPlotProps> = [
54
132
  "data",
55
133
  "domain",
56
134
  "height",
@@ -228,7 +306,7 @@ class VictoryBoxPlot extends React.Component {
228
306
  static getDomain = getDomain;
229
307
  static getData = getData;
230
308
  static getBaseProps = (props) => getBaseProps(props, fallbackProps);
231
- static expectedComponents = [
309
+ static expectedComponents: Array<keyof VictoryBoxPlotProps> = [
232
310
  "maxComponent",
233
311
  "maxLabelComponent",
234
312
  "medianComponent",
@@ -260,21 +338,30 @@ class VictoryBoxPlot extends React.Component {
260
338
  );
261
339
  }
262
340
  return validDataComponents;
263
- }, []);
341
+ }, [] as React.ReactElement[]);
264
342
  }),
265
343
  );
266
344
 
267
345
  const labelComponents = flatten(
268
346
  types.map((type) => {
269
- const components = this.dataKeys.map((key, index) => {
270
- const name = `${type}Labels`;
271
- const baseComponent = props[`${type}LabelComponent`];
272
- const labelProps = this.getComponentProps(baseComponent, name, index);
273
- if (labelProps.text !== undefined && labelProps.text !== null) {
274
- return React.cloneElement(baseComponent, labelProps);
275
- }
276
- return undefined;
277
- });
347
+ const components = this.dataKeys.reduce(
348
+ (validComponents, _key, index) => {
349
+ const name = `${type}Labels`;
350
+ const baseComponent = props[`${type}LabelComponent`];
351
+ const labelProps = this.getComponentProps(
352
+ baseComponent,
353
+ name,
354
+ index,
355
+ );
356
+ if (labelProps.text !== undefined && labelProps.text !== null) {
357
+ validComponents.push(
358
+ React.cloneElement(baseComponent, labelProps),
359
+ );
360
+ }
361
+ return validComponents;
362
+ },
363
+ [] as React.ReactElement[],
364
+ );
278
365
  return components.filter(Boolean);
279
366
  }),
280
367
  );
@@ -300,7 +387,7 @@ class VictoryBoxPlot extends React.Component {
300
387
  return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
301
388
  }
302
389
 
303
- render() {
390
+ render(): React.ReactElement {
304
391
  const { animationWhitelist, role } = VictoryBoxPlot;
305
392
  const props = Helpers.modifyProps(this.props, fallbackProps, role);
306
393
 
@@ -317,4 +404,4 @@ class VictoryBoxPlot extends React.Component {
317
404
  }
318
405
  }
319
406
 
320
- export default addEvents(VictoryBoxPlot, options);
407
+ export const VictoryBoxPlot = addEvents(VictoryBoxPlotBase, options);
package/src/index.d.ts DELETED
@@ -1,77 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- EventPropTypeInterface,
4
- DomainPropType,
5
- DomainPaddingPropType,
6
- OrientationTypes,
7
- StringOrNumberOrCallback,
8
- VictoryDatableProps,
9
- VictoryCommonProps,
10
- VictoryStyleObject,
11
- VictoryLabelStyleObject,
12
- } from "victory-core";
13
-
14
- export type VictoryBoxPlotLabelType =
15
- | boolean
16
- | (string | number)[]
17
- | Function
18
- | { (data: any): string | null };
19
-
20
- export interface VictoryBoxPlotStyleInterface {
21
- parent?: VictoryStyleObject;
22
- max?: VictoryStyleObject;
23
- maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
24
- min?: VictoryStyleObject;
25
- minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
26
- median?: VictoryStyleObject;
27
- medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
28
- q1?: VictoryStyleObject;
29
- q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
30
- q3?: VictoryStyleObject;
31
- q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
32
- }
33
-
34
- export interface VictoryBoxPlotLabelOrientationInterface {
35
- max?: OrientationTypes;
36
- min?: OrientationTypes;
37
- median?: OrientationTypes;
38
- q1?: OrientationTypes;
39
- q3?: OrientationTypes;
40
- }
41
-
42
- export interface VictoryBoxPlotProps
43
- extends VictoryCommonProps,
44
- VictoryDatableProps {
45
- boxWidth?: number;
46
- domain?: DomainPropType;
47
- domainPadding?: DomainPaddingPropType;
48
- events?: EventPropTypeInterface<string, StringOrNumberOrCallback>[];
49
- eventKey?: StringOrNumberOrCallback;
50
- horizontal?: boolean;
51
- labelOrientation?: OrientationTypes | VictoryBoxPlotLabelOrientationInterface;
52
- labels?: boolean;
53
- max?: StringOrNumberOrCallback | string[];
54
- maxComponent?: React.ReactElement;
55
- maxLabelComponent?: React.ReactElement;
56
- maxLabels?: VictoryBoxPlotLabelType;
57
- median?: StringOrNumberOrCallback | string[];
58
- medianComponent?: React.ReactElement;
59
- medianLabelComponent?: React.ReactElement;
60
- medianLabels?: VictoryBoxPlotLabelType;
61
- min?: StringOrNumberOrCallback | string[];
62
- minComponent?: React.ReactElement;
63
- minLabelComponent?: React.ReactElement;
64
- minLabels?: VictoryBoxPlotLabelType;
65
- q1?: StringOrNumberOrCallback | string[];
66
- q1Component?: React.ReactElement;
67
- q1LabelComponent?: React.ReactElement;
68
- q1Labels?: VictoryBoxPlotLabelType;
69
- q3?: StringOrNumberOrCallback | string[];
70
- q3Component?: React.ReactElement;
71
- q3LabelComponent?: React.ReactElement;
72
- q3Labels?: VictoryBoxPlotLabelType;
73
- style?: VictoryBoxPlotStyleInterface;
74
- whiskerWidth?: number;
75
- }
76
-
77
- export class VictoryBoxPlot extends React.Component<VictoryBoxPlotProps, any> {}
package/src/index.js DELETED
@@ -1 +0,0 @@
1
- export { default as VictoryBoxPlot } from "./victory-box-plot";