@bedrock-layout/type-utils
Advanced tools
Comparing version 0.0.18 to 0.1.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react");function c(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const u=c(n);function a(e){return u.forwardRef(e)}exports.forwardRefWithAs=a; | ||
"use strict"; |
@@ -1,18 +0,42 @@ | ||
import * as React from "react"; | ||
export declare function forwardRefWithAs<Props, ComponentType extends As>(comp: (props: PropsFromAs<ComponentType, Props>, ref: React.RefObject<any>) => React.ReactElement | null): ComponentWithAs<ComponentType, Props>; | ||
export declare type PropsFromAs<ComponentType extends As, ComponentProps> = (PropsWithAs<ComponentType, ComponentProps> & { | ||
as: ComponentType; | ||
}) & PropsWithAs<ComponentType, ComponentProps>; | ||
export declare type ComponentWithForwardedRef<ElementType extends React.ElementType, ComponentProps> = React.ForwardRefExoticComponent<ComponentProps & React.HTMLProps<React.ElementType<ElementType>> & React.ComponentPropsWithRef<ElementType>>; | ||
export declare type As<BaseProps = any> = React.ElementType<BaseProps>; | ||
export declare type PropsWithAs<ComponentType extends As, ComponentProps> = ComponentProps & Omit<React.ComponentPropsWithRef<ComponentType>, "as" | keyof ComponentProps> & { | ||
as?: ComponentType; | ||
import React from "react"; | ||
export type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>; | ||
type AsProp<C extends React.ElementType> = { | ||
/** | ||
* An override of the default HTML tag. | ||
* Can also be another React component. | ||
*/ | ||
as?: C; | ||
}; | ||
export interface ComponentWithAs<ComponentType extends As, ComponentProps> { | ||
<TT extends As>(props: PropsWithAs<TT, ComponentProps>): React.ReactElement | null; | ||
(props: PropsWithAs<ComponentType, ComponentProps>): React.ReactElement | null; | ||
displayName?: string; | ||
propTypes?: React.WeakValidationMap<PropsWithAs<ComponentType, ComponentProps>>; | ||
contextTypes?: React.ValidationMap<any>; | ||
defaultProps?: Partial<PropsWithAs<ComponentType, ComponentProps>>; | ||
} | ||
/** | ||
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props | ||
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding | ||
* set of props. | ||
*/ | ||
export type ExtendableProps<ExtendedProps = {}, OverrideProps = {}> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>; | ||
/** | ||
* Allows for inheriting the props from the specified element type so that | ||
* props like children, className & style work, as well as element-specific | ||
* attributes like aria roles. The component (`C`) must be passed in. | ||
*/ | ||
export type InheritableElementProps<C extends React.ElementType, Props = {}> = ExtendableProps<PropsOf<C>, Props>; | ||
/** | ||
* A more sophisticated version of `InheritableElementProps` where | ||
* the passed in `as` prop will determine which props can be included | ||
*/ | ||
export type PolymorphicComponentProps<C extends React.ElementType, Props = {}> = InheritableElementProps<C, Props & AsProp<C>>; | ||
/** | ||
* Utility type to extract the `ref` prop from a polymorphic component | ||
*/ | ||
export type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>["ref"]; | ||
/** | ||
* Utility type to extend the `ref` prop from a polymorphic component | ||
*/ | ||
export type WithRef<C extends React.ElementType> = { | ||
ref?: PolymorphicRef<C>; | ||
}; | ||
/** | ||
* A wrapper of `PolymorphicComponentProps` that also includes the `ref` | ||
* prop for the polymorphic component | ||
*/ | ||
export type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = {}> = PolymorphicComponentProps<C, Props> & WithRef<C>; | ||
export {}; |
@@ -1,7 +0,1 @@ | ||
import * as f from "react"; | ||
function o(r) { | ||
return f.forwardRef(r); | ||
} | ||
export { | ||
o as forwardRefWithAs | ||
}; | ||
@@ -1,1 +0,1 @@ | ||
(function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t["type-util"]={},t.React))})(this,function(t,n){"use strict";function f(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const u=f(n);function c(e){return u.forwardRef(e)}t.forwardRefWithAs=c,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"}); |
{ | ||
"name": "@bedrock-layout/type-utils", | ||
"version": "0.0.18", | ||
"version": "0.1.0", | ||
"description": "bedrock-layout type utils", | ||
@@ -57,3 +57,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "17accd044b36db3f2032dae72a450a8e38e7b610" | ||
"gitHead": "9ae10c12fea1c824280c460a6cbb06290a794b76" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
44
1
4683