victory-core 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.
- package/CHANGELOG.md +8 -0
- package/dist/victory-core.js +395 -358
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/types/prop-types.d.ts +1 -0
- package/es/victory-container/victory-container.d.ts +29 -35
- package/es/victory-container/victory-container.js +134 -162
- package/es/victory-portal/portal-context.d.ts +9 -8
- package/es/victory-portal/portal-context.js +34 -6
- package/es/victory-portal/portal-outlet.d.ts +12 -0
- package/es/victory-portal/portal-outlet.js +14 -0
- package/es/victory-portal/portal.d.ts +1 -12
- package/es/victory-portal/portal.js +6 -32
- package/es/victory-portal/victory-portal.d.ts +5 -22
- package/es/victory-portal/victory-portal.js +37 -52
- package/es/victory-util/index.d.ts +1 -0
- package/es/victory-util/index.js +1 -0
- package/es/victory-util/merge-refs.d.ts +13 -0
- package/es/victory-util/merge-refs.js +23 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +16 -4
- package/lib/types/prop-types.d.ts +1 -0
- package/lib/victory-container/victory-container.d.ts +29 -35
- package/lib/victory-container/victory-container.js +136 -163
- package/lib/victory-portal/portal-context.d.ts +9 -8
- package/lib/victory-portal/portal-context.js +37 -7
- package/lib/victory-portal/portal-outlet.d.ts +12 -0
- package/lib/victory-portal/portal-outlet.js +22 -0
- package/lib/victory-portal/portal.d.ts +1 -12
- package/lib/victory-portal/portal.js +6 -33
- package/lib/victory-portal/victory-portal.d.ts +5 -22
- package/lib/victory-portal/victory-portal.js +37 -52
- package/lib/victory-util/index.d.ts +1 -0
- package/lib/victory-util/index.js +12 -0
- package/lib/victory-util/merge-refs.d.ts +13 -0
- package/lib/victory-util/merge-refs.js +31 -0
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/types/prop-types.ts +7 -0
- package/src/victory-container/victory-container.tsx +167 -195
- package/src/victory-portal/portal-context.tsx +63 -0
- package/src/victory-portal/portal-outlet.tsx +26 -0
- package/src/victory-portal/portal.tsx +5 -42
- package/src/victory-portal/victory-portal.tsx +44 -73
- package/src/victory-util/index.ts +1 -0
- package/src/victory-util/merge-refs.ts +26 -0
- package/src/victory-portal/portal-context.ts +0 -14
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Helpers from "./helpers";
|
|
2
|
+
|
|
3
|
+
type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to merge multiple React refs into a single callback ref.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <div ref={mergeRefs([ref, forwardedRef])} />
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function mergeRefs<T>(refs: Ref<T>[]): React.RefCallback<T> {
|
|
14
|
+
return (value) => {
|
|
15
|
+
refs.forEach((ref) => {
|
|
16
|
+
// If the ref is a function, it's a callback ref and we call it with the value.
|
|
17
|
+
if (Helpers.isFunction(ref)) {
|
|
18
|
+
ref(value);
|
|
19
|
+
} else if (ref !== null && ref !== undefined) {
|
|
20
|
+
// If the ref is an object (not null and not undefined), it's an object ref.
|
|
21
|
+
// We assign the value to its 'current' property.
|
|
22
|
+
(ref as React.MutableRefObject<T | null>).current = value;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
export interface PortalContextValue {
|
|
4
|
-
portalRegister(): number;
|
|
5
|
-
portalUpdate(key: number, element: React.ReactElement): void;
|
|
6
|
-
portalDeregister(key: number): void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The React context object consumers may use to access the context of the
|
|
11
|
-
* portal.
|
|
12
|
-
*/
|
|
13
|
-
export const PortalContext = React.createContext({} as PortalContextValue);
|
|
14
|
-
PortalContext.displayName = "PortalContext";
|