victory-stack 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.
- package/CHANGELOG.md +33 -0
- package/dist/victory-stack.js +1977 -1806
- package/dist/victory-stack.min.js +1 -1
- package/es/helper-methods.d.ts +53 -0
- package/es/helper-methods.js +19 -17
- package/es/index.d.ts +2 -35
- package/es/index.js +1 -1
- package/es/victory-stack.d.ts +82 -0
- package/es/victory-stack.js +14 -15
- package/lib/helper-methods.d.ts +53 -0
- package/lib/helper-methods.js +19 -17
- package/lib/index.d.ts +2 -35
- package/lib/index.js +11 -8
- package/lib/victory-stack.d.ts +82 -0
- package/lib/victory-stack.js +16 -19
- package/package.json +266 -8
- package/src/{helper-methods.js → helper-methods.tsx} +12 -13
- package/src/index.ts +1 -0
- package/src/{victory-stack.js → victory-stack.tsx} +51 -21
- package/src/index.d.ts +0 -35
- package/src/index.js +0 -1
package/lib/victory-stack.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.VictoryStack = void 0;
|
|
7
7
|
|
|
8
8
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
9
|
|
|
@@ -37,9 +37,9 @@ var fallbackProps = {
|
|
|
37
37
|
padding: 50
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var VictoryStackBase = function (initialProps) {
|
|
41
41
|
// eslint-disable-next-line no-use-before-define
|
|
42
|
-
var role =
|
|
42
|
+
var role = VictoryStack.role;
|
|
43
43
|
|
|
44
44
|
var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
|
|
45
45
|
setAnimationState = _Hooks$useAnimationSt.setAnimationState,
|
|
@@ -67,14 +67,13 @@ var VictoryStack = function (initialProps) {
|
|
|
67
67
|
var calculatedProps = (0, _helperMethods.useMemoizedProps)(modifiedProps);
|
|
68
68
|
var domain = calculatedProps.domain,
|
|
69
69
|
scale = calculatedProps.scale,
|
|
70
|
-
style = calculatedProps.style
|
|
71
|
-
origin = calculatedProps.origin;
|
|
70
|
+
style = calculatedProps.style;
|
|
72
71
|
|
|
73
72
|
var newChildren = _react.default.useMemo(function () {
|
|
74
73
|
var children = (0, _helperMethods.getChildren)(props, childComponents, calculatedProps);
|
|
75
74
|
var orderedChildren = children.map(function (child, index) {
|
|
76
75
|
var childProps = (0, _assign2.default)({
|
|
77
|
-
animate: getAnimationProps(props, child, index
|
|
76
|
+
animate: getAnimationProps(props, child, index)
|
|
78
77
|
}, child.props);
|
|
79
78
|
return /*#__PURE__*/_react.default.cloneElement(child, childProps);
|
|
80
79
|
});
|
|
@@ -99,13 +98,12 @@ var VictoryStack = function (initialProps) {
|
|
|
99
98
|
style: style.parent,
|
|
100
99
|
horizontal: horizontal,
|
|
101
100
|
polar: polar,
|
|
102
|
-
origin: origin,
|
|
103
101
|
name: name
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
return {};
|
|
108
|
-
}, [standalone, domain, scale, width, height, theme, style, horizontal, polar,
|
|
106
|
+
}, [standalone, domain, scale, width, height, theme, style, horizontal, polar, name]);
|
|
109
107
|
|
|
110
108
|
var userProps = _react.default.useMemo(function () {
|
|
111
109
|
return _victoryCore.UserProps.getSafeUserProps(initialProps);
|
|
@@ -147,7 +145,7 @@ var VictoryStack = function (initialProps) {
|
|
|
147
145
|
return /*#__PURE__*/_react.default.cloneElement(container, container.props, newChildren);
|
|
148
146
|
};
|
|
149
147
|
|
|
150
|
-
|
|
148
|
+
VictoryStackBase.propTypes = _objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), {}, {
|
|
151
149
|
bins: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_victoryCore.PropTypes.nonNegative, _propTypes.default.instanceOf(Date)])), _victoryCore.PropTypes.nonNegative]),
|
|
152
150
|
categories: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.shape({
|
|
153
151
|
x: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
@@ -166,20 +164,19 @@ VictoryStack.propTypes = _objectSpread(_objectSpread({}, _victoryCore.CommonProp
|
|
|
166
164
|
}),
|
|
167
165
|
xOffset: _propTypes.default.number
|
|
168
166
|
});
|
|
169
|
-
|
|
167
|
+
VictoryStackBase.defaultProps = {
|
|
170
168
|
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
|
|
171
169
|
groupComponent: /*#__PURE__*/_react.default.createElement("g", null),
|
|
172
170
|
standalone: true,
|
|
173
171
|
theme: _victoryCore.VictoryTheme.grayscale,
|
|
174
172
|
fillInMissingData: true
|
|
175
173
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
exports.default = _default;
|
|
174
|
+
var componentConfig = {
|
|
175
|
+
role: "stack",
|
|
176
|
+
expectedComponents: ["groupComponent", "containerComponent", "labelComponent"],
|
|
177
|
+
getChildren: _helperMethods.getChildren
|
|
178
|
+
};
|
|
179
|
+
var VictoryStack = Object.assign( /*#__PURE__*/_react.default.memo(VictoryStackBase, _reactFastCompare.default), componentConfig);
|
|
180
|
+
exports.VictoryStack = VictoryStack;
|
|
181
|
+
VictoryStack.displayName = "VictoryStack";
|
|
185
182
|
//# sourceMappingURL=victory-stack.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-stack",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.6.2",
|
|
4
4
|
"description": "Stack Layout Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/formidablelabs/victory.git"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://formidable.com/open-source/victory",
|
|
16
|
+
"sideEffects": false,
|
|
16
17
|
"main": "lib/index.js",
|
|
17
18
|
"module": "es/index.js",
|
|
18
19
|
"jsnext:main": "es/index.js",
|
|
@@ -22,15 +23,272 @@
|
|
|
22
23
|
"lodash": "^4.17.19",
|
|
23
24
|
"prop-types": "^15.8.1",
|
|
24
25
|
"react-fast-compare": "^3.2.0",
|
|
25
|
-
"victory-core": "^36.
|
|
26
|
-
"victory-shared-events": "^36.
|
|
26
|
+
"victory-core": "^36.6.2",
|
|
27
|
+
"victory-shared-events": "^36.6.2"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"react": ">=16.6.0"
|
|
30
31
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"victory-bar": "*",
|
|
34
|
+
"victory-histogram": "*",
|
|
35
|
+
"victory-stack": "*"
|
|
33
36
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
+
"wireit": {
|
|
38
|
+
"### THESE WIREIT CONFIGS ARE GENERATED ####": {},
|
|
39
|
+
"### DO NOT MODIFY THESE MANUALLY ####": {},
|
|
40
|
+
"build": {
|
|
41
|
+
"dependencies": [
|
|
42
|
+
"build:lib",
|
|
43
|
+
"build:dist",
|
|
44
|
+
"types:create"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"build:lib": {
|
|
48
|
+
"dependencies": [
|
|
49
|
+
"build:lib:esm",
|
|
50
|
+
"build:lib:cjs"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"build:lib:esm": {
|
|
54
|
+
"command": "nps build:lib:esm",
|
|
55
|
+
"files": [
|
|
56
|
+
"src/**",
|
|
57
|
+
"!src/**/*.test.*",
|
|
58
|
+
"../../.babelrc.build.js"
|
|
59
|
+
],
|
|
60
|
+
"output": [
|
|
61
|
+
"es/**/*.js",
|
|
62
|
+
"es/**/*.js.map"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": [
|
|
65
|
+
"../victory-core:build:lib:esm",
|
|
66
|
+
"../victory-shared-events:build:lib:esm"
|
|
67
|
+
],
|
|
68
|
+
"packageLocks": [
|
|
69
|
+
"pnpm-lock.yaml"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"build:lib:cjs": {
|
|
73
|
+
"command": "nps build:lib:cjs",
|
|
74
|
+
"files": [
|
|
75
|
+
"src/**",
|
|
76
|
+
"!src/**/*.test.*",
|
|
77
|
+
"../../.babelrc.build.js"
|
|
78
|
+
],
|
|
79
|
+
"output": [
|
|
80
|
+
"lib/**/*.js",
|
|
81
|
+
"lib/**/*.js.map"
|
|
82
|
+
],
|
|
83
|
+
"dependencies": [
|
|
84
|
+
"../victory-core:build:lib:cjs",
|
|
85
|
+
"../victory-shared-events:build:lib:cjs"
|
|
86
|
+
],
|
|
87
|
+
"packageLocks": [
|
|
88
|
+
"pnpm-lock.yaml"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"build:dist": {
|
|
92
|
+
"dependencies": [
|
|
93
|
+
"build:dist:dev",
|
|
94
|
+
"build:dist:min"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"build:dist:dev": {
|
|
98
|
+
"command": "nps build:dist:dev",
|
|
99
|
+
"files": [
|
|
100
|
+
"src/**",
|
|
101
|
+
"!src/**/*.test.*",
|
|
102
|
+
"../../.babelrc.build.js",
|
|
103
|
+
"../../config/webpack.config.js",
|
|
104
|
+
"../../config/webpack.config.dev.js"
|
|
105
|
+
],
|
|
106
|
+
"output": [
|
|
107
|
+
"dist/victory*.js",
|
|
108
|
+
"!dist/victory*.min.js*"
|
|
109
|
+
],
|
|
110
|
+
"dependencies": [
|
|
111
|
+
"../victory-core:build:lib:esm",
|
|
112
|
+
"../victory-shared-events:build:lib:esm"
|
|
113
|
+
],
|
|
114
|
+
"packageLocks": [
|
|
115
|
+
"pnpm-lock.yaml"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"build:dist:min": {
|
|
119
|
+
"command": "nps build:dist:min",
|
|
120
|
+
"files": [
|
|
121
|
+
"src/**",
|
|
122
|
+
"!src/**/*.test.*",
|
|
123
|
+
"../../.babelrc.build.js",
|
|
124
|
+
"../../config/webpack.config.js"
|
|
125
|
+
],
|
|
126
|
+
"output": [
|
|
127
|
+
"dist/victory*.min.js*"
|
|
128
|
+
],
|
|
129
|
+
"dependencies": [
|
|
130
|
+
"../victory-core:build:lib:esm",
|
|
131
|
+
"../victory-shared-events:build:lib:esm"
|
|
132
|
+
],
|
|
133
|
+
"packageLocks": [
|
|
134
|
+
"pnpm-lock.yaml"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"check": {
|
|
138
|
+
"dependencies": [
|
|
139
|
+
"types:check",
|
|
140
|
+
"jest",
|
|
141
|
+
"format",
|
|
142
|
+
"lint"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"types:check": {
|
|
146
|
+
"command": "nps types:pkg:check",
|
|
147
|
+
"files": [
|
|
148
|
+
"src/**/*.{ts,tsx}",
|
|
149
|
+
"../../tsconfig.base.json",
|
|
150
|
+
"tsconfig.json"
|
|
151
|
+
],
|
|
152
|
+
"dependencies": [
|
|
153
|
+
"types:create",
|
|
154
|
+
"../victory-core:types:create",
|
|
155
|
+
"../victory-shared-events:types:create",
|
|
156
|
+
"../victory-bar:types:create",
|
|
157
|
+
"../victory-histogram:types:create",
|
|
158
|
+
"../victory-vendor:types:create",
|
|
159
|
+
"../victory-voronoi:types:create"
|
|
160
|
+
],
|
|
161
|
+
"output": [],
|
|
162
|
+
"packageLocks": [
|
|
163
|
+
"pnpm-lock.yaml"
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"types:create": {
|
|
167
|
+
"command": "nps types:pkg:create",
|
|
168
|
+
"files": [
|
|
169
|
+
"src/**",
|
|
170
|
+
"!src/**/*.test.*",
|
|
171
|
+
"../../tsconfig.base.json",
|
|
172
|
+
"tsconfig.build.json"
|
|
173
|
+
],
|
|
174
|
+
"output": [
|
|
175
|
+
"es/**/*.d.ts",
|
|
176
|
+
"es/**/*.d.ts.map",
|
|
177
|
+
"lib/**/*.d.ts",
|
|
178
|
+
"lib/**/*.d.ts.map"
|
|
179
|
+
],
|
|
180
|
+
"dependencies": [
|
|
181
|
+
"../victory-core:types:create",
|
|
182
|
+
"../victory-shared-events:types:create"
|
|
183
|
+
],
|
|
184
|
+
"packageLocks": [
|
|
185
|
+
"pnpm-lock.yaml"
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
"format": {
|
|
189
|
+
"command": "nps format:pkg",
|
|
190
|
+
"files": [
|
|
191
|
+
"src/**",
|
|
192
|
+
"*.json",
|
|
193
|
+
"../../.prettierignore",
|
|
194
|
+
"../../.prettierrc.json"
|
|
195
|
+
],
|
|
196
|
+
"output": [],
|
|
197
|
+
"packageLocks": [
|
|
198
|
+
"pnpm-lock.yaml"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
"format:fix": {
|
|
202
|
+
"command": "pnpm run format || nps format:pkg:fix",
|
|
203
|
+
"files": [
|
|
204
|
+
"src/**",
|
|
205
|
+
"*.json",
|
|
206
|
+
"../../.prettierignore",
|
|
207
|
+
"../../.prettierrc.json"
|
|
208
|
+
],
|
|
209
|
+
"output": [],
|
|
210
|
+
"packageLocks": [
|
|
211
|
+
"pnpm-lock.yaml"
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
"lint": {
|
|
215
|
+
"command": "nps lint:pkg",
|
|
216
|
+
"files": [
|
|
217
|
+
"src/**",
|
|
218
|
+
"../../.eslintignore",
|
|
219
|
+
"../../.eslintrc.js"
|
|
220
|
+
],
|
|
221
|
+
"output": [],
|
|
222
|
+
"dependencies": [
|
|
223
|
+
"../victory-core:types:create",
|
|
224
|
+
"../victory-shared-events:types:create",
|
|
225
|
+
"../victory-bar:types:create",
|
|
226
|
+
"../victory-histogram:types:create",
|
|
227
|
+
"../victory-vendor:types:create",
|
|
228
|
+
"../victory-voronoi:types:create"
|
|
229
|
+
],
|
|
230
|
+
"packageLocks": [
|
|
231
|
+
"pnpm-lock.yaml"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
"lint:fix": {
|
|
235
|
+
"command": "pnpm run lint || nps lint:pkg:fix",
|
|
236
|
+
"files": [
|
|
237
|
+
"src/**",
|
|
238
|
+
"../../.eslintignore",
|
|
239
|
+
"../../.eslintrc.js"
|
|
240
|
+
],
|
|
241
|
+
"output": [],
|
|
242
|
+
"dependencies": [
|
|
243
|
+
"../victory-core:types:create",
|
|
244
|
+
"../victory-shared-events:types:create",
|
|
245
|
+
"../victory-bar:types:create",
|
|
246
|
+
"../victory-histogram:types:create",
|
|
247
|
+
"../victory-vendor:types:create",
|
|
248
|
+
"../victory-voronoi:types:create"
|
|
249
|
+
],
|
|
250
|
+
"packageLocks": [
|
|
251
|
+
"pnpm-lock.yaml"
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
"jest": {
|
|
255
|
+
"command": "nps jest:pkg",
|
|
256
|
+
"files": [
|
|
257
|
+
"src/**/*.test.*",
|
|
258
|
+
"../../.babelrc.js",
|
|
259
|
+
"../../test/jest-config.js",
|
|
260
|
+
"../../test/jest-setup.ts"
|
|
261
|
+
],
|
|
262
|
+
"output": [],
|
|
263
|
+
"dependencies": [
|
|
264
|
+
"build:lib:cjs",
|
|
265
|
+
"../victory-bar:build:lib:cjs",
|
|
266
|
+
"../victory-histogram:build:lib:cjs",
|
|
267
|
+
"../victory-vendor:build:lib:cjs",
|
|
268
|
+
"../victory-voronoi:build:lib:cjs"
|
|
269
|
+
],
|
|
270
|
+
"packageLocks": [
|
|
271
|
+
"pnpm-lock.yaml"
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"scripts": {
|
|
276
|
+
"### THESE SCRIPTS ARE GENERATED ###": "true",
|
|
277
|
+
"### DO NOT MODIFY THESE MANUALLY ###": "true",
|
|
278
|
+
"build": "wireit",
|
|
279
|
+
"build:lib": "wireit",
|
|
280
|
+
"build:lib:esm": "wireit",
|
|
281
|
+
"build:lib:cjs": "wireit",
|
|
282
|
+
"build:dist": "wireit",
|
|
283
|
+
"build:dist:dev": "wireit",
|
|
284
|
+
"build:dist:min": "wireit",
|
|
285
|
+
"check": "wireit",
|
|
286
|
+
"types:check": "wireit",
|
|
287
|
+
"types:create": "wireit",
|
|
288
|
+
"format": "wireit",
|
|
289
|
+
"format:fix": "wireit",
|
|
290
|
+
"lint": "wireit",
|
|
291
|
+
"lint:fix": "wireit",
|
|
292
|
+
"jest": "wireit"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
@@ -19,31 +19,29 @@ function fillData(props, datasets) {
|
|
|
19
19
|
});
|
|
20
20
|
return prev;
|
|
21
21
|
}, {});
|
|
22
|
-
const xKeys = keys(xMap).map((k) =>
|
|
22
|
+
const xKeys = keys(xMap).map((k) => Number(k));
|
|
23
23
|
const xArr = orderBy(xKeys);
|
|
24
24
|
|
|
25
25
|
return datasets.map((dataset) => {
|
|
26
26
|
let indexOffset = 0;
|
|
27
27
|
const isDate = dataset[0] && dataset[0]._x instanceof Date;
|
|
28
|
-
const filledInData = xArr.map((x, index) => {
|
|
29
|
-
x =
|
|
28
|
+
const filledInData = xArr.map((x: number | Date, index) => {
|
|
29
|
+
x = Number(x);
|
|
30
30
|
const datum = dataset[index - indexOffset];
|
|
31
31
|
|
|
32
32
|
if (datum) {
|
|
33
33
|
const x1 = isDate ? datum._x.getTime() : datum._x;
|
|
34
34
|
if (x1 === x) {
|
|
35
35
|
return datum;
|
|
36
|
-
} else {
|
|
37
|
-
indexOffset++;
|
|
38
|
-
const y = fillInMissingData ? 0 : null;
|
|
39
|
-
x = isDate ? new Date(x) : x;
|
|
40
|
-
return { x, y, _x: x, _y: y };
|
|
41
36
|
}
|
|
42
|
-
|
|
37
|
+
indexOffset++;
|
|
43
38
|
const y = fillInMissingData ? 0 : null;
|
|
44
39
|
x = isDate ? new Date(x) : x;
|
|
45
40
|
return { x, y, _x: x, _y: y };
|
|
46
41
|
}
|
|
42
|
+
const y = fillInMissingData ? 0 : null;
|
|
43
|
+
x = isDate ? new Date(x) : x;
|
|
44
|
+
return { x, y, _x: x, _y: y };
|
|
47
45
|
});
|
|
48
46
|
|
|
49
47
|
return filledInData;
|
|
@@ -75,7 +73,7 @@ function getY0(datum, index, datasets) {
|
|
|
75
73
|
previousPoints.length &&
|
|
76
74
|
previousPoints.reduce((memo, value) => {
|
|
77
75
|
const sameSign = (y < 0 && value < 0) || (y >= 0 && value >= 0);
|
|
78
|
-
return sameSign ?
|
|
76
|
+
return sameSign ? Number(value) + memo : memo;
|
|
79
77
|
}, firstDatasetBaseline[group] || 0);
|
|
80
78
|
return previousPoints.some((point) => point instanceof Date)
|
|
81
79
|
? new Date(y0)
|
|
@@ -97,13 +95,13 @@ function addLayoutData(props, datasets, index) {
|
|
|
97
95
|
datum._y === null
|
|
98
96
|
? null
|
|
99
97
|
: datum._y instanceof Date
|
|
100
|
-
? new Date(
|
|
98
|
+
? new Date(Number(datum._y) + Number(yOffset))
|
|
101
99
|
: datum._y + yOffset,
|
|
102
100
|
_x1:
|
|
103
101
|
datum._x === null
|
|
104
102
|
? null
|
|
105
103
|
: datum._x instanceof Date
|
|
106
|
-
? new Date(
|
|
104
|
+
? new Date(Number(datum._x) + Number(xOffset))
|
|
107
105
|
: datum._x + xOffset,
|
|
108
106
|
});
|
|
109
107
|
});
|
|
@@ -164,7 +162,8 @@ export function getCalculatedProps(props, childComponents) {
|
|
|
164
162
|
// With shared events, the props change on every event, and every value is re-calculated
|
|
165
163
|
const withoutSharedEvents = (props) => {
|
|
166
164
|
const { children } = props;
|
|
167
|
-
const modifiedChildren = React.Children.toArray(children).map((
|
|
165
|
+
const modifiedChildren = React.Children.toArray(children).map((_child) => {
|
|
166
|
+
const child = _child as React.ReactElement;
|
|
168
167
|
return {
|
|
169
168
|
...child,
|
|
170
169
|
props: Helpers.omit(child.props, ["sharedEvents"]),
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./victory-stack";
|
|
@@ -2,15 +2,26 @@ import { assign, defaults, isEmpty } from "lodash";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import {
|
|
5
|
+
CategoryPropType,
|
|
6
|
+
ColorScalePropType,
|
|
7
|
+
DomainPropType,
|
|
8
|
+
EventPropTypeInterface,
|
|
9
|
+
StringOrNumberOrCallback,
|
|
10
|
+
VictoryCommonProps,
|
|
11
|
+
VictoryLabelableProps,
|
|
12
|
+
VictoryMultiLabelableProps,
|
|
13
|
+
VictoryStyleInterface,
|
|
5
14
|
CommonProps,
|
|
6
15
|
Helpers,
|
|
7
16
|
Hooks,
|
|
8
17
|
PropTypes as CustomPropTypes,
|
|
9
18
|
UserProps,
|
|
19
|
+
VictoryComponentConfiguration,
|
|
10
20
|
VictoryContainer,
|
|
11
21
|
VictoryTheme,
|
|
12
22
|
Wrapper,
|
|
13
23
|
} from "victory-core";
|
|
24
|
+
|
|
14
25
|
import { VictorySharedEvents } from "victory-shared-events";
|
|
15
26
|
import { getChildren, useMemoizedProps } from "./helper-methods";
|
|
16
27
|
import isEqual from "react-fast-compare";
|
|
@@ -21,9 +32,29 @@ const fallbackProps = {
|
|
|
21
32
|
padding: 50,
|
|
22
33
|
};
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
export type VictoryStackTTargetType = "data" | "labels" | "parent";
|
|
36
|
+
export interface VictoryStackProps
|
|
37
|
+
extends VictoryCommonProps,
|
|
38
|
+
VictoryLabelableProps,
|
|
39
|
+
VictoryMultiLabelableProps {
|
|
40
|
+
bins?: number | number[] | Date[];
|
|
41
|
+
categories?: CategoryPropType;
|
|
42
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
43
|
+
colorScale?: ColorScalePropType;
|
|
44
|
+
domain?: DomainPropType;
|
|
45
|
+
events?: EventPropTypeInterface<
|
|
46
|
+
VictoryStackTTargetType,
|
|
47
|
+
StringOrNumberOrCallback
|
|
48
|
+
>[];
|
|
49
|
+
eventKey?: StringOrNumberOrCallback;
|
|
50
|
+
fillInMissingData?: boolean;
|
|
51
|
+
style?: VictoryStyleInterface;
|
|
52
|
+
xOffset?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const VictoryStackBase = (initialProps) => {
|
|
25
56
|
// eslint-disable-next-line no-use-before-define
|
|
26
|
-
const { role } =
|
|
57
|
+
const { role } = VictoryStack;
|
|
27
58
|
const { setAnimationState, getAnimationProps, getProps } =
|
|
28
59
|
Hooks.useAnimationState();
|
|
29
60
|
|
|
@@ -46,13 +77,13 @@ const VictoryStack = (initialProps) => {
|
|
|
46
77
|
|
|
47
78
|
const childComponents = React.Children.toArray(modifiedProps.children);
|
|
48
79
|
const calculatedProps = useMemoizedProps(modifiedProps);
|
|
49
|
-
const { domain, scale, style
|
|
80
|
+
const { domain, scale, style } = calculatedProps;
|
|
50
81
|
|
|
51
82
|
const newChildren = React.useMemo(() => {
|
|
52
83
|
const children = getChildren(props, childComponents, calculatedProps);
|
|
53
84
|
const orderedChildren = children.map((child, index) => {
|
|
54
85
|
const childProps = assign(
|
|
55
|
-
{ animate: getAnimationProps(props, child, index
|
|
86
|
+
{ animate: getAnimationProps(props, child, index) },
|
|
56
87
|
child.props,
|
|
57
88
|
);
|
|
58
89
|
return React.cloneElement(child, childProps);
|
|
@@ -77,7 +108,6 @@ const VictoryStack = (initialProps) => {
|
|
|
77
108
|
style: style.parent,
|
|
78
109
|
horizontal,
|
|
79
110
|
polar,
|
|
80
|
-
origin,
|
|
81
111
|
name,
|
|
82
112
|
};
|
|
83
113
|
}
|
|
@@ -92,7 +122,6 @@ const VictoryStack = (initialProps) => {
|
|
|
92
122
|
style,
|
|
93
123
|
horizontal,
|
|
94
124
|
polar,
|
|
95
|
-
origin,
|
|
96
125
|
name,
|
|
97
126
|
]);
|
|
98
127
|
const userProps = React.useMemo(
|
|
@@ -150,7 +179,7 @@ const VictoryStack = (initialProps) => {
|
|
|
150
179
|
return React.cloneElement(container, container.props, newChildren);
|
|
151
180
|
};
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
VictoryStackBase.propTypes = {
|
|
154
183
|
...CommonProps.baseProps,
|
|
155
184
|
bins: PropTypes.oneOfType([
|
|
156
185
|
PropTypes.arrayOf(
|
|
@@ -197,7 +226,7 @@ VictoryStack.propTypes = {
|
|
|
197
226
|
xOffset: PropTypes.number,
|
|
198
227
|
};
|
|
199
228
|
|
|
200
|
-
|
|
229
|
+
VictoryStackBase.defaultProps = {
|
|
201
230
|
containerComponent: <VictoryContainer />,
|
|
202
231
|
groupComponent: <g />,
|
|
203
232
|
standalone: true,
|
|
@@ -205,17 +234,18 @@ VictoryStack.defaultProps = {
|
|
|
205
234
|
fillInMissingData: true,
|
|
206
235
|
};
|
|
207
236
|
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
VictoryStackMemo.getChildren = getChildren;
|
|
237
|
+
const componentConfig: VictoryComponentConfiguration<VictoryStackProps> = {
|
|
238
|
+
role: "stack",
|
|
239
|
+
expectedComponents: [
|
|
240
|
+
"groupComponent",
|
|
241
|
+
"containerComponent",
|
|
242
|
+
"labelComponent",
|
|
243
|
+
],
|
|
244
|
+
getChildren,
|
|
245
|
+
};
|
|
220
246
|
|
|
221
|
-
export
|
|
247
|
+
export const VictoryStack = Object.assign(
|
|
248
|
+
React.memo(VictoryStackBase, isEqual),
|
|
249
|
+
componentConfig,
|
|
250
|
+
);
|
|
251
|
+
VictoryStack.displayName = "VictoryStack";
|
package/src/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
CategoryPropType,
|
|
4
|
-
ColorScalePropType,
|
|
5
|
-
DomainPropType,
|
|
6
|
-
EventPropTypeInterface,
|
|
7
|
-
StringOrNumberOrCallback,
|
|
8
|
-
VictoryCommonProps,
|
|
9
|
-
VictoryLabelableProps,
|
|
10
|
-
VictoryMultiLabelableProps,
|
|
11
|
-
VictoryStyleInterface,
|
|
12
|
-
} from "victory-core";
|
|
13
|
-
|
|
14
|
-
export type VictoryStackTTargetType = "data" | "labels" | "parent";
|
|
15
|
-
|
|
16
|
-
export interface VictoryStackProps
|
|
17
|
-
extends VictoryCommonProps,
|
|
18
|
-
VictoryLabelableProps,
|
|
19
|
-
VictoryMultiLabelableProps {
|
|
20
|
-
bins?: number | number[] | Date[];
|
|
21
|
-
categories?: CategoryPropType;
|
|
22
|
-
children?: React.ReactNode | React.ReactNode[];
|
|
23
|
-
colorScale?: ColorScalePropType;
|
|
24
|
-
domain?: DomainPropType;
|
|
25
|
-
events?: EventPropTypeInterface<
|
|
26
|
-
VictoryStackTTargetType,
|
|
27
|
-
StringOrNumberOrCallback
|
|
28
|
-
>[];
|
|
29
|
-
eventKey?: StringOrNumberOrCallback;
|
|
30
|
-
fillInMissingData?: boolean;
|
|
31
|
-
style?: VictoryStyleInterface;
|
|
32
|
-
xOffset?: number;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class VictoryStack extends React.Component<VictoryStackProps, any> {}
|
package/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as VictoryStack } from "./victory-stack";
|