victory-bar 36.4.1 → 36.5.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.
Files changed (42) hide show
  1. package/dist/victory-bar.js +748 -706
  2. package/dist/victory-bar.min.js +1 -1
  3. package/es/bar-helper-methods.js +2 -1
  4. package/es/bar.js +2 -1
  5. package/es/geometry-helper-methods.js +2 -1
  6. package/es/helper-methods.js +2 -1
  7. package/es/index.d.ts +1 -1
  8. package/es/index.js +2 -1
  9. package/es/path-helper-methods.js +2 -1
  10. package/es/v37/victory-bar.d.ts +23 -0
  11. package/es/v37/victory-bar.js +98 -0
  12. package/es/v37/victory-bar.stories.d.ts +13 -0
  13. package/es/v37/victory-bar.stories.js +18 -0
  14. package/es/victory-bar-beta.d.ts +23 -0
  15. package/es/victory-bar-beta.js +102 -0
  16. package/es/victory-bar.js +20 -27
  17. package/lib/bar-helper-methods.js +2 -1
  18. package/lib/bar.js +2 -1
  19. package/lib/geometry-helper-methods.js +2 -1
  20. package/lib/helper-methods.js +2 -1
  21. package/lib/index.d.ts +1 -1
  22. package/lib/index.js +2 -1
  23. package/lib/path-helper-methods.js +2 -1
  24. package/lib/v37/victory-bar.d.ts +23 -0
  25. package/lib/v37/victory-bar.js +115 -0
  26. package/lib/v37/victory-bar.stories.d.ts +13 -0
  27. package/lib/v37/victory-bar.stories.js +41 -0
  28. package/lib/victory-bar-beta.d.ts +23 -0
  29. package/lib/victory-bar-beta.js +122 -0
  30. package/lib/victory-bar.js +20 -26
  31. package/package.json +5 -5
  32. package/src/bar-helper-methods.js +4 -4
  33. package/src/bar.js +7 -7
  34. package/src/geometry-helper-methods.js +5 -5
  35. package/src/helper-methods.js +9 -9
  36. package/src/index.d.ts +1 -1
  37. package/src/index.js +1 -1
  38. package/src/path-helper-methods.js +18 -18
  39. package/src/v37/victory-bar.stories.tsx +25 -0
  40. package/src/v37/victory-bar.tsx +96 -0
  41. package/src/victory-bar-beta.tsx +127 -0
  42. package/src/victory-bar.js +13 -13
@@ -79,4 +79,5 @@ export var getStyle = function () {
79
79
  stroke: stroke
80
80
  };
81
81
  return Helpers.evaluateStyle(_assign(baseStyle, style), props);
82
- };
82
+ };
83
+ //# sourceMappingURL=bar-helper-methods.js.map
package/es/bar.js CHANGED
@@ -100,4 +100,5 @@ Bar.defaultProps = {
100
100
  role: "presentation",
101
101
  shapeRendering: "auto"
102
102
  };
103
- export default Bar;
103
+ export default Bar;
104
+ //# sourceMappingURL=bar.js.map
@@ -114,4 +114,5 @@ var circle = function (center, radius) {
114
114
  };
115
115
  };
116
116
 
117
- export { circle, point };
117
+ export { circle, point };
118
+ //# sourceMappingURL=geometry-helper-methods.js.map
@@ -140,4 +140,5 @@ export var getBaseProps = function (props, fallbackProps) {
140
140
 
141
141
  return childProps;
142
142
  }, initialChildProps);
143
- };
143
+ };
144
+ //# sourceMappingURL=helper-methods.js.map
package/es/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  VictoryCommonPrimitiveProps,
8
8
  VictoryDatableProps,
9
9
  VictoryMultiLabelableProps,
10
- VictoryStyleInterface
10
+ VictoryStyleInterface,
11
11
  } from "victory-core";
12
12
 
13
13
  export type VictoryBarTTargetType = "data" | "labels" | "parent";
package/es/index.js CHANGED
@@ -2,4 +2,5 @@ export { default as VictoryBar } from "./victory-bar";
2
2
  export { default as Bar } from "./bar";
3
3
  export { getBarPosition } from "./helper-methods";
4
4
  export { getVerticalBarPath, getHorizontalBarPath, getVerticalPolarBarPath, getCustomBarPath, getPolarBarPath, getBarPath } from "./path-helper-methods";
5
- export { getBarWidth, getStyle, getCornerRadius } from "./bar-helper-methods";
5
+ export { getBarWidth, getStyle, getCornerRadius } from "./bar-helper-methods";
6
+ //# sourceMappingURL=index.js.map
@@ -483,4 +483,5 @@ export var getBarPath = function (props, width, cornerRadius) {
483
483
  export var getPolarBarPath = function (props, cornerRadius) {
484
484
  // TODO Radial bars
485
485
  return getVerticalPolarBarPath(props, cornerRadius);
486
- };
486
+ };
487
+ //# sourceMappingURL=path-helper-methods.js.map
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { Datum, NumberOrCallback, VictoryCalculatedStateProps } from "victory-core";
3
+ export declare type VictoryBarAlignmentType = "start" | "middle" | "end";
4
+ export interface VictoryBarProps extends VictoryCalculatedStateProps {
5
+ alignment?: VictoryBarAlignmentType;
6
+ barRatio?: number;
7
+ barWidth?: NumberOrCallback;
8
+ cornerRadius?: NumberOrCallback | {
9
+ top?: NumberOrCallback;
10
+ topLeft?: NumberOrCallback;
11
+ topRight?: NumberOrCallback;
12
+ bottom?: NumberOrCallback;
13
+ bottomLeft?: NumberOrCallback;
14
+ bottomRight?: NumberOrCallback;
15
+ };
16
+ data?: Datum[];
17
+ dataComponent?: React.ReactElement;
18
+ groupComponent?: React.ReactElement;
19
+ horizontal?: boolean;
20
+ }
21
+ declare const _default: (props: VictoryBarProps) => JSX.Element;
22
+ export default _default;
23
+ //# sourceMappingURL=victory-bar.d.ts.map
@@ -0,0 +1,98 @@
1
+ var _excluded = ["alignment", "barRatio", "barWidth", "cornerRadius", "data", "dataComponent", "groupComponent", "includeZero", "horizontal", "sortOrder"];
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+
13
+ /* eslint-disable react/no-multi-comp */
14
+ import * as React from "react";
15
+ import { useData, useDomain, useScale, useVictoryProviderSync, withContainer } from "victory-core";
16
+ import Bar from "../bar";
17
+ import { getBarPosition } from "../helper-methods";
18
+
19
+ function VictoryBar(_ref) {
20
+ var _ref$alignment = _ref.alignment,
21
+ alignment = _ref$alignment === void 0 ? "middle" : _ref$alignment,
22
+ barRatio = _ref.barRatio,
23
+ barWidth = _ref.barWidth,
24
+ cornerRadius = _ref.cornerRadius,
25
+ _ref$data = _ref.data,
26
+ data = _ref$data === void 0 ? [{
27
+ x: 1,
28
+ y: 1
29
+ }, {
30
+ x: 2,
31
+ y: 2
32
+ }, {
33
+ x: 3,
34
+ y: 3
35
+ }, {
36
+ x: 4,
37
+ y: 4
38
+ }] : _ref$data,
39
+ _ref$dataComponent = _ref.dataComponent,
40
+ dataComponent = _ref$dataComponent === void 0 ? /*#__PURE__*/React.createElement(Bar, null) : _ref$dataComponent,
41
+ _ref$groupComponent = _ref.groupComponent,
42
+ groupComponent = _ref$groupComponent === void 0 ? /*#__PURE__*/React.createElement("g", {
43
+ role: "presentation"
44
+ }) : _ref$groupComponent,
45
+ _ref$includeZero = _ref.includeZero,
46
+ includeZero = _ref$includeZero === void 0 ? true : _ref$includeZero,
47
+ _ref$horizontal = _ref.horizontal,
48
+ horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
49
+ _ref$sortOrder = _ref.sortOrder,
50
+ sortOrder = _ref$sortOrder === void 0 ? "ascending" : _ref$sortOrder,
51
+ props = _objectWithoutProperties(_ref, _excluded);
52
+
53
+ // Typescript works best when we provide defaults in the destructured
54
+ // component props. However, I am anticipating confusion about which props
55
+ // we will need to pass back up to the provider vs. the props that are only
56
+ // used in this component.
57
+ useVictoryProviderSync("bar", _objectSpread({
58
+ data: data,
59
+ includeZero: includeZero,
60
+ sortOrder: sortOrder
61
+ }, props));
62
+ var scale = useScale();
63
+ var domain = useDomain(); // TODO: Do we need to get this from context?
64
+
65
+ var formattedData = useData();
66
+ var barPositionProps = {
67
+ domain: domain,
68
+ scale: scale,
69
+ horizontal: horizontal
70
+ };
71
+ var children = formattedData.map(function (datum, i) {
72
+ var _getBarPosition = getBarPosition(barPositionProps, datum),
73
+ x = _getBarPosition.x,
74
+ y = _getBarPosition.y,
75
+ y0 = _getBarPosition.y0;
76
+
77
+ var dataProps = {
78
+ index: i,
79
+ key: "bar-".concat(i),
80
+ alignment: alignment,
81
+ barRatio: barRatio,
82
+ barWidth: barWidth,
83
+ cornerRadius: cornerRadius,
84
+ scale: scale,
85
+ data: data,
86
+ x: x,
87
+ y: y,
88
+ y0: y0,
89
+ datum: datum
90
+ };
91
+ return /*#__PURE__*/React.cloneElement(dataComponent, dataProps);
92
+ });
93
+ return /*#__PURE__*/React.cloneElement(groupComponent, {}, children);
94
+ } // @ts-expect-error we need to work out what props this withContainer wrapper accepts
95
+
96
+
97
+ export default withContainer(VictoryBar);
98
+ //# sourceMappingURL=victory-bar.js.map
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (props: import("./victory-bar").VictoryBarProps) => JSX.Element;
4
+ };
5
+ export default _default;
6
+ export declare const Demo: {
7
+ (props: any): JSX.Element;
8
+ args: {
9
+ barRatio: number;
10
+ };
11
+ };
12
+ export declare const WithChart: (props: any) => JSX.Element;
13
+ //# sourceMappingURL=victory-bar.stories.d.ts.map
@@ -0,0 +1,18 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import * as React from "react";
3
+ import VictoryBar from "./victory-bar";
4
+ import VictoryChart from "victory-chart/lib/v37/victory-chart";
5
+ export default {
6
+ title: "v37/VictoryBar",
7
+ component: VictoryBar
8
+ };
9
+ export var Demo = function (props) {
10
+ return /*#__PURE__*/React.createElement(VictoryBar, props);
11
+ };
12
+ Demo.args = {
13
+ barRatio: 0.5
14
+ };
15
+ export var WithChart = function (props) {
16
+ return /*#__PURE__*/React.createElement(VictoryChart, props, /*#__PURE__*/React.createElement(VictoryBar, null));
17
+ };
18
+ //# sourceMappingURL=victory-bar.stories.js.map
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { NumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryProviderProps } from "victory-core";
3
+ export declare type VictoryBarAlignmentType = "start" | "middle" | "end";
4
+ export interface VictoryBarProps extends VictoryCommonProps, VictoryDatableProps {
5
+ alignment?: VictoryBarAlignmentType;
6
+ barRatio?: number;
7
+ barWidth?: NumberOrCallback;
8
+ cornerRadius?: NumberOrCallback | {
9
+ top?: NumberOrCallback;
10
+ topLeft?: NumberOrCallback;
11
+ topRight?: NumberOrCallback;
12
+ bottom?: NumberOrCallback;
13
+ bottomLeft?: NumberOrCallback;
14
+ bottomRight?: NumberOrCallback;
15
+ };
16
+ dataComponent?: React.ReactElement;
17
+ groupComponent?: React.ReactElement;
18
+ horizontal?: boolean;
19
+ }
20
+ export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: (props: Props) => React.ReactElement, initialProviderProps?: Partial<VictoryProviderProps>): (props: Props) => JSX.Element;
21
+ declare const _default: (props: VictoryBarProps) => JSX.Element;
22
+ export default _default;
23
+ //# sourceMappingURL=victory-bar-beta.d.ts.map
@@ -0,0 +1,102 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ /* eslint-disable react/no-multi-comp */
8
+ import * as React from "react";
9
+ import { useData, useDomain, useScale, VictoryContainer, VictoryProvider } from "victory-core";
10
+ import Bar from "./bar";
11
+ import { getBarPosition } from "./helper-methods"; // This is a demo component that uses VictoryProvider to access calculated props and state.
12
+ // This component does not include events, animations, or styling.
13
+ // To test this out, swap out the VictoryBar export in ./index.js and run `yarn storybook`.
14
+
15
+ var defaultProps = {
16
+ data: [{
17
+ x: 1,
18
+ y: 1
19
+ }, {
20
+ x: 2,
21
+ y: 2
22
+ }, {
23
+ x: 3,
24
+ y: 3
25
+ }, {
26
+ x: 4,
27
+ y: 4
28
+ }],
29
+ height: 300,
30
+ includeZero: true,
31
+ padding: 50,
32
+ sortOrder: "ascending",
33
+ width: 450
34
+ };
35
+ // TODO: This would be a shared helper that allows us to access context values in the base component
36
+ export function withContainer(WrappedComponent) {
37
+ var initialProviderProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ return function (props) {
39
+ var providerProps = _objectSpread(_objectSpread({}, initialProviderProps), props);
40
+
41
+ var _props$standalone = props.standalone,
42
+ standalone = _props$standalone === void 0 ? true : _props$standalone,
43
+ _props$containerCompo = props.containerComponent,
44
+ containerComponent = _props$containerCompo === void 0 ? /*#__PURE__*/React.createElement(VictoryContainer, null) : _props$containerCompo;
45
+
46
+ if (standalone) {
47
+ return /*#__PURE__*/React.createElement(VictoryProvider, providerProps, /*#__PURE__*/React.cloneElement(containerComponent, providerProps, /*#__PURE__*/React.createElement(WrappedComponent, props)));
48
+ }
49
+
50
+ return /*#__PURE__*/React.createElement(VictoryProvider, providerProps, /*#__PURE__*/React.createElement(WrappedComponent, props));
51
+ };
52
+ }
53
+
54
+ function VictoryBar(_ref) {
55
+ var _ref$dataComponent = _ref.dataComponent,
56
+ dataComponent = _ref$dataComponent === void 0 ? /*#__PURE__*/React.createElement(Bar, null) : _ref$dataComponent,
57
+ _ref$groupComponent = _ref.groupComponent,
58
+ groupComponent = _ref$groupComponent === void 0 ? /*#__PURE__*/React.createElement("g", {
59
+ role: "presentation"
60
+ }) : _ref$groupComponent,
61
+ alignment = _ref.alignment,
62
+ barRatio = _ref.barRatio,
63
+ barWidth = _ref.barWidth,
64
+ cornerRadius = _ref.cornerRadius,
65
+ _ref$horizontal = _ref.horizontal,
66
+ horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal;
67
+ var scale = useScale();
68
+ var data = useData();
69
+ var domain = useDomain();
70
+ var children = data.map(function (datum, i) {
71
+ var _getBarPosition = getBarPosition({
72
+ domain: domain,
73
+ scale: scale,
74
+ horizontal: horizontal
75
+ }, datum),
76
+ x = _getBarPosition.x,
77
+ y = _getBarPosition.y,
78
+ x0 = _getBarPosition.x0,
79
+ y0 = _getBarPosition.y0;
80
+
81
+ var dataProps = {
82
+ index: i,
83
+ key: "bar-".concat(i),
84
+ alignment: alignment,
85
+ barRatio: barRatio,
86
+ barWidth: barWidth,
87
+ cornerRadius: cornerRadius,
88
+ scale: scale,
89
+ data: data,
90
+ x: x,
91
+ y: y,
92
+ x0: x0,
93
+ y0: y0,
94
+ datum: datum
95
+ };
96
+ return /*#__PURE__*/React.cloneElement(dataComponent, dataProps);
97
+ });
98
+ return /*#__PURE__*/React.cloneElement(groupComponent, {}, children);
99
+ }
100
+
101
+ export default withContainer(VictoryBar, defaultProps);
102
+ //# sourceMappingURL=victory-bar-beta.js.map
package/es/victory-bar.js CHANGED
@@ -2,6 +2,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
2
2
 
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
 
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
5
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
8
 
7
9
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -10,7 +12,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
10
12
 
11
13
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
12
14
 
13
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
16
 
15
17
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
18
 
@@ -20,9 +22,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
20
22
 
21
23
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
24
 
23
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
-
25
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
26
 
27
27
  import PropTypes from "prop-types";
28
28
  import React from "react";
@@ -85,13 +85,10 @@ var VictoryBar = /*#__PURE__*/function (_React$Component) {
85
85
  return VictoryBar;
86
86
  }(React.Component);
87
87
 
88
- _defineProperty(VictoryBar, "animationWhitelist", ["data", "domain", "height", "padding", "style", "width"]);
89
-
90
- _defineProperty(VictoryBar, "displayName", "VictoryBar");
91
-
92
- _defineProperty(VictoryBar, "role", "bar");
93
-
94
- _defineProperty(VictoryBar, "defaultTransitions", {
88
+ VictoryBar.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
89
+ VictoryBar.displayName = "VictoryBar";
90
+ VictoryBar.role = "bar";
91
+ VictoryBar.defaultTransitions = {
95
92
  onLoad: {
96
93
  duration: 2000,
97
94
  before: function () {
@@ -135,9 +132,8 @@ _defineProperty(VictoryBar, "defaultTransitions", {
135
132
  };
136
133
  }
137
134
  }
138
- });
139
-
140
- _defineProperty(VictoryBar, "propTypes", _objectSpread(_objectSpread(_objectSpread({}, CommonProps.baseProps), CommonProps.dataProps), {}, {
135
+ };
136
+ VictoryBar.propTypes = _objectSpread(_objectSpread(_objectSpread({}, CommonProps.baseProps), CommonProps.dataProps), {}, {
141
137
  alignment: PropTypes.oneOf(["start", "middle", "end"]),
142
138
  barRatio: PropTypes.number,
143
139
  barWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
@@ -151,9 +147,8 @@ _defineProperty(VictoryBar, "propTypes", _objectSpread(_objectSpread(_objectSpre
151
147
  })]),
152
148
  getPath: PropTypes.func,
153
149
  horizontal: PropTypes.bool
154
- }));
155
-
156
- _defineProperty(VictoryBar, "defaultProps", {
150
+ });
151
+ VictoryBar.defaultProps = {
157
152
  containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
158
153
  data: defaultData,
159
154
  dataComponent: /*#__PURE__*/React.createElement(Bar, null),
@@ -165,16 +160,14 @@ _defineProperty(VictoryBar, "defaultProps", {
165
160
  sortOrder: "ascending",
166
161
  standalone: true,
167
162
  theme: VictoryTheme.grayscale
168
- });
169
-
170
- _defineProperty(VictoryBar, "getDomain", Domain.getDomainWithZero);
171
-
172
- _defineProperty(VictoryBar, "getData", Data.getData);
163
+ };
164
+ VictoryBar.getDomain = Domain.getDomainWithZero;
165
+ VictoryBar.getData = Data.getData;
173
166
 
174
- _defineProperty(VictoryBar, "getBaseProps", function (props) {
167
+ VictoryBar.getBaseProps = function (props) {
175
168
  return getBaseProps(props, fallbackProps);
176
- });
177
-
178
- _defineProperty(VictoryBar, "expectedComponents", ["dataComponent", "labelComponent", "groupComponent", "containerComponent"]);
169
+ };
179
170
 
180
- export default addEvents(VictoryBar);
171
+ VictoryBar.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
172
+ export default addEvents(VictoryBar);
173
+ //# sourceMappingURL=victory-bar.js.map
@@ -99,4 +99,5 @@ var getStyle = function () {
99
99
  return _victoryCore.Helpers.evaluateStyle((0, _assign2.default)(baseStyle, style), props);
100
100
  };
101
101
 
102
- exports.getStyle = getStyle;
102
+ exports.getStyle = getStyle;
103
+ //# sourceMappingURL=bar-helper-methods.js.map
package/lib/bar.js CHANGED
@@ -119,4 +119,5 @@ Bar.defaultProps = {
119
119
  shapeRendering: "auto"
120
120
  };
121
121
  var _default = Bar;
122
- exports.default = _default;
122
+ exports.default = _default;
123
+ //# sourceMappingURL=bar.js.map
@@ -123,4 +123,5 @@ var circle = function (center, radius) {
123
123
  };
124
124
  };
125
125
 
126
- exports.circle = circle;
126
+ exports.circle = circle;
127
+ //# sourceMappingURL=geometry-helper-methods.js.map
@@ -164,4 +164,5 @@ var getBaseProps = function (props, fallbackProps) {
164
164
  }, initialChildProps);
165
165
  };
166
166
 
167
- exports.getBaseProps = getBaseProps;
167
+ exports.getBaseProps = getBaseProps;
168
+ //# sourceMappingURL=helper-methods.js.map
package/lib/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  VictoryCommonPrimitiveProps,
8
8
  VictoryDatableProps,
9
9
  VictoryMultiLabelableProps,
10
- VictoryStyleInterface
10
+ VictoryStyleInterface,
11
11
  } from "victory-core";
12
12
 
13
13
  export type VictoryBarTTargetType = "data" | "labels" | "parent";
package/lib/index.js CHANGED
@@ -86,4 +86,5 @@ var _pathHelperMethods = require("./path-helper-methods");
86
86
 
87
87
  var _barHelperMethods = require("./bar-helper-methods");
88
88
 
89
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
89
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
90
+ //# sourceMappingURL=index.js.map
@@ -511,4 +511,5 @@ var getPolarBarPath = function (props, cornerRadius) {
511
511
  return getVerticalPolarBarPath(props, cornerRadius);
512
512
  };
513
513
 
514
- exports.getPolarBarPath = getPolarBarPath;
514
+ exports.getPolarBarPath = getPolarBarPath;
515
+ //# sourceMappingURL=path-helper-methods.js.map
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { Datum, NumberOrCallback, VictoryCalculatedStateProps } from "victory-core";
3
+ export declare type VictoryBarAlignmentType = "start" | "middle" | "end";
4
+ export interface VictoryBarProps extends VictoryCalculatedStateProps {
5
+ alignment?: VictoryBarAlignmentType;
6
+ barRatio?: number;
7
+ barWidth?: NumberOrCallback;
8
+ cornerRadius?: NumberOrCallback | {
9
+ top?: NumberOrCallback;
10
+ topLeft?: NumberOrCallback;
11
+ topRight?: NumberOrCallback;
12
+ bottom?: NumberOrCallback;
13
+ bottomLeft?: NumberOrCallback;
14
+ bottomRight?: NumberOrCallback;
15
+ };
16
+ data?: Datum[];
17
+ dataComponent?: React.ReactElement;
18
+ groupComponent?: React.ReactElement;
19
+ horizontal?: boolean;
20
+ }
21
+ declare const _default: (props: VictoryBarProps) => JSX.Element;
22
+ export default _default;
23
+ //# sourceMappingURL=victory-bar.d.ts.map
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _victoryCore = require("victory-core");
11
+
12
+ var _bar = _interopRequireDefault(require("../bar"));
13
+
14
+ var _helperMethods = require("../helper-methods");
15
+
16
+ var _excluded = ["alignment", "barRatio", "barWidth", "cornerRadius", "data", "dataComponent", "groupComponent", "includeZero", "horizontal", "sortOrder"];
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
+
32
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
+
34
+ function VictoryBar(_ref) {
35
+ var _ref$alignment = _ref.alignment,
36
+ alignment = _ref$alignment === void 0 ? "middle" : _ref$alignment,
37
+ barRatio = _ref.barRatio,
38
+ barWidth = _ref.barWidth,
39
+ cornerRadius = _ref.cornerRadius,
40
+ _ref$data = _ref.data,
41
+ data = _ref$data === void 0 ? [{
42
+ x: 1,
43
+ y: 1
44
+ }, {
45
+ x: 2,
46
+ y: 2
47
+ }, {
48
+ x: 3,
49
+ y: 3
50
+ }, {
51
+ x: 4,
52
+ y: 4
53
+ }] : _ref$data,
54
+ _ref$dataComponent = _ref.dataComponent,
55
+ dataComponent = _ref$dataComponent === void 0 ? /*#__PURE__*/React.createElement(_bar.default, null) : _ref$dataComponent,
56
+ _ref$groupComponent = _ref.groupComponent,
57
+ groupComponent = _ref$groupComponent === void 0 ? /*#__PURE__*/React.createElement("g", {
58
+ role: "presentation"
59
+ }) : _ref$groupComponent,
60
+ _ref$includeZero = _ref.includeZero,
61
+ includeZero = _ref$includeZero === void 0 ? true : _ref$includeZero,
62
+ _ref$horizontal = _ref.horizontal,
63
+ horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
64
+ _ref$sortOrder = _ref.sortOrder,
65
+ sortOrder = _ref$sortOrder === void 0 ? "ascending" : _ref$sortOrder,
66
+ props = _objectWithoutProperties(_ref, _excluded);
67
+
68
+ // Typescript works best when we provide defaults in the destructured
69
+ // component props. However, I am anticipating confusion about which props
70
+ // we will need to pass back up to the provider vs. the props that are only
71
+ // used in this component.
72
+ (0, _victoryCore.useVictoryProviderSync)("bar", _objectSpread({
73
+ data: data,
74
+ includeZero: includeZero,
75
+ sortOrder: sortOrder
76
+ }, props));
77
+ var scale = (0, _victoryCore.useScale)();
78
+ var domain = (0, _victoryCore.useDomain)(); // TODO: Do we need to get this from context?
79
+
80
+ var formattedData = (0, _victoryCore.useData)();
81
+ var barPositionProps = {
82
+ domain: domain,
83
+ scale: scale,
84
+ horizontal: horizontal
85
+ };
86
+ var children = formattedData.map(function (datum, i) {
87
+ var _getBarPosition = (0, _helperMethods.getBarPosition)(barPositionProps, datum),
88
+ x = _getBarPosition.x,
89
+ y = _getBarPosition.y,
90
+ y0 = _getBarPosition.y0;
91
+
92
+ var dataProps = {
93
+ index: i,
94
+ key: "bar-".concat(i),
95
+ alignment: alignment,
96
+ barRatio: barRatio,
97
+ barWidth: barWidth,
98
+ cornerRadius: cornerRadius,
99
+ scale: scale,
100
+ data: data,
101
+ x: x,
102
+ y: y,
103
+ y0: y0,
104
+ datum: datum
105
+ };
106
+ return /*#__PURE__*/React.cloneElement(dataComponent, dataProps);
107
+ });
108
+ return /*#__PURE__*/React.cloneElement(groupComponent, {}, children);
109
+ } // @ts-expect-error we need to work out what props this withContainer wrapper accepts
110
+
111
+
112
+ var _default = (0, _victoryCore.withContainer)(VictoryBar);
113
+
114
+ exports.default = _default;
115
+ //# sourceMappingURL=victory-bar.js.map
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (props: import("./victory-bar").VictoryBarProps) => JSX.Element;
4
+ };
5
+ export default _default;
6
+ export declare const Demo: {
7
+ (props: any): JSX.Element;
8
+ args: {
9
+ barRatio: number;
10
+ };
11
+ };
12
+ export declare const WithChart: (props: any) => JSX.Element;
13
+ //# sourceMappingURL=victory-bar.stories.d.ts.map