victory-core 36.5.1 → 36.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,12 +23,12 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
23
23
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
24
|
|
|
25
25
|
import * as React from "react";
|
|
26
|
-
import { createContext,
|
|
26
|
+
import { createContext, useContext } from "react";
|
|
27
27
|
import { getData } from "./helpers/get-data";
|
|
28
28
|
import { getDomain } from "./helpers/get-domain";
|
|
29
29
|
import { getRange } from "./helpers/get-range";
|
|
30
30
|
import { getScale } from "./helpers/get-scale";
|
|
31
|
-
var VictoryContext = createContext(null);
|
|
31
|
+
var VictoryContext = /*#__PURE__*/createContext(null);
|
|
32
32
|
export function VictoryProvider(_ref) {
|
|
33
33
|
var children = _ref.children,
|
|
34
34
|
initialProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -82,13 +82,13 @@ export function VictoryProvider(_ref) {
|
|
|
82
82
|
}, children);
|
|
83
83
|
}
|
|
84
84
|
export function useVictoryContext(selector) {
|
|
85
|
-
|
|
86
|
-
if (!context) {
|
|
87
|
-
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
88
|
-
}
|
|
85
|
+
var context = useContext(VictoryContext);
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
if (!context) {
|
|
88
|
+
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return selector(context);
|
|
92
92
|
}
|
|
93
93
|
export function useScale() {
|
|
94
94
|
return useVictoryContext(function (value) {
|
|
@@ -12,8 +12,6 @@ exports.useVictoryProviderSync = useVictoryProviderSync;
|
|
|
12
12
|
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
14
|
|
|
15
|
-
var _useContextSelector = require("use-context-selector");
|
|
16
|
-
|
|
17
15
|
var _getData = require("./helpers/get-data");
|
|
18
16
|
|
|
19
17
|
var _getDomain = require("./helpers/get-domain");
|
|
@@ -50,7 +48,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
50
48
|
|
|
51
49
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
52
50
|
|
|
53
|
-
var VictoryContext = (0,
|
|
51
|
+
var VictoryContext = /*#__PURE__*/(0, React.createContext)(null);
|
|
54
52
|
|
|
55
53
|
function VictoryProvider(_ref) {
|
|
56
54
|
var children = _ref.children,
|
|
@@ -106,13 +104,13 @@ function VictoryProvider(_ref) {
|
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
function useVictoryContext(selector) {
|
|
109
|
-
|
|
110
|
-
if (!context) {
|
|
111
|
-
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
112
|
-
}
|
|
107
|
+
var context = (0, React.useContext)(VictoryContext);
|
|
113
108
|
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
if (!context) {
|
|
110
|
+
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return selector(context);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
function useScale() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.5.
|
|
3
|
+
"version": "36.5.2",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"version": "yarn run nps build-libs && nps build-dists"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "def218e9749ecafc159ef458dd03a8b92e227666"
|
|
35
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { createContext,
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
3
|
import { D3ScaleFn, DomainTuple, ForAxes } from "../types/prop-types";
|
|
4
4
|
import { FormattedDatum, getData } from "./helpers/get-data";
|
|
5
5
|
import { getDomain } from "./helpers/get-domain";
|
|
@@ -81,17 +81,12 @@ export function VictoryProvider({
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
type ContextValue = ContextType | null;
|
|
85
|
-
|
|
86
84
|
export function useVictoryContext<T>(selector: (value: ContextType) => T): T {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return selector(context);
|
|
94
|
-
});
|
|
85
|
+
const context = useContext(VictoryContext);
|
|
86
|
+
if (!context) {
|
|
87
|
+
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
88
|
+
}
|
|
89
|
+
return selector(context);
|
|
95
90
|
}
|
|
96
91
|
|
|
97
92
|
export function useScale() {
|