@rarui/typings 1.0.0-rc.1 → 1.0.0-rc.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.
- package/package.json +8 -3
- package/src/index.ts +0 -25
- package/src/index.types.ts +0 -70
- package/webpack.config.ts +0 -11
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rarui/typings",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"CHANGELOG.md"
|
|
10
|
+
],
|
|
6
11
|
"sideEffects": false,
|
|
7
12
|
"scripts": {
|
|
8
13
|
"build": "yarn g:webpack",
|
|
@@ -18,7 +23,7 @@
|
|
|
18
23
|
"url": "https://github.com/juniorconquista/boilerplate-design-system/issues"
|
|
19
24
|
},
|
|
20
25
|
"devDependencies": {
|
|
21
|
-
"@rarui/webpack": "
|
|
26
|
+
"@rarui/webpack": "^1.0.0-rc.2"
|
|
22
27
|
},
|
|
23
28
|
"stableVersion": "0.0.0"
|
|
24
|
-
}
|
|
29
|
+
}
|
package/src/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ForwardedRef, RefObject, useImperativeHandle } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Use a ref object as the imperative handle for a forwarded ref. This can be used to
|
|
5
|
-
* synchronize the ref object with the forwarded ref and allow local access the reference
|
|
6
|
-
* instance with `.current`.
|
|
7
|
-
*
|
|
8
|
-
* **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
|
|
9
|
-
*/
|
|
10
|
-
export function useRefObjectAsForwardedRef<T>(
|
|
11
|
-
forwardedRef: ForwardedRef<T>,
|
|
12
|
-
refObject: RefObject<T>,
|
|
13
|
-
): void {
|
|
14
|
-
useImperativeHandle<T | null, T | null>(
|
|
15
|
-
forwardedRef,
|
|
16
|
-
() => refObject.current,
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type {
|
|
21
|
-
PolymorphicForwardRefComponent,
|
|
22
|
-
OwnProps,
|
|
23
|
-
IntrinsicElement,
|
|
24
|
-
Merge,
|
|
25
|
-
} from "./index.types";
|
package/src/index.types.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is originally from `@radix-ui/react-polymorphic` before the package
|
|
3
|
-
* was deprecated. The original source for this lived in the URL below.
|
|
4
|
-
*
|
|
5
|
-
* @see https://github.com/radix-ui/primitives/blob/17ffcb7aaa42cbd36b3c210ba86d7d73d218e5be/packages/react/polymorphic/src/polymorphic.ts
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React from "react";
|
|
9
|
-
|
|
10
|
-
/* -------------------------------------------------------------------------------------------------
|
|
11
|
-
* Utility types
|
|
12
|
-
* -----------------------------------------------------------------------------------------------*/
|
|
13
|
-
type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
|
|
17
|
-
*/
|
|
18
|
-
type OwnProps<E> =
|
|
19
|
-
E extends PolymorphicForwardRefComponent<any, infer P> ? P : {};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
|
|
23
|
-
*/
|
|
24
|
-
type IntrinsicElement<E> =
|
|
25
|
-
E extends PolymorphicForwardRefComponent<infer I, any> ? I : never;
|
|
26
|
-
|
|
27
|
-
type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<
|
|
28
|
-
Merge<
|
|
29
|
-
E extends React.ElementType ? React.ComponentPropsWithRef<E> : never,
|
|
30
|
-
OwnProps & { as?: E }
|
|
31
|
-
>
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
/* -------------------------------------------------------------------------------------------------
|
|
35
|
-
* PolymorphicForwardRefComponent
|
|
36
|
-
* -----------------------------------------------------------------------------------------------*/
|
|
37
|
-
|
|
38
|
-
interface PolymorphicForwardRefComponent<
|
|
39
|
-
IntrinsicElementString,
|
|
40
|
-
OwnProps = {},
|
|
41
|
-
/**
|
|
42
|
-
* Extends original type to ensure built in React types play nice
|
|
43
|
-
* with polymorphic components still e.g. `React.ElementRef` etc.
|
|
44
|
-
*/
|
|
45
|
-
> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {
|
|
46
|
-
/**
|
|
47
|
-
* When `as` prop is passed, use this overload.
|
|
48
|
-
* Merges original own props (without DOM props) and the inferred props
|
|
49
|
-
* from `as` element with the own props taking precendence.
|
|
50
|
-
*
|
|
51
|
-
* We explicitly avoid `React.ElementType` and manually narrow the prop types
|
|
52
|
-
* so that events are typed when using JSX.IntrinsicElements.
|
|
53
|
-
*/
|
|
54
|
-
<As = IntrinsicElementString>(
|
|
55
|
-
props: As extends ""
|
|
56
|
-
? { as: keyof JSX.IntrinsicElements }
|
|
57
|
-
: As extends React.ComponentType<infer P>
|
|
58
|
-
? Merge<P, OwnProps & { as: As }>
|
|
59
|
-
: As extends keyof JSX.IntrinsicElements
|
|
60
|
-
? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As }>
|
|
61
|
-
: never,
|
|
62
|
-
): React.ReactElement | null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type {
|
|
66
|
-
PolymorphicForwardRefComponent,
|
|
67
|
-
OwnProps,
|
|
68
|
-
IntrinsicElement,
|
|
69
|
-
Merge,
|
|
70
|
-
};
|
package/webpack.config.ts
DELETED