@fluentui/react-utilities
Advanced tools
Comparing version 9.0.0-alpha.44 to 9.0.0-alpha.45
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Mon, 06 Sep 2021 07:32:10 GMT", | ||
"date": "Fri, 10 Sep 2021 07:36:18 GMT", | ||
"tag": "@fluentui/react-utilities_v9.0.0-alpha.45", | ||
"version": "9.0.0-alpha.45", | ||
"comments": { | ||
"prerelease": [ | ||
{ | ||
"comment": "Add IntrinsicShorthandProps for slots that use intrinsic elements like div or span", | ||
"author": "behowell@microsoft.com", | ||
"commit": "8700a515c7f2659761c5b53f55c32453bc3510b1", | ||
"package": "@fluentui/react-utilities" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Mon, 06 Sep 2021 07:34:53 GMT", | ||
"tag": "@fluentui/react-utilities_v9.0.0-alpha.44", | ||
@@ -8,0 +23,0 @@ "version": "9.0.0-alpha.44", |
# Change Log - @fluentui/react-utilities | ||
This log was last generated on Mon, 06 Sep 2021 07:32:10 GMT and should not be manually modified. | ||
This log was last generated on Fri, 10 Sep 2021 07:36:18 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## [9.0.0-alpha.45](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-alpha.45) | ||
Fri, 10 Sep 2021 07:36:18 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-alpha.44..@fluentui/react-utilities_v9.0.0-alpha.45) | ||
### Changes | ||
- Add IntrinsicShorthandProps for slots that use intrinsic elements like div or span ([PR #19642](https://github.com/microsoft/fluentui/pull/19642) by behowell@microsoft.com) | ||
## [9.0.0-alpha.44](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-alpha.44) | ||
Mon, 06 Sep 2021 07:32:10 GMT | ||
Mon, 06 Sep 2021 07:34:53 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-alpha.43..@fluentui/react-utilities_v9.0.0-alpha.44) | ||
@@ -11,0 +20,0 @@ |
@@ -66,3 +66,5 @@ import { DispatchWithoutAction } from 'react'; | ||
components?: { | ||
[Key in keyof Shorthands]?: React_2.ElementType<NonNullable<Shorthands[Key]>> | keyof JSX.IntrinsicElements; | ||
[Key in keyof Shorthands]-?: React_2.ComponentType<NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends { | ||
as?: infer As; | ||
} ? As : keyof JSX.IntrinsicElements); | ||
}; | ||
@@ -82,3 +84,12 @@ } & Shorthands; | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{}, unknown, keyof JSX.IntrinsicElements>; | ||
/** | ||
* Matches any shorthand props type. | ||
* | ||
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`; | ||
* it shouldn't be used as the type of a slot. | ||
*/ | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{ | ||
children?: React_2.ReactNode; | ||
as?: keyof JSX.IntrinsicElements; | ||
}>; | ||
@@ -216,2 +227,35 @@ /** | ||
/** | ||
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'. | ||
* For slots that support custom components, use {@link ObjectShorthandProps} instead. | ||
* | ||
* The first param is the slot's default type if no `as` prop is specified. | ||
* The second param is an optional union of alternative types that can be specified for the `as` prop. | ||
* | ||
* ``` | ||
* IntrinsicShorthandProps<'div'> // Slot is always a <div> | ||
* IntrinsicShorthandProps<'a', 'button'> // Defaults to <a>, but allows { as: 'button' } to be a <button> | ||
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to <label>, but allows { as: 'span' } or { as: 'div' } | ||
* ``` | ||
*/ | ||
export declare type IntrinsicShorthandProps<DefaultElement extends keyof JSX.IntrinsicElements, AlternateElements extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultElement> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({ | ||
as?: DefaultElement; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[DefaultElement]>>) | { | ||
[As in AlternateElements]: { | ||
as: As; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[As]>>; | ||
}[AlternateElements]; | ||
/** | ||
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings. | ||
* | ||
* ``` | ||
* IsSingleton<'a'> // true | ||
* IsSingleton<'a' | 'b' | 'c'> // false | ||
* ``` | ||
*/ | ||
export declare type IsSingleton<T extends string> = { | ||
[K in T]: Exclude<T, K> extends never ? true : false; | ||
}[T]; | ||
/** | ||
* An array of LABEL tag properties and events. | ||
@@ -255,2 +299,11 @@ * | ||
/** | ||
* Excludes LegacyRef (string) from the ref prop of the given Props type | ||
*/ | ||
export declare type NoLegacyRef<Props extends { | ||
ref?: unknown; | ||
}> = Omit<Props, 'ref'> & { | ||
ref?: Exclude<Props['ref'], string>; | ||
}; | ||
/** | ||
* Simple constant function for returning null, used to render empty templates in JSX. | ||
@@ -260,6 +313,10 @@ */ | ||
/** | ||
* Defines the slot props for a slot that supports a Component type. | ||
* | ||
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead. | ||
*/ | ||
export declare type ObjectShorthandProps<Props extends { | ||
children?: React_2.ReactNode; | ||
} = {}, Ref = unknown, As extends keyof JSX.IntrinsicElements = never> = Props & React_2.RefAttributes<Ref> & { | ||
as?: As; | ||
} = {}> = Props & { | ||
children?: Props['children'] | ShorthandRenderFunction<Props>; | ||
@@ -266,0 +323,0 @@ }; |
@@ -5,9 +5,61 @@ import * as React from 'react'; | ||
export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props; | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{}, unknown, keyof JSX.IntrinsicElements>; | ||
/** | ||
* Matches any shorthand props type. | ||
* | ||
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`; | ||
* it shouldn't be used as the type of a slot. | ||
*/ | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{ | ||
children?: React.ReactNode; | ||
as?: keyof JSX.IntrinsicElements; | ||
}>; | ||
/** | ||
* Defines the slot props for a slot that supports a Component type. | ||
* | ||
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead. | ||
*/ | ||
export declare type ObjectShorthandProps<Props extends { | ||
children?: React.ReactNode; | ||
} = {}, Ref = unknown, As extends keyof JSX.IntrinsicElements = never> = Props & React.RefAttributes<Ref> & { | ||
as?: As; | ||
} = {}> = Props & { | ||
children?: Props['children'] | ShorthandRenderFunction<Props>; | ||
}; | ||
/** | ||
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'. | ||
* For slots that support custom components, use {@link ObjectShorthandProps} instead. | ||
* | ||
* The first param is the slot's default type if no `as` prop is specified. | ||
* The second param is an optional union of alternative types that can be specified for the `as` prop. | ||
* | ||
* ``` | ||
* IntrinsicShorthandProps<'div'> // Slot is always a <div> | ||
* IntrinsicShorthandProps<'a', 'button'> // Defaults to <a>, but allows { as: 'button' } to be a <button> | ||
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to <label>, but allows { as: 'span' } or { as: 'div' } | ||
* ``` | ||
*/ | ||
export declare type IntrinsicShorthandProps<DefaultElement extends keyof JSX.IntrinsicElements, AlternateElements extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultElement> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({ | ||
as?: DefaultElement; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[DefaultElement]>>) | { | ||
[As in AlternateElements]: { | ||
as: As; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[As]>>; | ||
}[AlternateElements]; | ||
/** | ||
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings. | ||
* | ||
* ``` | ||
* IsSingleton<'a'> // true | ||
* IsSingleton<'a' | 'b' | 'c'> // false | ||
* ``` | ||
*/ | ||
export declare type IsSingleton<T extends string> = { | ||
[K in T]: Exclude<T, K> extends never ? true : false; | ||
}[T]; | ||
/** | ||
* Excludes LegacyRef (string) from the ref prop of the given Props type | ||
*/ | ||
export declare type NoLegacyRef<Props extends { | ||
ref?: unknown; | ||
}> = Omit<Props, 'ref'> & { | ||
ref?: Exclude<Props['ref'], string>; | ||
}; | ||
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{ | ||
@@ -18,3 +70,5 @@ [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>; | ||
components?: { | ||
[Key in keyof Shorthands]?: React.ElementType<NonNullable<Shorthands[Key]>> | keyof JSX.IntrinsicElements; | ||
[Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends { | ||
as?: infer As; | ||
} ? As : keyof JSX.IntrinsicElements); | ||
}; | ||
@@ -21,0 +75,0 @@ } & Shorthands; |
@@ -5,9 +5,61 @@ import * as React from 'react'; | ||
export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props; | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{}, unknown, keyof JSX.IntrinsicElements>; | ||
/** | ||
* Matches any shorthand props type. | ||
* | ||
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`; | ||
* it shouldn't be used as the type of a slot. | ||
*/ | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{ | ||
children?: React.ReactNode; | ||
as?: keyof JSX.IntrinsicElements; | ||
}>; | ||
/** | ||
* Defines the slot props for a slot that supports a Component type. | ||
* | ||
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead. | ||
*/ | ||
export declare type ObjectShorthandProps<Props extends { | ||
children?: React.ReactNode; | ||
} = {}, Ref = unknown, As extends keyof JSX.IntrinsicElements = never> = Props & React.RefAttributes<Ref> & { | ||
as?: As; | ||
} = {}> = Props & { | ||
children?: Props['children'] | ShorthandRenderFunction<Props>; | ||
}; | ||
/** | ||
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'. | ||
* For slots that support custom components, use {@link ObjectShorthandProps} instead. | ||
* | ||
* The first param is the slot's default type if no `as` prop is specified. | ||
* The second param is an optional union of alternative types that can be specified for the `as` prop. | ||
* | ||
* ``` | ||
* IntrinsicShorthandProps<'div'> // Slot is always a <div> | ||
* IntrinsicShorthandProps<'a', 'button'> // Defaults to <a>, but allows { as: 'button' } to be a <button> | ||
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to <label>, but allows { as: 'span' } or { as: 'div' } | ||
* ``` | ||
*/ | ||
export declare type IntrinsicShorthandProps<DefaultElement extends keyof JSX.IntrinsicElements, AlternateElements extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultElement> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({ | ||
as?: DefaultElement; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[DefaultElement]>>) | { | ||
[As in AlternateElements]: { | ||
as: As; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[As]>>; | ||
}[AlternateElements]; | ||
/** | ||
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings. | ||
* | ||
* ``` | ||
* IsSingleton<'a'> // true | ||
* IsSingleton<'a' | 'b' | 'c'> // false | ||
* ``` | ||
*/ | ||
export declare type IsSingleton<T extends string> = { | ||
[K in T]: Exclude<T, K> extends never ? true : false; | ||
}[T]; | ||
/** | ||
* Excludes LegacyRef (string) from the ref prop of the given Props type | ||
*/ | ||
export declare type NoLegacyRef<Props extends { | ||
ref?: unknown; | ||
}> = Omit<Props, 'ref'> & { | ||
ref?: Exclude<Props['ref'], string>; | ||
}; | ||
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{ | ||
@@ -18,3 +70,5 @@ [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>; | ||
components?: { | ||
[Key in keyof Shorthands]?: React.ElementType<NonNullable<Shorthands[Key]>> | keyof JSX.IntrinsicElements; | ||
[Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends { | ||
as?: infer As; | ||
} ? As : keyof JSX.IntrinsicElements); | ||
}; | ||
@@ -21,0 +75,0 @@ } & Shorthands; |
@@ -5,9 +5,61 @@ import * as React from 'react'; | ||
export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props; | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{}, unknown, keyof JSX.IntrinsicElements>; | ||
/** | ||
* Matches any shorthand props type. | ||
* | ||
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`; | ||
* it shouldn't be used as the type of a slot. | ||
*/ | ||
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{ | ||
children?: React.ReactNode; | ||
as?: keyof JSX.IntrinsicElements; | ||
}>; | ||
/** | ||
* Defines the slot props for a slot that supports a Component type. | ||
* | ||
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead. | ||
*/ | ||
export declare type ObjectShorthandProps<Props extends { | ||
children?: React.ReactNode; | ||
} = {}, Ref = unknown, As extends keyof JSX.IntrinsicElements = never> = Props & React.RefAttributes<Ref> & { | ||
as?: As; | ||
} = {}> = Props & { | ||
children?: Props['children'] | ShorthandRenderFunction<Props>; | ||
}; | ||
/** | ||
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'. | ||
* For slots that support custom components, use {@link ObjectShorthandProps} instead. | ||
* | ||
* The first param is the slot's default type if no `as` prop is specified. | ||
* The second param is an optional union of alternative types that can be specified for the `as` prop. | ||
* | ||
* ``` | ||
* IntrinsicShorthandProps<'div'> // Slot is always a <div> | ||
* IntrinsicShorthandProps<'a', 'button'> // Defaults to <a>, but allows { as: 'button' } to be a <button> | ||
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to <label>, but allows { as: 'span' } or { as: 'div' } | ||
* ``` | ||
*/ | ||
export declare type IntrinsicShorthandProps<DefaultElement extends keyof JSX.IntrinsicElements, AlternateElements extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultElement> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({ | ||
as?: DefaultElement; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[DefaultElement]>>) | { | ||
[As in AlternateElements]: { | ||
as: As; | ||
} & ObjectShorthandProps<NoLegacyRef<JSX.IntrinsicElements[As]>>; | ||
}[AlternateElements]; | ||
/** | ||
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings. | ||
* | ||
* ``` | ||
* IsSingleton<'a'> // true | ||
* IsSingleton<'a' | 'b' | 'c'> // false | ||
* ``` | ||
*/ | ||
export declare type IsSingleton<T extends string> = { | ||
[K in T]: Exclude<T, K> extends never ? true : false; | ||
}[T]; | ||
/** | ||
* Excludes LegacyRef (string) from the ref prop of the given Props type | ||
*/ | ||
export declare type NoLegacyRef<Props extends { | ||
ref?: unknown; | ||
}> = Omit<Props, 'ref'> & { | ||
ref?: Exclude<Props['ref'], string>; | ||
}; | ||
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{ | ||
@@ -18,3 +70,5 @@ [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>; | ||
components?: { | ||
[Key in keyof Shorthands]?: React.ElementType<NonNullable<Shorthands[Key]>> | keyof JSX.IntrinsicElements; | ||
[Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends { | ||
as?: infer As; | ||
} ? As : keyof JSX.IntrinsicElements); | ||
}; | ||
@@ -21,0 +75,0 @@ } & Shorthands; |
{ | ||
"name": "@fluentui/react-utilities", | ||
"version": "9.0.0-alpha.44", | ||
"version": "9.0.0-alpha.45", | ||
"description": "A set of general React-specific utilities.", | ||
@@ -5,0 +5,0 @@ "main": "lib-commonjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
653677
7971