victory-create-container 37.0.2 → 37.1.0

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,44 +1,399 @@
1
1
  import React from "react";
2
- export declare type ContainerType = "brush" | "cursor" | "selection" | "voronoi" | "zoom";
3
- declare type MixinFunction = (...args: any[]) => any;
4
- export declare const combineContainerMixins: (mixins: MixinFunction[], Container: React.ComponentType<any>) => {
5
- new (): {
6
- [x: string]: any;
7
- getChildren(props: any): any;
8
- };
9
- [x: string]: any;
2
+ import { VictoryContainer } from "victory-core";
3
+ export declare type ContainerType = "zoom" | "selection" | "brush" | "cursor" | "voronoi";
4
+ declare type ContainerComponents = Record<ContainerType, React.ComponentType<any> & {
5
+ defaultEvents: (props: any) => any[];
6
+ }>;
7
+ export declare function makeCreateContainerFunction<TContainerComponents extends ContainerComponents>(containerComponents: TContainerComponents, VictoryContainerBase: typeof VictoryContainer): <TContainerA extends ContainerType, TContainerB extends ContainerType>(containerA: TContainerA, containerB: TContainerB) => {
8
+ (props: React.ComponentProps<TContainerComponents[TContainerA]> & React.ComponentProps<TContainerComponents[TContainerB]>): JSX.Element;
10
9
  displayName: string;
11
- propTypes: any;
12
- defaultProps: any;
13
- defaultEvents(props: any): ({
10
+ role: string;
11
+ defaultEvents(props: React.ComponentProps<TContainerComponents[TContainerA]> & React.ComponentProps<TContainerComponents[TContainerB]>): ({
14
12
  target: string;
15
13
  eventHandlers: any;
16
14
  } | null)[];
17
15
  };
18
- export declare const makeCreateContainerFunction: (mixinMap: Record<ContainerType, MixinFunction[]>, Container: React.ComponentType<any>) => (behaviorA: ContainerType, behaviorB: ContainerType, ...invalid: ContainerType[]) => React.ComponentType<any> | {
19
- new (): {
20
- [x: string]: any;
21
- getChildren(props: any): any;
22
- };
23
- [x: string]: any;
16
+ export declare const createContainer: <TContainerA extends ContainerType, TContainerB extends ContainerType>(containerA: TContainerA, containerB: TContainerB) => {
17
+ (props: React.ComponentProps<{
18
+ zoom: {
19
+ (initialProps: import("victory-zoom-container").VictoryZoomContainerProps): JSX.Element;
20
+ role: string;
21
+ defaultEvents(initialProps: import("victory-zoom-container").VictoryZoomContainerProps): {
22
+ target: string;
23
+ eventHandlers: {
24
+ onMouseDown: import("victory-core").VictoryEventHandler;
25
+ onTouchStart: import("victory-core").VictoryEventHandler;
26
+ onMouseUp: import("victory-core").VictoryEventHandler;
27
+ onTouchEnd: import("victory-core").VictoryEventHandler;
28
+ onMouseLeave: import("victory-core").VictoryEventHandler;
29
+ onTouchCancel: import("victory-core").VictoryEventHandler;
30
+ onMouseMove: import("victory-core").VictoryEventHandler;
31
+ onTouchMove: import("victory-core").VictoryEventHandler;
32
+ onWheel: import("victory-core").VictoryEventHandler;
33
+ };
34
+ }[];
35
+ };
36
+ selection: {
37
+ (initialProps: import("victory-selection-container").VictorySelectionContainerProps): JSX.Element;
38
+ role: string;
39
+ defaultEvents(initialProps: import("victory-selection-container").VictorySelectionContainerProps): {
40
+ target: string;
41
+ eventHandlers: {
42
+ onMouseDown: import("victory-core").VictoryEventHandler;
43
+ onTouchStart: import("victory-core").VictoryEventHandler;
44
+ onMouseMove: import("victory-core").VictoryEventHandler;
45
+ onTouchMove: import("victory-core").VictoryEventHandler;
46
+ onMouseUp: import("victory-core").VictoryEventHandler;
47
+ onTouchEnd: import("victory-core").VictoryEventHandler;
48
+ };
49
+ }[];
50
+ };
51
+ brush: {
52
+ (initialProps: import("victory-brush-container").VictoryBrushContainerProps): JSX.Element;
53
+ role: string;
54
+ defaultEvents(initialProps: import("victory-brush-container").VictoryBrushContainerProps): {
55
+ target: string;
56
+ eventHandlers: {
57
+ onMouseDown: import("victory-core").VictoryEventHandler;
58
+ onTouchStart: import("victory-core").VictoryEventHandler;
59
+ onGlobalMouseMove: import("victory-core").VictoryEventHandler;
60
+ onGlobalTouchMove: import("victory-core").VictoryEventHandler;
61
+ onGlobalMouseUp: import("victory-core").VictoryEventHandler;
62
+ onGlobalTouchEnd: import("victory-core").VictoryEventHandler;
63
+ onGlobalTouchCancel: import("victory-core").VictoryEventHandler;
64
+ };
65
+ }[];
66
+ };
67
+ cursor: {
68
+ (initialProps: import("victory-cursor-container").VictoryCursorContainerProps): JSX.Element;
69
+ role: string;
70
+ defaultEvents(initialProps: import("victory-cursor-container").VictoryCursorContainerProps): {
71
+ target: string;
72
+ eventHandlers: {
73
+ onMouseLeave: import("victory-core").VictoryEventHandler;
74
+ onMouseMove: import("victory-core").VictoryEventHandler;
75
+ onTouchMove: import("victory-core").VictoryEventHandler;
76
+ };
77
+ }[];
78
+ };
79
+ voronoi: {
80
+ (initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): JSX.Element;
81
+ role: string;
82
+ defaultEvents(initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): ({
83
+ target: string;
84
+ eventHandlers: {
85
+ onMouseLeave: import("victory-core").VictoryEventHandler;
86
+ onTouchCancel: import("victory-core").VictoryEventHandler;
87
+ onMouseMove: import("victory-core").VictoryEventHandler;
88
+ onTouchMove: import("victory-core").VictoryEventHandler;
89
+ onMouseOver?: undefined;
90
+ onMouseOut?: undefined;
91
+ };
92
+ } | {
93
+ target: string;
94
+ eventHandlers: {
95
+ onMouseLeave?: undefined;
96
+ onTouchCancel?: undefined;
97
+ onMouseMove?: undefined;
98
+ onTouchMove?: undefined;
99
+ onMouseOver?: undefined;
100
+ onMouseOut?: undefined;
101
+ } | {
102
+ onMouseOver: () => null;
103
+ onMouseOut: () => null;
104
+ onMouseMove: () => null;
105
+ onMouseLeave?: undefined;
106
+ onTouchCancel?: undefined;
107
+ onTouchMove?: undefined;
108
+ };
109
+ })[];
110
+ };
111
+ }[TContainerA]> & React.ComponentProps<{
112
+ zoom: {
113
+ (initialProps: import("victory-zoom-container").VictoryZoomContainerProps): JSX.Element;
114
+ role: string;
115
+ defaultEvents(initialProps: import("victory-zoom-container").VictoryZoomContainerProps): {
116
+ target: string;
117
+ eventHandlers: {
118
+ onMouseDown: import("victory-core").VictoryEventHandler;
119
+ onTouchStart: import("victory-core").VictoryEventHandler;
120
+ onMouseUp: import("victory-core").VictoryEventHandler;
121
+ onTouchEnd: import("victory-core").VictoryEventHandler;
122
+ onMouseLeave: import("victory-core").VictoryEventHandler;
123
+ onTouchCancel: import("victory-core").VictoryEventHandler;
124
+ onMouseMove: import("victory-core").VictoryEventHandler;
125
+ onTouchMove: import("victory-core").VictoryEventHandler;
126
+ onWheel: import("victory-core").VictoryEventHandler;
127
+ };
128
+ }[];
129
+ };
130
+ selection: {
131
+ (initialProps: import("victory-selection-container").VictorySelectionContainerProps): JSX.Element;
132
+ role: string;
133
+ defaultEvents(initialProps: import("victory-selection-container").VictorySelectionContainerProps): {
134
+ target: string;
135
+ eventHandlers: {
136
+ onMouseDown: import("victory-core").VictoryEventHandler;
137
+ onTouchStart: import("victory-core").VictoryEventHandler;
138
+ onMouseMove: import("victory-core").VictoryEventHandler;
139
+ onTouchMove: import("victory-core").VictoryEventHandler;
140
+ onMouseUp: import("victory-core").VictoryEventHandler;
141
+ onTouchEnd: import("victory-core").VictoryEventHandler;
142
+ };
143
+ }[];
144
+ };
145
+ brush: {
146
+ (initialProps: import("victory-brush-container").VictoryBrushContainerProps): JSX.Element;
147
+ role: string;
148
+ defaultEvents(initialProps: import("victory-brush-container").VictoryBrushContainerProps): {
149
+ target: string;
150
+ eventHandlers: {
151
+ onMouseDown: import("victory-core").VictoryEventHandler;
152
+ onTouchStart: import("victory-core").VictoryEventHandler;
153
+ onGlobalMouseMove: import("victory-core").VictoryEventHandler;
154
+ onGlobalTouchMove: import("victory-core").VictoryEventHandler;
155
+ onGlobalMouseUp: import("victory-core").VictoryEventHandler;
156
+ onGlobalTouchEnd: import("victory-core").VictoryEventHandler;
157
+ onGlobalTouchCancel: import("victory-core").VictoryEventHandler;
158
+ };
159
+ }[];
160
+ };
161
+ cursor: {
162
+ (initialProps: import("victory-cursor-container").VictoryCursorContainerProps): JSX.Element;
163
+ role: string;
164
+ defaultEvents(initialProps: import("victory-cursor-container").VictoryCursorContainerProps): {
165
+ target: string;
166
+ eventHandlers: {
167
+ onMouseLeave: import("victory-core").VictoryEventHandler;
168
+ onMouseMove: import("victory-core").VictoryEventHandler;
169
+ onTouchMove: import("victory-core").VictoryEventHandler;
170
+ };
171
+ }[];
172
+ };
173
+ voronoi: {
174
+ (initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): JSX.Element;
175
+ role: string;
176
+ defaultEvents(initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): ({
177
+ target: string;
178
+ eventHandlers: {
179
+ onMouseLeave: import("victory-core").VictoryEventHandler;
180
+ onTouchCancel: import("victory-core").VictoryEventHandler;
181
+ onMouseMove: import("victory-core").VictoryEventHandler;
182
+ onTouchMove: import("victory-core").VictoryEventHandler;
183
+ onMouseOver?: undefined;
184
+ onMouseOut?: undefined;
185
+ };
186
+ } | {
187
+ target: string;
188
+ eventHandlers: {
189
+ onMouseLeave?: undefined;
190
+ onTouchCancel?: undefined;
191
+ onMouseMove?: undefined;
192
+ onTouchMove?: undefined;
193
+ onMouseOver?: undefined;
194
+ onMouseOut?: undefined;
195
+ } | {
196
+ onMouseOver: () => null;
197
+ onMouseOut: () => null;
198
+ onMouseMove: () => null;
199
+ onMouseLeave?: undefined;
200
+ onTouchCancel?: undefined;
201
+ onTouchMove?: undefined;
202
+ };
203
+ })[];
204
+ };
205
+ }[TContainerB]>): JSX.Element;
24
206
  displayName: string;
25
- propTypes: any;
26
- defaultProps: any;
27
- defaultEvents(props: any): ({
28
- target: string;
29
- eventHandlers: any;
30
- } | null)[];
31
- };
32
- export declare const createContainer: (behaviorA: ContainerType, behaviorB: ContainerType, ...invalid: ContainerType[]) => React.ComponentType<any> | {
33
- new (): {
34
- [x: string]: any;
35
- getChildren(props: any): any;
36
- };
37
- [x: string]: any;
38
- displayName: string;
39
- propTypes: any;
40
- defaultProps: any;
41
- defaultEvents(props: any): ({
207
+ role: string;
208
+ defaultEvents(props: React.ComponentProps<{
209
+ zoom: {
210
+ (initialProps: import("victory-zoom-container").VictoryZoomContainerProps): JSX.Element;
211
+ role: string;
212
+ defaultEvents(initialProps: import("victory-zoom-container").VictoryZoomContainerProps): {
213
+ target: string;
214
+ eventHandlers: {
215
+ onMouseDown: import("victory-core").VictoryEventHandler;
216
+ onTouchStart: import("victory-core").VictoryEventHandler;
217
+ onMouseUp: import("victory-core").VictoryEventHandler;
218
+ onTouchEnd: import("victory-core").VictoryEventHandler;
219
+ onMouseLeave: import("victory-core").VictoryEventHandler;
220
+ onTouchCancel: import("victory-core").VictoryEventHandler;
221
+ onMouseMove: import("victory-core").VictoryEventHandler;
222
+ onTouchMove: import("victory-core").VictoryEventHandler;
223
+ onWheel: import("victory-core").VictoryEventHandler;
224
+ };
225
+ }[];
226
+ };
227
+ selection: {
228
+ (initialProps: import("victory-selection-container").VictorySelectionContainerProps): JSX.Element;
229
+ role: string;
230
+ defaultEvents(initialProps: import("victory-selection-container").VictorySelectionContainerProps): {
231
+ target: string;
232
+ eventHandlers: {
233
+ onMouseDown: import("victory-core").VictoryEventHandler;
234
+ onTouchStart: import("victory-core").VictoryEventHandler;
235
+ onMouseMove: import("victory-core").VictoryEventHandler;
236
+ onTouchMove: import("victory-core").VictoryEventHandler;
237
+ onMouseUp: import("victory-core").VictoryEventHandler;
238
+ onTouchEnd: import("victory-core").VictoryEventHandler;
239
+ };
240
+ }[];
241
+ };
242
+ brush: {
243
+ (initialProps: import("victory-brush-container").VictoryBrushContainerProps): JSX.Element;
244
+ role: string;
245
+ defaultEvents(initialProps: import("victory-brush-container").VictoryBrushContainerProps): {
246
+ target: string;
247
+ eventHandlers: {
248
+ onMouseDown: import("victory-core").VictoryEventHandler;
249
+ onTouchStart: import("victory-core").VictoryEventHandler;
250
+ onGlobalMouseMove: import("victory-core").VictoryEventHandler;
251
+ onGlobalTouchMove: import("victory-core").VictoryEventHandler;
252
+ onGlobalMouseUp: import("victory-core").VictoryEventHandler;
253
+ onGlobalTouchEnd: import("victory-core").VictoryEventHandler;
254
+ onGlobalTouchCancel: import("victory-core").VictoryEventHandler;
255
+ };
256
+ }[];
257
+ };
258
+ cursor: {
259
+ (initialProps: import("victory-cursor-container").VictoryCursorContainerProps): JSX.Element;
260
+ role: string;
261
+ defaultEvents(initialProps: import("victory-cursor-container").VictoryCursorContainerProps): {
262
+ target: string;
263
+ eventHandlers: {
264
+ onMouseLeave: import("victory-core").VictoryEventHandler;
265
+ onMouseMove: import("victory-core").VictoryEventHandler;
266
+ onTouchMove: import("victory-core").VictoryEventHandler;
267
+ };
268
+ }[];
269
+ };
270
+ voronoi: {
271
+ (initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): JSX.Element;
272
+ role: string;
273
+ defaultEvents(initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): ({
274
+ target: string;
275
+ eventHandlers: {
276
+ onMouseLeave: import("victory-core").VictoryEventHandler;
277
+ onTouchCancel: import("victory-core").VictoryEventHandler;
278
+ onMouseMove: import("victory-core").VictoryEventHandler;
279
+ onTouchMove: import("victory-core").VictoryEventHandler;
280
+ onMouseOver?: undefined;
281
+ onMouseOut?: undefined;
282
+ };
283
+ } | {
284
+ target: string;
285
+ eventHandlers: {
286
+ onMouseLeave?: undefined;
287
+ onTouchCancel?: undefined;
288
+ onMouseMove?: undefined;
289
+ onTouchMove?: undefined;
290
+ onMouseOver?: undefined;
291
+ onMouseOut?: undefined;
292
+ } | {
293
+ onMouseOver: () => null;
294
+ onMouseOut: () => null;
295
+ onMouseMove: () => null;
296
+ onMouseLeave?: undefined;
297
+ onTouchCancel?: undefined;
298
+ onTouchMove?: undefined;
299
+ };
300
+ })[];
301
+ };
302
+ }[TContainerA]> & React.ComponentProps<{
303
+ zoom: {
304
+ (initialProps: import("victory-zoom-container").VictoryZoomContainerProps): JSX.Element;
305
+ role: string;
306
+ defaultEvents(initialProps: import("victory-zoom-container").VictoryZoomContainerProps): {
307
+ target: string;
308
+ eventHandlers: {
309
+ onMouseDown: import("victory-core").VictoryEventHandler;
310
+ onTouchStart: import("victory-core").VictoryEventHandler;
311
+ onMouseUp: import("victory-core").VictoryEventHandler;
312
+ onTouchEnd: import("victory-core").VictoryEventHandler;
313
+ onMouseLeave: import("victory-core").VictoryEventHandler;
314
+ onTouchCancel: import("victory-core").VictoryEventHandler;
315
+ onMouseMove: import("victory-core").VictoryEventHandler;
316
+ onTouchMove: import("victory-core").VictoryEventHandler;
317
+ onWheel: import("victory-core").VictoryEventHandler;
318
+ };
319
+ }[];
320
+ };
321
+ selection: {
322
+ (initialProps: import("victory-selection-container").VictorySelectionContainerProps): JSX.Element;
323
+ role: string;
324
+ defaultEvents(initialProps: import("victory-selection-container").VictorySelectionContainerProps): {
325
+ target: string;
326
+ eventHandlers: {
327
+ onMouseDown: import("victory-core").VictoryEventHandler;
328
+ onTouchStart: import("victory-core").VictoryEventHandler;
329
+ onMouseMove: import("victory-core").VictoryEventHandler;
330
+ onTouchMove: import("victory-core").VictoryEventHandler;
331
+ onMouseUp: import("victory-core").VictoryEventHandler;
332
+ onTouchEnd: import("victory-core").VictoryEventHandler;
333
+ };
334
+ }[];
335
+ };
336
+ brush: {
337
+ (initialProps: import("victory-brush-container").VictoryBrushContainerProps): JSX.Element;
338
+ role: string;
339
+ defaultEvents(initialProps: import("victory-brush-container").VictoryBrushContainerProps): {
340
+ target: string;
341
+ eventHandlers: {
342
+ onMouseDown: import("victory-core").VictoryEventHandler;
343
+ onTouchStart: import("victory-core").VictoryEventHandler;
344
+ onGlobalMouseMove: import("victory-core").VictoryEventHandler;
345
+ onGlobalTouchMove: import("victory-core").VictoryEventHandler;
346
+ onGlobalMouseUp: import("victory-core").VictoryEventHandler;
347
+ onGlobalTouchEnd: import("victory-core").VictoryEventHandler;
348
+ onGlobalTouchCancel: import("victory-core").VictoryEventHandler;
349
+ };
350
+ }[];
351
+ };
352
+ cursor: {
353
+ (initialProps: import("victory-cursor-container").VictoryCursorContainerProps): JSX.Element;
354
+ role: string;
355
+ defaultEvents(initialProps: import("victory-cursor-container").VictoryCursorContainerProps): {
356
+ target: string;
357
+ eventHandlers: {
358
+ onMouseLeave: import("victory-core").VictoryEventHandler;
359
+ onMouseMove: import("victory-core").VictoryEventHandler;
360
+ onTouchMove: import("victory-core").VictoryEventHandler;
361
+ };
362
+ }[];
363
+ };
364
+ voronoi: {
365
+ (initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): JSX.Element;
366
+ role: string;
367
+ defaultEvents(initialProps: import("victory-voronoi-container").VictoryVoronoiContainerProps): ({
368
+ target: string;
369
+ eventHandlers: {
370
+ onMouseLeave: import("victory-core").VictoryEventHandler;
371
+ onTouchCancel: import("victory-core").VictoryEventHandler;
372
+ onMouseMove: import("victory-core").VictoryEventHandler;
373
+ onTouchMove: import("victory-core").VictoryEventHandler;
374
+ onMouseOver?: undefined;
375
+ onMouseOut?: undefined;
376
+ };
377
+ } | {
378
+ target: string;
379
+ eventHandlers: {
380
+ onMouseLeave?: undefined;
381
+ onTouchCancel?: undefined;
382
+ onMouseMove?: undefined;
383
+ onTouchMove?: undefined;
384
+ onMouseOver?: undefined;
385
+ onMouseOut?: undefined;
386
+ } | {
387
+ onMouseOver: () => null;
388
+ onMouseOut: () => null;
389
+ onMouseMove: () => null;
390
+ onMouseLeave?: undefined;
391
+ onTouchCancel?: undefined;
392
+ onTouchMove?: undefined;
393
+ };
394
+ })[];
395
+ };
396
+ }[TContainerB]>): ({
42
397
  target: string;
43
398
  eventHandlers: any;
44
399
  } | null)[];
@@ -3,18 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.makeCreateContainerFunction = exports.createContainer = exports.combineContainerMixins = void 0;
6
+ exports.createContainer = void 0;
7
+ exports.makeCreateContainerFunction = makeCreateContainerFunction;
8
+ var _toPairs2 = _interopRequireDefault(require("lodash/toPairs"));
7
9
  var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
8
- var _flow2 = _interopRequireDefault(require("lodash/flow"));
9
- var _forOwn2 = _interopRequireDefault(require("lodash/forOwn"));
10
10
  var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
11
- var _toPairs2 = _interopRequireDefault(require("lodash/toPairs"));
12
- var _victoryCore = require("victory-core");
13
- var _victoryVoronoiContainer = require("victory-voronoi-container");
11
+ var _forOwn2 = _interopRequireDefault(require("lodash/forOwn"));
14
12
  var _victoryZoomContainer = require("victory-zoom-container");
15
13
  var _victorySelectionContainer = require("victory-selection-container");
16
- var _victoryBrushContainer = require("victory-brush-container");
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _victoryCore = require("victory-core");
16
+ var _victoryVoronoiContainer = require("victory-voronoi-container");
17
17
  var _victoryCursorContainer = require("victory-cursor-container");
18
+ var _victoryBrushContainer = require("victory-brush-container");
18
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20
  function ensureArray(thing) {
20
21
  if (!thing) {
@@ -61,67 +62,55 @@ const combineDefaultEvents = defaultEvents => {
61
62
  });
62
63
  return events.filter(Boolean);
63
64
  };
64
- const combineContainerMixins = (mixins, Container) => {
65
- // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
66
- // this applies to propTypes and defaultProps.
67
- // getChildren will call A's getChildren() and pass the resulting children to B's.
68
- // defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
69
- const Classes = mixins.map(mixin => mixin(Container));
70
- const instances = Classes.map(Class => new Class());
71
- const NaiveCombinedContainer = (0, _flow2.default)(mixins)(Container);
72
- const displayType = Classes.map(Class => {
73
- const match = Class.displayName.match(/Victory(.*)Container/);
74
- return match[1] || "";
75
- }).join("");
76
- return class VictoryCombinedContainer extends NaiveCombinedContainer {
77
- static displayName = `Victory${displayType}Container`;
78
- static propTypes = Classes.reduce((propTypes, Class) => ({
79
- ...propTypes,
80
- ...Class.propTypes
81
- }), {});
82
- static defaultProps = Classes.reduce((defaultProps, Class) => ({
83
- ...defaultProps,
84
- ...Class.defaultProps
85
- }), {});
86
- static defaultEvents(props) {
87
- return combineDefaultEvents(Classes.reduce((defaultEvents, Class) => {
88
- const events = _victoryCore.Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
89
- return [...defaultEvents, ...events];
90
- }, []));
91
- }
92
- getChildren(props) {
93
- return instances.reduce((children, instance) => instance.getChildren({
94
- ...props,
95
- children
96
- }), props.children);
97
- }
98
- };
99
- };
100
- exports.combineContainerMixins = combineContainerMixins;
101
- const checkBehaviorName = (behavior, behaviors) => {
102
- if (behavior && !behaviors.includes(behavior)) {
103
- _victoryCore.Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
104
- }
65
+ /**
66
+ * Container hooks are used to provide the container logic to the container components through props and a modified children object
67
+ * - These hooks contain shared logic for both web and Victory Native containers.
68
+ * - In this utility, we call multiple of these hooks with the props returned by the previous to combine the container logic.
69
+ */
70
+ const CONTAINER_HOOKS = {
71
+ zoom: _victoryZoomContainer.useVictoryZoomContainer,
72
+ selection: _victorySelectionContainer.useVictorySelectionContainer,
73
+ brush: _victoryBrushContainer.useVictoryBrushContainer,
74
+ cursor: _victoryCursorContainer.useVictoryCursorContainer,
75
+ voronoi: _victoryVoronoiContainer.useVictoryVoronoiContainer
105
76
  };
106
- const makeCreateContainerFunction = (mixinMap, Container) => function (behaviorA, behaviorB) {
107
- const behaviors = Object.keys(mixinMap);
108
- checkBehaviorName(behaviorA, behaviors);
109
- checkBehaviorName(behaviorB, behaviors);
110
- if (arguments.length <= 2 ? 0 : arguments.length - 2) {
111
- _victoryCore.Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
112
- }
113
- const firstMixins = mixinMap[behaviorA];
114
- const secondMixins = mixinMap[behaviorB] || [];
115
- if (!firstMixins) {
116
- return Container;
117
- }
118
- return combineContainerMixins([...firstMixins, ...secondMixins], Container);
77
+
78
+ /**
79
+ * Container hooks are wrappers that return a VictoryContainer with the props provided by their respective hooks, and the modified children.
80
+ * - These containers are specific to the web. Victory Native has its own container components.
81
+ * - For this utility, we only need the container components to extract the defaultEvents.
82
+ */
83
+ const CONTAINER_COMPONENTS_WEB = {
84
+ zoom: _victoryZoomContainer.VictoryZoomContainer,
85
+ selection: _victorySelectionContainer.VictorySelectionContainer,
86
+ brush: _victoryBrushContainer.VictoryBrushContainer,
87
+ cursor: _victoryCursorContainer.VictoryCursorContainer,
88
+ voronoi: _victoryVoronoiContainer.VictoryVoronoiContainer
119
89
  };
120
- exports.makeCreateContainerFunction = makeCreateContainerFunction;
121
- const createContainer = exports.createContainer = makeCreateContainerFunction({
122
- zoom: [_victoryZoomContainer.zoomContainerMixin],
123
- voronoi: [_victoryVoronoiContainer.voronoiContainerMixin],
124
- selection: [_victorySelectionContainer.selectionContainerMixin],
125
- cursor: [_victoryCursorContainer.cursorContainerMixin],
126
- brush: [_victoryBrushContainer.brushContainerMixin]
127
- }, _victoryCore.VictoryContainer);
90
+ function makeCreateContainerFunction(containerComponents, VictoryContainerBase) {
91
+ return function combineContainers(containerA, containerB) {
92
+ const ContainerA = containerComponents[containerA];
93
+ const ContainerB = containerComponents[containerB];
94
+ const useContainerA = CONTAINER_HOOKS[containerA];
95
+ const useContainerB = CONTAINER_HOOKS[containerB];
96
+ const CombinedContainer = props => {
97
+ const {
98
+ children: childrenA,
99
+ props: propsA
100
+ } = useContainerA(props);
101
+ const {
102
+ children: combinedChildren,
103
+ props: combinedProps
104
+ } = useContainerB({
105
+ ...propsA,
106
+ children: childrenA
107
+ });
108
+ return /*#__PURE__*/_react.default.createElement(VictoryContainerBase, combinedProps, combinedChildren);
109
+ };
110
+ CombinedContainer.displayName = `Victory${containerA}${containerB}Container`;
111
+ CombinedContainer.role = "container";
112
+ CombinedContainer.defaultEvents = props => combineDefaultEvents([...ContainerA.defaultEvents(props), ...ContainerB.defaultEvents(props)]);
113
+ return CombinedContainer;
114
+ };
115
+ }
116
+ const createContainer = exports.createContainer = makeCreateContainerFunction(CONTAINER_COMPONENTS_WEB, _victoryCore.VictoryContainer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-create-container",
3
- "version": "37.0.2",
3
+ "version": "37.1.0",
4
4
  "description": "Container Helper for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -21,12 +21,12 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
- "victory-brush-container": "^37.0.2",
25
- "victory-core": "^37.0.2",
26
- "victory-cursor-container": "^37.0.2",
27
- "victory-selection-container": "^37.0.2",
28
- "victory-voronoi-container": "^37.0.2",
29
- "victory-zoom-container": "^37.0.2"
24
+ "victory-brush-container": "37.1.0",
25
+ "victory-core": "37.1.0",
26
+ "victory-cursor-container": "37.1.0",
27
+ "victory-selection-container": "37.1.0",
28
+ "victory-voronoi-container": "37.1.0",
29
+ "victory-zoom-container": "37.1.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.6.0"