react-component-instance 0.0.10 → 0.0.12
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/package.json +4 -4
- package/src/index.d.mts +27 -0
- package/src/index.mjs +1 -1
- package/src/utils/index.d.mts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-component-instance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Get a React class component instance from its DOM Element",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"@babel/eslint-parser": "^7.26.10",
|
|
36
36
|
"@babel/preset-env": "^7.26.9",
|
|
37
37
|
"@babel/preset-react": "^7.26.3",
|
|
38
|
-
"@sequencemedia/eslint-config-standard": "^0.2.
|
|
39
|
-
"@sequencemedia/eslint-config-typescript": "^0.1.
|
|
38
|
+
"@sequencemedia/eslint-config-standard": "^0.2.44",
|
|
39
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.64",
|
|
40
40
|
"@testing-library/jest-dom": "^6.6.3",
|
|
41
41
|
"@testing-library/react": "^16.2.0",
|
|
42
42
|
"@types/debug": "^4.1.12",
|
|
43
43
|
"@types/jest": "^29.5.14",
|
|
44
44
|
"@types/react": "^19.0.12",
|
|
45
45
|
"core-js": "^3.41.0",
|
|
46
|
-
"eslint": "^9.
|
|
46
|
+
"eslint": "^9.23.0",
|
|
47
47
|
"eslint-plugin-react": "^7.37.4",
|
|
48
48
|
"globals": "^16.0.0",
|
|
49
49
|
"husky": "^9.1.7",
|
package/src/index.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type {
|
|
3
|
+
RenderResult as RenderType
|
|
4
|
+
} from '@testing-library/react'
|
|
5
|
+
|
|
6
|
+
type FiberRootNode = ReactComponentInstanceTypes.FiberRootNode
|
|
7
|
+
type FiberNode = ReactComponentInstanceTypes.FiberNode
|
|
8
|
+
|
|
9
|
+
export function getContainerFiberNodeFrom (containerElement?: Element | null): FiberRootNode | null | undefined
|
|
10
|
+
|
|
11
|
+
export function getFiberNodeFrom (element?: Element | null): FiberNode | null | undefined
|
|
12
|
+
|
|
13
|
+
export function getParentFiberNodeFrom (element?: Element | null): FiberNode | null | undefined
|
|
14
|
+
|
|
15
|
+
export function getChildFiberNodeFrom (element?: Element | null): FiberNode | null | undefined
|
|
16
|
+
|
|
17
|
+
export function getComponentElementFromRender (render: RenderType): Element | null
|
|
18
|
+
|
|
19
|
+
export function getContainerElementFromRender (render: RenderType): Element | null
|
|
20
|
+
|
|
21
|
+
export function getInstanceFromContainerElement (containerElement?: Element | null): React.Component<any, any> | HTMLElement | Text | null
|
|
22
|
+
|
|
23
|
+
export function getInstanceFromComponentElement (componentElement?: Element | null): React.Component<any, any> | HTMLElement | Text | null
|
|
24
|
+
|
|
25
|
+
export function findInstanceFor (element: Element | null | undefined, Component: (() => React.JSX.Element) | typeof React.Component) : React.Component<any, any> | HTMLElement | Text | null
|
|
26
|
+
|
|
27
|
+
export function getInstance (render: RenderType): React.Component<any, any> | HTMLElement | Text | null
|
package/src/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from './utils/index.mjs'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @param {Element | null
|
|
19
|
+
* @param {Element | null} [containerElement]
|
|
20
20
|
* @returns {FiberRootNode | null | undefined}
|
|
21
21
|
*/
|
|
22
22
|
export function getContainerFiberNodeFrom (containerElement) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
|
|
3
|
+
type FiberRootNode = ReactComponentInstanceTypes.FiberRootNode
|
|
4
|
+
type FiberNode = ReactComponentInstanceTypes.FiberNode
|
|
5
|
+
|
|
6
|
+
export function isReactFiberKey (key: PropertyKey) : boolean
|
|
7
|
+
|
|
8
|
+
export function isReactPropsKey (key: PropertyKey) : boolean
|
|
9
|
+
|
|
10
|
+
export function isReactContainerFiberKey (key: PropertyKey): boolean
|
|
11
|
+
|
|
12
|
+
export function getReactFiberKey (element: Element): string | undefined
|
|
13
|
+
|
|
14
|
+
export function getReactPropsKey (element: Element): string | undefined
|
|
15
|
+
|
|
16
|
+
export function getReactContainerFiberKey (element: Element): string | undefined
|
|
17
|
+
|
|
18
|
+
export function getFiberFrom (element: Element): FiberNode | null | undefined
|
|
19
|
+
|
|
20
|
+
export function getParentFiberFrom (element: Element): FiberNode | null | undefined
|
|
21
|
+
|
|
22
|
+
export function getChildFiberFrom (element: Element): FiberNode | null | undefined
|
|
23
|
+
|
|
24
|
+
export function getContainerFiberFrom (element: Element): FiberNode | null | undefined
|
|
25
|
+
|
|
26
|
+
export function getParentFiber (fiber: FiberNode): FiberNode | null | undefined
|
|
27
|
+
|
|
28
|
+
export function getChildFiber (fiber: FiberNode): FiberNode | null | undefined
|
|
29
|
+
|
|
30
|
+
export function getComponentInstance (fiber: FiberNode): React.Component<any, any> | HTMLElement | Text | null
|
|
31
|
+
|
|
32
|
+
export function getContainerInstance (fiber: FiberRootNode): React.Component<any, any> | HTMLElement | Text | null
|
|
33
|
+
|
|
34
|
+
export function isComponentType (Component: (() => React.JSX.Element) | typeof React.Component, fiber: FiberNode): boolean
|
|
35
|
+
|
|
36
|
+
export function getIsComponentType (Component: (() => React.JSX.Element) | typeof React.Component): (fiber: FiberNode) => boolean
|
|
37
|
+
|
|
38
|
+
export function traverseFiberParents (fiber: FiberNode): Generator<FiberNode | null | undefined, null, unknown>
|