@leafygreen-ui/polymorphic
Advanced tools
Comparing version 1.3.6 to 1.3.7
# @leafygreen-ui/polymorphic | ||
## 1.3.7 | ||
### Patch Changes | ||
- 356a53fd: Update TS builds to use `typescript@4.9.5` | ||
## 1.3.6 | ||
@@ -4,0 +10,0 @@ |
@@ -24,2 +24,6 @@ import React from 'react'; | ||
/** | ||
* @example | ||
*/ | ||
export declare const ExampleInferredWithRef: import("..").InferredPolymorphicComponentType<ExampleProps, PolymorphicAs>; | ||
/** | ||
* A test mocking the Button component | ||
@@ -39,4 +43,4 @@ * @example | ||
*/ | ||
declare type RestrictedType = 'a' | 'button' | React.ComponentType<React.PropsWithChildren<unknown>>; | ||
declare type RestrictedProps<T extends RestrictedType> = PolymorphicPropsWithRef<T, { | ||
type RestrictedType = 'a' | 'button' | React.ComponentType<React.PropsWithChildren<unknown>>; | ||
type RestrictedProps<T extends RestrictedType> = PolymorphicPropsWithRef<T, { | ||
title?: 'string'; | ||
@@ -43,0 +47,0 @@ }>; |
@@ -7,3 +7,3 @@ import { PropsWithChildren, ReactElement, RefAttributes, WeakValidationMap } from 'react'; | ||
/** Either an anchor tag, or a component that accepts an `href` */ | ||
export declare type AnchorLike = 'a' | React18ChildlessComponentType<{ | ||
export type AnchorLike = 'a' | React18ChildlessComponentType<{ | ||
href: string; | ||
@@ -17,3 +17,3 @@ }> | React18ChildlessComponentType<{ | ||
*/ | ||
export declare type AnchorLikeProps<T extends AnchorLike | undefined, P = {}> = PropsWithChildren<{ | ||
export type AnchorLikeProps<T extends AnchorLike | undefined, P = {}> = PropsWithChildren<{ | ||
href: string | NodeUrlLike; | ||
@@ -27,3 +27,3 @@ as?: T extends AnchorLike ? T : 'a'; | ||
*/ | ||
export declare type InferredProps<T extends PolymorphicAs, XP = {}> = PropsWithChildren<XP & (({ | ||
export type InferredProps<T extends PolymorphicAs, XP = {}> = PropsWithChildren<XP & (({ | ||
href: string; | ||
@@ -46,7 +46,7 @@ as?: 'a'; | ||
*/ | ||
export declare type InferredPolymorphicProps<T extends PolymorphicAs, XP = {}> = T extends AnchorLike | undefined ? AnchorLikeProps<T, XP> & InheritedProps<T, XP> : InferredProps<T, XP>; | ||
export type InferredPolymorphicProps<T extends PolymorphicAs, XP = {}> = T extends AnchorLike | undefined ? AnchorLikeProps<T, XP> & InheritedProps<T, XP> : InferredProps<T, XP>; | ||
/** | ||
* Inferred props clone of {@link PolymorphicPropsWithRef} | ||
*/ | ||
export declare type InferredPolymorphicPropsWithRef<T extends PolymorphicAs, XP = {}> = InferredPolymorphicProps<T, XP> & { | ||
export type InferredPolymorphicPropsWithRef<T extends PolymorphicAs, XP = {}> = InferredPolymorphicProps<T, XP> & { | ||
/** The ref object returned by `React.useRef` */ | ||
@@ -53,0 +53,0 @@ ref?: PolymorphicRef<T>; |
@@ -5,3 +5,3 @@ /** | ||
import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, PropsWithChildren, PropsWithoutRef, ReactElement, RefAttributes, WeakValidationMap } from 'react'; | ||
export declare type PolymorphicAs = ElementType; | ||
export type PolymorphicAs = ElementType; | ||
/** | ||
@@ -20,11 +20,11 @@ * An interface that enables the `as` prop. | ||
*/ | ||
export declare type PolymorphicRef<T extends PolymorphicAs> = ComponentPropsWithRef<T>['ref']; | ||
export type PolymorphicRef<T extends PolymorphicAs> = ComponentPropsWithRef<T>['ref']; | ||
/** | ||
* Union of prop types potentially re-defined in React.ComponentProps | ||
*/ | ||
export declare type PropsToOmit<T extends PolymorphicAs, P> = keyof (P & AsProp<T>); | ||
export type PropsToOmit<T extends PolymorphicAs, P> = keyof (P & AsProp<T>); | ||
/** | ||
* Ensures `href` is required for anchors | ||
*/ | ||
export declare type AnchorProps = Omit<ComponentPropsWithoutRef<'a'>, 'href'> & { | ||
export type AnchorProps = Omit<ComponentPropsWithoutRef<'a'>, 'href'> & { | ||
/** `href` is required for Anchor tags */ | ||
@@ -37,7 +37,7 @@ href: string; | ||
*/ | ||
export declare type AllInheritedProps<T extends PolymorphicAs> = T extends 'a' ? AnchorProps : ComponentPropsWithoutRef<T>; | ||
export type AllInheritedProps<T extends PolymorphicAs> = T extends 'a' ? AnchorProps : ComponentPropsWithoutRef<T>; | ||
/** | ||
* Omits any props inclided in type `P` from the inherited props | ||
*/ | ||
export declare type InheritedProps<T extends PolymorphicAs, XP = {}> = Omit<AllInheritedProps<T>, PropsToOmit<T, XP>>; | ||
export type InheritedProps<T extends PolymorphicAs, XP = {}> = Omit<AllInheritedProps<T>, PropsToOmit<T, XP>>; | ||
/** | ||
@@ -48,3 +48,3 @@ * The basic props for the Polymorphic component. | ||
*/ | ||
export declare type PolymorphicProps<T extends PolymorphicAs, XP = {}> = PropsWithChildren<XP & AsProp<T>> & InheritedProps<T, XP>; | ||
export type PolymorphicProps<T extends PolymorphicAs, XP = {}> = PropsWithChildren<XP & AsProp<T>> & InheritedProps<T, XP>; | ||
/** | ||
@@ -57,3 +57,3 @@ * Add the `ref` prop type to PolymorphicProps | ||
*/ | ||
export declare type PolymorphicPropsWithRef<T extends PolymorphicAs, XP = {}> = PolymorphicProps<T, XP> & { | ||
export type PolymorphicPropsWithRef<T extends PolymorphicAs, XP = {}> = PolymorphicProps<T, XP> & { | ||
/** The ref object returned by `React.useRef` */ | ||
@@ -60,0 +60,0 @@ ref?: PolymorphicRef<T>; |
/// <reference types="jest" /> | ||
import React from 'react'; | ||
/** Test utility functions */ | ||
export declare type WrapperProps = React.ComponentPropsWithoutRef<'span'> & { | ||
export type WrapperProps = React.ComponentPropsWithoutRef<'span'> & { | ||
darkMode?: boolean; | ||
@@ -6,0 +6,0 @@ }; |
@@ -24,3 +24,3 @@ import { ComponentProps, ComponentType, PropsWithChildren } from 'react'; | ||
*/ | ||
export declare type PropsOf<C extends PolymorphicComponentType | InferredPolymorphicComponentType | ComponentType<React.PropsWithChildren<unknown>>> = C extends PolymorphicComponentType<infer P, infer T> ? PolymorphicPropsWithRef<T, P> : C extends InferredPolymorphicComponentType<infer P, infer T> ? InferredPolymorphicPropsWithRef<T, P> : C extends ComponentType<React.PropsWithChildren<unknown>> ? ComponentProps<C> : never; | ||
export type PropsOf<C extends PolymorphicComponentType | InferredPolymorphicComponentType | ComponentType<React.PropsWithChildren<unknown>>> = C extends PolymorphicComponentType<infer P, infer T> ? PolymorphicPropsWithRef<T, P> : C extends InferredPolymorphicComponentType<infer P, infer T> ? InferredPolymorphicPropsWithRef<T, P> : C extends ComponentType<React.PropsWithChildren<unknown>> ? ComponentProps<C> : never; | ||
/** | ||
@@ -38,5 +38,5 @@ * Generates loosely typed polymorphic props, for use in tests or wrapper components, | ||
*/ | ||
export declare type LoosePolymorphicProps<XP = {}> = PropsWithChildren<XP & AsProp<PolymorphicAs>> & Omit<Partial<JSX.IntrinsicElements[keyof JSX.IntrinsicElements]>, 'href'> & { | ||
export type LoosePolymorphicProps<XP = {}> = PropsWithChildren<XP & AsProp<PolymorphicAs>> & Omit<Partial<JSX.IntrinsicElements[keyof JSX.IntrinsicElements]>, 'href'> & { | ||
href?: string | NodeUrlLike; | ||
}; | ||
//# sourceMappingURL=Polymorphic.utils.d.ts.map |
@@ -17,4 +17,4 @@ import { ComponentClass, ReactElement, ValidationMap, WeakValidationMap } from 'react'; | ||
*/ | ||
export declare type React18ChildlessComponentType<P = {}> = ComponentClass<P> | React18FunctionComponent<P>; | ||
export type React18ChildlessComponentType<P = {}> = ComponentClass<P> | React18FunctionComponent<P>; | ||
export {}; | ||
//# sourceMappingURL=React18ChildlessComponentType.d.ts.map |
{ | ||
"name": "@leafygreen-ui/polymorphic", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "LeafyGreen UI Kit Polymorphic", | ||
@@ -34,6 +34,6 @@ "main": "./dist/index.js", | ||
"@emotion/styled": "^11.10.5", | ||
"@lg-tools/build": "^0.2.1", | ||
"next": "^13.1.6", | ||
"@leafygreen-ui/lib": "^11.0.0" | ||
"@lg-tools/build": "^0.4.1", | ||
"@lg-tools/storybook-utils": "^0.1.0", | ||
"next": "^13.1.6" | ||
} | ||
} |
@@ -12,4 +12,4 @@ { | ||
], | ||
"exclude": ["**/*.spec.*", "**/*.story.*"], | ||
"exclude": ["**/*.spec.*", "**/*.stories.*"], | ||
"references": [] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
157640
3454
1