victory-create-container 36.8.2 → 36.8.3

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.
@@ -0,0 +1,47 @@
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 {};
47
+ //# sourceMappingURL=create-container.d.ts.map
@@ -1,4 +1,3 @@
1
- import _keys from "lodash/keys";
2
1
  import _isFunction from "lodash/isFunction";
3
2
  import _isEmpty from "lodash/isEmpty";
4
3
  import _flow from "lodash/flow";
@@ -60,7 +59,7 @@ import { selectionContainerMixin } from "victory-selection-container";
60
59
  import { brushContainerMixin } from "victory-brush-container";
61
60
  import { cursorContainerMixin } from "victory-cursor-container";
62
61
 
63
- var ensureArray = function (thing) {
62
+ function ensureArray(thing) {
64
63
  if (!thing) {
65
64
  return [];
66
65
  } else if (!Array.isArray(thing)) {
@@ -68,7 +67,7 @@ var ensureArray = function (thing) {
68
67
  }
69
68
 
70
69
  return thing;
71
- };
70
+ }
72
71
 
73
72
  var combineEventHandlers = function (eventHandlersArray) {
74
73
  // takes an array of event handler objects and produces one eventHandlers object
@@ -105,8 +104,8 @@ var combineDefaultEvents = function (defaultEvents) {
105
104
  target = _ref2[0],
106
105
  eventsArray = _ref2[1];
107
106
 
108
- eventsArray = eventsArray.filter(Boolean);
109
- return _isEmpty(eventsArray) ? null : {
107
+ var newEventsArray = eventsArray.filter(Boolean);
108
+ return _isEmpty(newEventsArray) ? null : {
110
109
  target: target,
111
110
  eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
112
111
  return event.eventHandlers;
@@ -118,7 +117,7 @@ var combineDefaultEvents = function (defaultEvents) {
118
117
  return events.filter(Boolean);
119
118
  };
120
119
 
121
- var combineContainerMixins = function (mixins, Container) {
120
+ export var combineContainerMixins = function (mixins, Container) {
122
121
  var _class;
123
122
 
124
123
  // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
@@ -179,10 +178,9 @@ var checkBehaviorName = function (behavior, behaviors) {
179
178
  }
180
179
  };
181
180
 
182
- var makeCreateContainerFunction = function (mixinMap, Container) {
181
+ export var makeCreateContainerFunction = function (mixinMap, Container) {
183
182
  return function (behaviorA, behaviorB) {
184
- var behaviors = _keys(mixinMap);
185
-
183
+ var behaviors = Object.keys(mixinMap);
186
184
  checkBehaviorName(behaviorA, behaviors);
187
185
  checkBehaviorName(behaviorB, behaviors);
188
186
 
@@ -200,12 +198,10 @@ var makeCreateContainerFunction = function (mixinMap, Container) {
200
198
  return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
201
199
  };
202
200
  };
203
-
204
- var createContainer = makeCreateContainerFunction({
201
+ export var createContainer = makeCreateContainerFunction({
205
202
  zoom: [zoomContainerMixin],
206
203
  voronoi: [voronoiContainerMixin],
207
204
  selection: [selectionContainerMixin],
208
205
  cursor: [cursorContainerMixin],
209
206
  brush: [brushContainerMixin]
210
- }, VictoryContainer);
211
- export { createContainer, makeCreateContainerFunction, combineContainerMixins };
207
+ }, VictoryContainer);
package/es/index.d.ts CHANGED
@@ -1,19 +1,2 @@
1
- import * as React from "react";
2
-
3
- export type ContainerType =
4
- | "brush"
5
- | "cursor"
6
- | "selection"
7
- | "voronoi"
8
- | "zoom";
9
- export function createContainer<V, W>(
10
- c1: ContainerType,
11
- c2: ContainerType,
12
- ): React.ComponentType<V & W>;
13
-
14
- export function combineContainerMixins(mixins: any, Container: any): any;
15
-
16
- export const makeCreateContainerFunction: (
17
- mixinMap: any,
18
- Container: any,
19
- ) => (behaviorA: any, behaviorB: any) => any;
1
+ export * from "./create-container";
2
+ //# sourceMappingURL=index.d.ts.map
package/es/index.js CHANGED
@@ -1 +1 @@
1
- export { combineContainerMixins, makeCreateContainerFunction, createContainer } from "./create-container";
1
+ export * from "./create-container";
@@ -0,0 +1,47 @@
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 {};
47
+ //# sourceMappingURL=create-container.d.ts.map
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.makeCreateContainerFunction = exports.createContainer = exports.combineContainerMixins = void 0;
7
7
 
8
- var _keys2 = _interopRequireDefault(require("lodash/keys"));
9
-
10
8
  var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
11
9
 
12
10
  var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
@@ -81,7 +79,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
81
79
 
82
80
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
83
81
 
84
- var ensureArray = function (thing) {
82
+ function ensureArray(thing) {
85
83
  if (!thing) {
86
84
  return [];
87
85
  } else if (!Array.isArray(thing)) {
@@ -89,7 +87,7 @@ var ensureArray = function (thing) {
89
87
  }
90
88
 
91
89
  return thing;
92
- };
90
+ }
93
91
 
94
92
  var combineEventHandlers = function (eventHandlersArray) {
95
93
  // takes an array of event handler objects and produces one eventHandlers object
@@ -124,8 +122,8 @@ var combineDefaultEvents = function (defaultEvents) {
124
122
  target = _ref2[0],
125
123
  eventsArray = _ref2[1];
126
124
 
127
- eventsArray = eventsArray.filter(Boolean);
128
- return (0, _isEmpty2.default)(eventsArray) ? null : {
125
+ var newEventsArray = eventsArray.filter(Boolean);
126
+ return (0, _isEmpty2.default)(newEventsArray) ? null : {
129
127
  target: target,
130
128
  eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
131
129
  return event.eventHandlers;
@@ -199,7 +197,7 @@ var checkBehaviorName = function (behavior, behaviors) {
199
197
 
200
198
  var makeCreateContainerFunction = function (mixinMap, Container) {
201
199
  return function (behaviorA, behaviorB) {
202
- var behaviors = (0, _keys2.default)(mixinMap);
200
+ var behaviors = Object.keys(mixinMap);
203
201
  checkBehaviorName(behaviorA, behaviors);
204
202
  checkBehaviorName(behaviorB, behaviors);
205
203
 
package/lib/index.d.ts CHANGED
@@ -1,19 +1,2 @@
1
- import * as React from "react";
2
-
3
- export type ContainerType =
4
- | "brush"
5
- | "cursor"
6
- | "selection"
7
- | "voronoi"
8
- | "zoom";
9
- export function createContainer<V, W>(
10
- c1: ContainerType,
11
- c2: ContainerType,
12
- ): React.ComponentType<V & W>;
13
-
14
- export function combineContainerMixins(mixins: any, Container: any): any;
15
-
16
- export const makeCreateContainerFunction: (
17
- mixinMap: any,
18
- Container: any,
19
- ) => (behaviorA: any, behaviorB: any) => any;
1
+ export * from "./create-container";
2
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -3,23 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "combineContainerMixins", {
7
- enumerable: true,
8
- get: function () {
9
- return _createContainer.combineContainerMixins;
10
- }
11
- });
12
- Object.defineProperty(exports, "createContainer", {
13
- enumerable: true,
14
- get: function () {
15
- return _createContainer.createContainer;
16
- }
17
- });
18
- Object.defineProperty(exports, "makeCreateContainerFunction", {
19
- enumerable: true,
20
- get: function () {
21
- return _createContainer.makeCreateContainerFunction;
22
- }
23
- });
24
6
 
25
- var _createContainer = require("./create-container");
7
+ var _createContainer = require("./create-container");
8
+
9
+ Object.keys(_createContainer).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _createContainer[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _createContainer[key];
16
+ }
17
+ });
18
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-create-container",
3
- "version": "36.8.2",
3
+ "version": "36.8.3",
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": "^36.8.2",
25
- "victory-core": "^36.8.2",
26
- "victory-cursor-container": "^36.8.2",
27
- "victory-selection-container": "^36.8.2",
28
- "victory-voronoi-container": "^36.8.2",
29
- "victory-zoom-container": "^36.8.2"
24
+ "victory-brush-container": "^36.8.3",
25
+ "victory-core": "^36.8.3",
26
+ "victory-cursor-container": "^36.8.3",
27
+ "victory-selection-container": "^36.8.3",
28
+ "victory-voronoi-container": "^36.8.3",
29
+ "victory-zoom-container": "^36.8.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.6.0"
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import {
2
3
  toPairs,
3
4
  groupBy,
@@ -6,7 +7,6 @@ import {
6
7
  flow,
7
8
  isEmpty,
8
9
  isFunction,
9
- keys,
10
10
  } from "lodash";
11
11
  import { VictoryContainer, Log } from "victory-core";
12
12
  import { voronoiContainerMixin } from "victory-voronoi-container";
@@ -15,16 +15,25 @@ import { selectionContainerMixin } from "victory-selection-container";
15
15
  import { brushContainerMixin } from "victory-brush-container";
16
16
  import { cursorContainerMixin } from "victory-cursor-container";
17
17
 
18
- const ensureArray = (thing) => {
18
+ export type ContainerType =
19
+ | "brush"
20
+ | "cursor"
21
+ | "selection"
22
+ | "voronoi"
23
+ | "zoom";
24
+
25
+ type MixinFunction = (...args: any[]) => any;
26
+
27
+ function ensureArray<T>(thing: T): [] | T | T[] {
19
28
  if (!thing) {
20
29
  return [];
21
30
  } else if (!Array.isArray(thing)) {
22
31
  return [thing];
23
32
  }
24
33
  return thing;
25
- };
34
+ }
26
35
 
27
- const combineEventHandlers = (eventHandlersArray) => {
36
+ const combineEventHandlers = (eventHandlersArray: any[]) => {
28
37
  // takes an array of event handler objects and produces one eventHandlers object
29
38
  // creates a custom combinedHandler() for events with multiple conflicting handlers
30
39
  return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
@@ -47,13 +56,13 @@ const combineEventHandlers = (eventHandlersArray) => {
47
56
  });
48
57
  };
49
58
 
50
- const combineDefaultEvents = (defaultEvents) => {
59
+ const combineDefaultEvents = (defaultEvents: any[]) => {
51
60
  // takes a defaultEvents array and returns one equal or lesser length,
52
61
  // by combining any events that have the same target
53
62
  const eventsByTarget = groupBy(defaultEvents, "target");
54
63
  const events = toPairs(eventsByTarget).map(([target, eventsArray]) => {
55
- eventsArray = eventsArray.filter(Boolean);
56
- return isEmpty(eventsArray)
64
+ const newEventsArray = eventsArray.filter(Boolean);
65
+ return isEmpty(newEventsArray)
57
66
  ? null
58
67
  : {
59
68
  target,
@@ -66,12 +75,14 @@ const combineDefaultEvents = (defaultEvents) => {
66
75
  return events.filter(Boolean);
67
76
  };
68
77
 
69
- const combineContainerMixins = (mixins, Container) => {
78
+ export const combineContainerMixins = (
79
+ mixins: MixinFunction[],
80
+ Container: React.ComponentType<any>,
81
+ ) => {
70
82
  // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
71
83
  // this applies to propTypes and defaultProps.
72
84
  // getChildren will call A's getChildren() and pass the resulting children to B's.
73
85
  // defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
74
-
75
86
  const Classes = mixins.map((mixin) => mixin(Container));
76
87
  const instances = Classes.map((Class) => new Class());
77
88
  const NaiveCombinedContainer = flow(mixins)(Container);
@@ -114,7 +125,10 @@ const combineContainerMixins = (mixins, Container) => {
114
125
  };
115
126
  };
116
127
 
117
- const checkBehaviorName = (behavior, behaviors) => {
128
+ const checkBehaviorName = (
129
+ behavior: ContainerType,
130
+ behaviors: ContainerType[],
131
+ ) => {
118
132
  if (behavior && !includes(behaviors, behavior)) {
119
133
  Log.warn(
120
134
  `"${behavior}" is not a valid behavior. Choose from [${behaviors.join(
@@ -124,10 +138,17 @@ const checkBehaviorName = (behavior, behaviors) => {
124
138
  }
125
139
  };
126
140
 
127
- const makeCreateContainerFunction =
128
- (mixinMap, Container) =>
129
- (behaviorA, behaviorB, ...invalid) => {
130
- const behaviors = keys(mixinMap);
141
+ export const makeCreateContainerFunction =
142
+ (
143
+ mixinMap: Record<ContainerType, MixinFunction[]>,
144
+ Container: React.ComponentType<any>,
145
+ ) =>
146
+ (
147
+ behaviorA: ContainerType,
148
+ behaviorB: ContainerType,
149
+ ...invalid: ContainerType[]
150
+ ) => {
151
+ const behaviors = Object.keys(mixinMap) as ContainerType[];
131
152
 
132
153
  checkBehaviorName(behaviorA, behaviors);
133
154
  checkBehaviorName(behaviorB, behaviors);
@@ -148,7 +169,7 @@ const makeCreateContainerFunction =
148
169
  return combineContainerMixins([...firstMixins, ...secondMixins], Container);
149
170
  };
150
171
 
151
- const createContainer = makeCreateContainerFunction(
172
+ export const createContainer = makeCreateContainerFunction(
152
173
  {
153
174
  zoom: [zoomContainerMixin],
154
175
  voronoi: [voronoiContainerMixin],
@@ -158,5 +179,3 @@ const createContainer = makeCreateContainerFunction(
158
179
  },
159
180
  VictoryContainer,
160
181
  );
161
-
162
- export { createContainer, makeCreateContainerFunction, combineContainerMixins };
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./create-container";
package/src/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
-
3
- export type ContainerType =
4
- | "brush"
5
- | "cursor"
6
- | "selection"
7
- | "voronoi"
8
- | "zoom";
9
- export function createContainer<V, W>(
10
- c1: ContainerType,
11
- c2: ContainerType,
12
- ): React.ComponentType<V & W>;
13
-
14
- export function combineContainerMixins(mixins: any, Container: any): any;
15
-
16
- export const makeCreateContainerFunction: (
17
- mixinMap: any,
18
- Container: any,
19
- ) => (behaviorA: any, behaviorB: any) => any;
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- export {
2
- combineContainerMixins,
3
- makeCreateContainerFunction,
4
- createContainer,
5
- } from "./create-container";