victory-create-container 36.9.2-next.1 → 36.9.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.
@@ -1,402 +1,47 @@
1
- import React from "react";
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;
9
- displayName: string;
10
- role: string;
11
- defaultEvents(props: React.ComponentProps<TContainerComponents[TContainerA]> & React.ComponentProps<TContainerComponents[TContainerB]>): ({
12
- target: string;
13
- eventHandlers: any;
14
- } | null)[];
15
- };
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;
206
- displayName: string;
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]>): ({
397
- target: string;
398
- eventHandlers: any;
399
- } | null)[];
400
- };
401
- export {};
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;
10
+ displayName: string;
11
+ propTypes: any;
12
+ defaultProps: any;
13
+ defaultEvents: (props: any) => ({
14
+ target: string;
15
+ eventHandlers: any;
16
+ } | null)[];
17
+ };
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;
24
+ 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) => ({
42
+ target: string;
43
+ eventHandlers: any;
44
+ } | null)[];
45
+ };
46
+ export {};
402
47
  //# sourceMappingURL=create-container.d.ts.map
@@ -1,7 +1,8 @@
1
- import _toPairs from "lodash/toPairs";
2
1
  import _isEmpty from "lodash/isEmpty";
3
- import _groupBy from "lodash/groupBy";
2
+ import _flow from "lodash/flow";
4
3
  import _forOwn from "lodash/forOwn";
4
+ import _groupBy from "lodash/groupBy";
5
+ import _toPairs from "lodash/toPairs";
5
6
 
6
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
8
 
@@ -17,6 +18,26 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
18
 
18
19
  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; }
19
20
 
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ 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); } }
24
+
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+
27
+ 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); }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ 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); }; }
32
+
33
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
34
+
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+
37
+ 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; } }
38
+
39
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+
20
41
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
42
 
22
43
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -29,13 +50,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
29
50
 
30
51
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
52
 
32
- import { VictoryZoomContainer, useVictoryZoomContainer } from "victory-zoom-container";
33
- import { VictorySelectionContainer, useVictorySelectionContainer } from "victory-selection-container";
34
- import React from "react";
35
- import { VictoryContainer } from "victory-core";
36
- import { VictoryVoronoiContainer, useVictoryVoronoiContainer } from "victory-voronoi-container";
37
- import { VictoryCursorContainer, useVictoryCursorContainer } from "victory-cursor-container";
38
- import { VictoryBrushContainer, useVictoryBrushContainer } from "victory-brush-container";
53
+ import { Helpers, VictoryContainer, Log } from "victory-core";
54
+ import { voronoiContainerMixin } from "victory-voronoi-container";
55
+ import { zoomContainerMixin } from "victory-zoom-container";
56
+ import { selectionContainerMixin } from "victory-selection-container";
57
+ import { brushContainerMixin } from "victory-brush-container";
58
+ import { cursorContainerMixin } from "victory-cursor-container";
39
59
 
40
60
  function ensureArray(thing) {
41
61
  if (!thing) {
@@ -95,60 +115,91 @@ var combineDefaultEvents = function (defaultEvents) {
95
115
  return events.filter(Boolean);
96
116
  };
97
117
 
98
- /**
99
- * Container hooks are used to provide the container logic to the container components through props and a modified children object
100
- * - These hooks contain shared logic for both web and Victory Native containers.
101
- * - In this utility, we call multiple of these hooks with the props returned by the previous to combine the container logic.
102
- */
103
- var CONTAINER_HOOKS = {
104
- zoom: useVictoryZoomContainer,
105
- selection: useVictorySelectionContainer,
106
- brush: useVictoryBrushContainer,
107
- cursor: useVictoryCursorContainer,
108
- voronoi: useVictoryVoronoiContainer
118
+ export var combineContainerMixins = function (mixins, Container) {
119
+ var _class;
120
+
121
+ // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
122
+ // this applies to propTypes and defaultProps.
123
+ // getChildren will call A's getChildren() and pass the resulting children to B's.
124
+ // defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
125
+ var Classes = mixins.map(function (mixin) {
126
+ return mixin(Container);
127
+ });
128
+ var instances = Classes.map(function (Class) {
129
+ return new Class();
130
+ });
131
+
132
+ var NaiveCombinedContainer = _flow(mixins)(Container);
133
+
134
+ var displayType = Classes.map(function (Class) {
135
+ var match = Class.displayName.match(/Victory(.*)Container/);
136
+ return match[1] || "";
137
+ }).join("");
138
+ return _class = /*#__PURE__*/function (_NaiveCombinedContain) {
139
+ _inherits(VictoryCombinedContainer, _NaiveCombinedContain);
140
+
141
+ var _super = _createSuper(VictoryCombinedContainer);
142
+
143
+ function VictoryCombinedContainer() {
144
+ _classCallCheck(this, VictoryCombinedContainer);
145
+
146
+ return _super.apply(this, arguments);
147
+ }
148
+
149
+ _createClass(VictoryCombinedContainer, [{
150
+ key: "getChildren",
151
+ value: function getChildren(props) {
152
+ return instances.reduce(function (children, instance) {
153
+ return instance.getChildren(_objectSpread(_objectSpread({}, props), {}, {
154
+ children: children
155
+ }));
156
+ }, props.children);
157
+ }
158
+ }]);
159
+
160
+ return VictoryCombinedContainer;
161
+ }(NaiveCombinedContainer), _class.displayName = "Victory".concat(displayType, "Container"), _class.propTypes = Classes.reduce(function (propTypes, Class) {
162
+ return _objectSpread(_objectSpread({}, propTypes), Class.propTypes);
163
+ }, {}), _class.defaultProps = Classes.reduce(function (defaultProps, Class) {
164
+ return _objectSpread(_objectSpread({}, defaultProps), Class.defaultProps);
165
+ }, {}), _class.defaultEvents = function (props) {
166
+ return combineDefaultEvents(Classes.reduce(function (defaultEvents, Class) {
167
+ var events = Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
168
+ return [].concat(_toConsumableArray(defaultEvents), _toConsumableArray(events));
169
+ }, []));
170
+ }, _class;
109
171
  };
110
- /**
111
- * Container hooks are wrappers that return a VictoryContainer with the props provided by their respective hooks, and the modified children.
112
- * - These containers are specific to the web. Victory Native has its own container components.
113
- * - For this utility, we only need the container components to extract the defaultEvents.
114
- */
115
-
116
- var CONTAINER_COMPONENTS = {
117
- zoom: VictoryZoomContainer,
118
- selection: VictorySelectionContainer,
119
- brush: VictoryBrushContainer,
120
- cursor: VictoryCursorContainer,
121
- voronoi: VictoryVoronoiContainer
172
+
173
+ var checkBehaviorName = function (behavior, behaviors) {
174
+ if (behavior && !behaviors.includes(behavior)) {
175
+ Log.warn("\"".concat(behavior, "\" is not a valid behavior. Choose from [").concat(behaviors.join(", "), "]."));
176
+ }
122
177
  };
123
- export function makeCreateContainerFunction(containerComponents, VictoryContainerBase) {
124
- return function combineContainers(containerA, containerB) {
125
- var ContainerA = containerComponents[containerA];
126
- var ContainerB = containerComponents[containerB];
127
- var useContainerA = CONTAINER_HOOKS[containerA];
128
- var useContainerB = CONTAINER_HOOKS[containerB];
129
-
130
- var CombinedContainer = function (props) {
131
- var _useContainerA = useContainerA(props),
132
- childrenA = _useContainerA.children,
133
- propsA = _useContainerA.props;
134
-
135
- var _useContainerB = useContainerB(_objectSpread(_objectSpread({}, propsA), {}, {
136
- children: childrenA
137
- })),
138
- combinedChildren = _useContainerB.children,
139
- combinedProps = _useContainerB.props;
140
-
141
- return /*#__PURE__*/React.createElement(VictoryContainerBase, combinedProps, combinedChildren);
142
- };
143
178
 
144
- CombinedContainer.displayName = "Victory".concat(containerA).concat(containerB, "Container");
145
- CombinedContainer.role = "container";
179
+ export var makeCreateContainerFunction = function (mixinMap, Container) {
180
+ return function (behaviorA, behaviorB) {
181
+ var behaviors = Object.keys(mixinMap);
182
+ checkBehaviorName(behaviorA, behaviors);
183
+ checkBehaviorName(behaviorB, behaviors);
146
184
 
147
- CombinedContainer.defaultEvents = function (props) {
148
- return combineDefaultEvents([].concat(_toConsumableArray(ContainerA.defaultEvents(props)), _toConsumableArray(ContainerB.defaultEvents(props))));
149
- };
185
+ if (arguments.length <= 2 ? 0 : arguments.length - 2) {
186
+ Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
187
+ }
150
188
 
151
- return CombinedContainer;
189
+ var firstMixins = mixinMap[behaviorA];
190
+ var secondMixins = mixinMap[behaviorB] || [];
191
+
192
+ if (!firstMixins) {
193
+ return Container;
194
+ }
195
+
196
+ return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
152
197
  };
153
- }
154
- export var createContainer = makeCreateContainerFunction(CONTAINER_COMPONENTS, VictoryContainer);
198
+ };
199
+ export var createContainer = makeCreateContainerFunction({
200
+ zoom: [zoomContainerMixin],
201
+ voronoi: [voronoiContainerMixin],
202
+ selection: [selectionContainerMixin],
203
+ cursor: [cursorContainerMixin],
204
+ brush: [brushContainerMixin]
205
+ }, VictoryContainer);
package/es/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./create-container";
1
+ export * from "./create-container";
2
2
  //# sourceMappingURL=index.d.ts.map