@fluentui/react-utilities 9.0.0-alpha.9 → 9.0.0-beta.4
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/CHANGELOG.json +1132 -1
- package/CHANGELOG.md +492 -2
- package/dist/react-utilities.d.ts +335 -67
- package/lib/compose/getSlots.d.ts +13 -4
- package/lib/compose/getSlots.js +44 -32
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.d.ts +1 -2
- package/lib/compose/index.js +2 -2
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/nullRender.js +1 -1
- package/lib/compose/nullRender.js.map +1 -1
- package/lib/compose/resolveShorthand.d.ts +12 -0
- package/lib/compose/resolveShorthand.js +31 -0
- package/lib/compose/resolveShorthand.js.map +1 -0
- package/lib/compose/types.d.ts +95 -21
- package/lib/compose/types.js +5 -0
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.d.ts +9 -1
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useBoolean.d.ts +2 -2
- package/lib/hooks/useBoolean.js +16 -11
- package/lib/hooks/useBoolean.js.map +1 -1
- package/lib/hooks/useConst.js +15 -12
- package/lib/hooks/useConst.js.map +1 -1
- package/lib/hooks/useControllableState.d.ts +21 -0
- package/lib/hooks/useControllableState.js +68 -0
- package/lib/hooks/useControllableState.js.map +1 -0
- package/lib/hooks/useControllableValue.js +47 -50
- package/lib/hooks/useControllableValue.js.map +1 -1
- package/lib/hooks/useEventCallback.d.ts +2 -2
- package/lib/hooks/useEventCallback.js +14 -17
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.d.ts +11 -0
- package/lib/hooks/useFirstMount.js +23 -0
- package/lib/hooks/useFirstMount.js.map +1 -0
- package/lib/hooks/useForceUpdate.d.ts +4 -0
- package/lib/hooks/useForceUpdate.js +9 -0
- package/lib/hooks/useForceUpdate.js.map +1 -0
- package/lib/hooks/useId.d.ts +7 -3
- package/lib/hooks/useId.js +13 -17
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.d.ts +9 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js +13 -4
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +16 -20
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useMount.d.ts +6 -0
- package/lib/hooks/useMount.js +17 -0
- package/lib/hooks/useMount.js.map +1 -0
- package/lib/hooks/useOnClickOutside.d.ts +14 -4
- package/lib/hooks/useOnClickOutside.js +129 -18
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.d.ts +5 -0
- package/lib/hooks/useOnScrollOutside.js +36 -0
- package/lib/hooks/useOnScrollOutside.js.map +1 -0
- package/lib/hooks/usePrevious.d.ts +1 -0
- package/lib/hooks/usePrevious.js +9 -0
- package/lib/hooks/usePrevious.js.map +1 -0
- package/lib/hooks/useTimeout.d.ts +8 -0
- package/lib/hooks/useTimeout.js +29 -0
- package/lib/hooks/useTimeout.js.map +1 -0
- package/lib/hooks/useUnmount.d.ts +6 -0
- package/lib/hooks/useUnmount.js +17 -0
- package/lib/hooks/useUnmount.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.d.ts +33 -0
- package/lib/ssr/SSRContext.js +65 -0
- package/lib/ssr/SSRContext.js.map +1 -0
- package/lib/ssr/canUseDOM.d.ts +4 -0
- package/lib/ssr/canUseDOM.js +8 -0
- package/lib/ssr/canUseDOM.js.map +1 -0
- package/lib/ssr/index.d.ts +2 -0
- package/lib/ssr/index.js +3 -0
- package/lib/ssr/index.js.map +1 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils/applyTriggerPropsToChildren.d.ts +5 -0
- package/lib/utils/applyTriggerPropsToChildren.js +16 -0
- package/lib/utils/applyTriggerPropsToChildren.js.map +1 -0
- package/lib/utils/clamp.d.ts +8 -0
- package/lib/utils/clamp.js +9 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/getNativeElementProps.d.ts +22 -0
- package/lib/utils/getNativeElementProps.js +48 -24
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.d.ts +4 -0
- package/lib/utils/getRTLSafeKey.js +21 -0
- package/lib/utils/getRTLSafeKey.js.map +1 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/omit.d.ts +1 -1
- package/lib/utils/omit.js +9 -7
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/onlyChild.d.ts +5 -0
- package/lib/utils/onlyChild.js +13 -0
- package/lib/utils/onlyChild.js.map +1 -0
- package/lib/utils/properties.js +80 -282
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.js +20 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
- package/lib-commonjs/compose/getSlots.d.ts +13 -4
- package/lib-commonjs/compose/getSlots.js +57 -35
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.d.ts +1 -2
- package/lib-commonjs/compose/index.js +12 -4
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/nullRender.js +9 -2
- package/lib-commonjs/compose/nullRender.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.d.ts +12 -0
- package/lib-commonjs/compose/resolveShorthand.js +41 -0
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -0
- package/lib-commonjs/compose/types.d.ts +95 -21
- package/lib-commonjs/compose/types.js +8 -1
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/hooks/index.d.ts +9 -1
- package/lib-commonjs/hooks/index.js +31 -4
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useBoolean.d.ts +2 -2
- package/lib-commonjs/hooks/useBoolean.js +27 -14
- package/lib-commonjs/hooks/useBoolean.js.map +1 -1
- package/lib-commonjs/hooks/useConst.js +24 -14
- package/lib-commonjs/hooks/useConst.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.d.ts +21 -0
- package/lib-commonjs/hooks/useControllableState.js +78 -0
- package/lib-commonjs/hooks/useControllableState.js.map +1 -0
- package/lib-commonjs/hooks/useControllableValue.js +58 -53
- package/lib-commonjs/hooks/useControllableValue.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.d.ts +2 -2
- package/lib-commonjs/hooks/useEventCallback.js +26 -20
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.d.ts +11 -0
- package/lib-commonjs/hooks/useFirstMount.js +33 -0
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -0
- package/lib-commonjs/hooks/useForceUpdate.d.ts +4 -0
- package/lib-commonjs/hooks/useForceUpdate.js +19 -0
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -0
- package/lib-commonjs/hooks/useId.d.ts +7 -3
- package/lib-commonjs/hooks/useId.js +25 -21
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +9 -0
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +22 -6
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +25 -22
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useMount.d.ts +6 -0
- package/lib-commonjs/hooks/useMount.js +27 -0
- package/lib-commonjs/hooks/useMount.js.map +1 -0
- package/lib-commonjs/hooks/useOnClickOutside.d.ts +14 -4
- package/lib-commonjs/hooks/useOnClickOutside.js +141 -21
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.d.ts +5 -0
- package/lib-commonjs/hooks/useOnScrollOutside.js +47 -0
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -0
- package/lib-commonjs/hooks/usePrevious.d.ts +1 -0
- package/lib-commonjs/hooks/usePrevious.js +19 -0
- package/lib-commonjs/hooks/usePrevious.js.map +1 -0
- package/lib-commonjs/hooks/useTimeout.d.ts +8 -0
- package/lib-commonjs/hooks/useTimeout.js +40 -0
- package/lib-commonjs/hooks/useTimeout.js.map +1 -0
- package/lib-commonjs/hooks/useUnmount.d.ts +6 -0
- package/lib-commonjs/hooks/useUnmount.js +27 -0
- package/lib-commonjs/hooks/useUnmount.js.map +1 -0
- package/lib-commonjs/index.d.ts +1 -0
- package/lib-commonjs/index.js +11 -2
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.d.ts +33 -0
- package/lib-commonjs/ssr/SSRContext.js +80 -0
- package/lib-commonjs/ssr/SSRContext.js.map +1 -0
- package/lib-commonjs/ssr/canUseDOM.d.ts +4 -0
- package/lib-commonjs/ssr/canUseDOM.js +17 -0
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -0
- package/lib-commonjs/ssr/index.d.ts +2 -0
- package/lib-commonjs/ssr/index.js +12 -0
- package/lib-commonjs/ssr/index.js.map +1 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +5 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js +27 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -0
- package/lib-commonjs/utils/clamp.d.ts +8 -0
- package/lib-commonjs/utils/clamp.js +18 -0
- package/lib-commonjs/utils/clamp.js.map +1 -0
- package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
- package/lib-commonjs/utils/getNativeElementProps.js +58 -25
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.d.ts +4 -0
- package/lib-commonjs/utils/getRTLSafeKey.js +30 -0
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -0
- package/lib-commonjs/utils/index.d.ts +5 -0
- package/lib-commonjs/utils/index.js +19 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/omit.d.ts +1 -1
- package/lib-commonjs/utils/omit.js +16 -8
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/onlyChild.d.ts +5 -0
- package/lib-commonjs/utils/onlyChild.js +23 -0
- package/lib-commonjs/utils/onlyChild.js.map +1 -0
- package/lib-commonjs/utils/properties.js +84 -280
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +30 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
- package/package.json +11 -9
- package/NOTICE.txt +0 -0
- package/config/api-extractor.json +0 -3
- package/config/tests.js +0 -7
- package/etc/react-utilities.api.md +0 -207
- package/just.config.ts +0 -3
- package/lib/compose/makeMergeProps.d.ts +0 -15
- package/lib/compose/makeMergeProps.js +0 -96
- package/lib/compose/makeMergeProps.js.map +0 -1
- package/lib/compose/resolveShorthandProps.d.ts +0 -7
- package/lib/compose/resolveShorthandProps.js +0 -27
- package/lib/compose/resolveShorthandProps.js.map +0 -1
- package/lib-amd/compose/getSlots.d.ts +0 -20
- package/lib-amd/compose/getSlots.js +0 -51
- package/lib-amd/compose/getSlots.js.map +0 -1
- package/lib-amd/compose/index.d.ts +0 -5
- package/lib-amd/compose/index.js +0 -9
- package/lib-amd/compose/index.js.map +0 -1
- package/lib-amd/compose/makeMergeProps.d.ts +0 -15
- package/lib-amd/compose/makeMergeProps.js +0 -98
- package/lib-amd/compose/makeMergeProps.js.map +0 -1
- package/lib-amd/compose/nullRender.d.ts +0 -4
- package/lib-amd/compose/nullRender.js +0 -9
- package/lib-amd/compose/nullRender.js.map +0 -1
- package/lib-amd/compose/resolveShorthandProps.d.ts +0 -7
- package/lib-amd/compose/resolveShorthandProps.js +0 -29
- package/lib-amd/compose/resolveShorthandProps.js.map +0 -1
- package/lib-amd/compose/types.d.ts +0 -29
- package/lib-amd/compose/types.js +0 -5
- package/lib-amd/compose/types.js.map +0 -1
- package/lib-amd/hooks/index.d.ts +0 -8
- package/lib-amd/hooks/index.js +0 -13
- package/lib-amd/hooks/index.js.map +0 -1
- package/lib-amd/hooks/useBoolean.d.ts +0 -17
- package/lib-amd/hooks/useBoolean.js +0 -26
- package/lib-amd/hooks/useBoolean.js.map +0 -1
- package/lib-amd/hooks/useConst.d.ts +0 -12
- package/lib-amd/hooks/useConst.js +0 -31
- package/lib-amd/hooks/useConst.js.map +0 -1
- package/lib-amd/hooks/useControllableValue.d.ts +0 -20
- package/lib-amd/hooks/useControllableValue.js +0 -42
- package/lib-amd/hooks/useControllableValue.js.map +0 -1
- package/lib-amd/hooks/useEventCallback.d.ts +0 -13
- package/lib-amd/hooks/useEventCallback.js +0 -33
- package/lib-amd/hooks/useEventCallback.js.map +0 -1
- package/lib-amd/hooks/useId.d.ts +0 -11
- package/lib-amd/hooks/useId.js +0 -35
- package/lib-amd/hooks/useId.js.map +0 -1
- package/lib-amd/hooks/useIsomorphicLayoutEffect.d.ts +0 -2
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js +0 -9
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js.map +0 -1
- package/lib-amd/hooks/useMergedRefs.d.ts +0 -13
- package/lib-amd/hooks/useMergedRefs.js +0 -33
- package/lib-amd/hooks/useMergedRefs.js.map +0 -1
- package/lib-amd/hooks/useOnClickOutside.d.ts +0 -19
- package/lib-amd/hooks/useOnClickOutside.js +0 -27
- package/lib-amd/hooks/useOnClickOutside.js.map +0 -1
- package/lib-amd/index.d.ts +0 -3
- package/lib-amd/index.js +0 -8
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/utils/getNativeElementProps.d.ts +0 -9
- package/lib-amd/utils/getNativeElementProps.js +0 -40
- package/lib-amd/utils/getNativeElementProps.js.map +0 -1
- package/lib-amd/utils/index.d.ts +0 -3
- package/lib-amd/utils/index.js +0 -8
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/omit.d.ts +0 -14
- package/lib-amd/utils/omit.js +0 -30
- package/lib-amd/utils/omit.js.map +0 -1
- package/lib-amd/utils/properties.d.ts +0 -148
- package/lib-amd/utils/properties.js +0 -416
- package/lib-amd/utils/properties.js.map +0 -1
- package/lib-commonjs/compose/makeMergeProps.d.ts +0 -15
- package/lib-commonjs/compose/makeMergeProps.js +0 -98
- package/lib-commonjs/compose/makeMergeProps.js.map +0 -1
- package/lib-commonjs/compose/resolveShorthandProps.d.ts +0 -7
- package/lib-commonjs/compose/resolveShorthandProps.js +0 -29
- package/lib-commonjs/compose/resolveShorthandProps.js.map +0 -1
- package/src/compose/README.md +0 -279
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import { DispatchWithoutAction } from 'react';
|
2
|
+
import * as React_2 from 'react';
|
2
3
|
|
3
4
|
/**
|
4
5
|
* An array of A tag properties and events.
|
@@ -7,6 +8,23 @@ import * as React from 'react';
|
|
7
8
|
*/
|
8
9
|
export declare const anchorProperties: Record<string, number>;
|
9
10
|
|
11
|
+
/**
|
12
|
+
* Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
|
13
|
+
*/
|
14
|
+
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | ((props: TTriggerProps) => React_2.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactNode;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Helper type for inferring the type of the as prop from a Props type.
|
18
|
+
*
|
19
|
+
* For example:
|
20
|
+
* ```
|
21
|
+
* type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
|
25
|
+
as?: As;
|
26
|
+
};
|
27
|
+
|
10
28
|
/**
|
11
29
|
* An array of AUDIO tag properties and events.
|
12
30
|
|
@@ -28,10 +46,6 @@ export declare const baseElementEvents: Record<string, number>;
|
|
28
46
|
*/
|
29
47
|
export declare const baseElementProperties: Record<string, number>;
|
30
48
|
|
31
|
-
export declare interface BaseSlots {
|
32
|
-
root: React.ElementType;
|
33
|
-
}
|
34
|
-
|
35
49
|
/**
|
36
50
|
* An array of BUTTON tag properties and events.
|
37
51
|
*
|
@@ -39,22 +53,52 @@ export declare interface BaseSlots {
|
|
39
53
|
*/
|
40
54
|
export declare const buttonProperties: Record<string, number>;
|
41
55
|
|
42
|
-
|
56
|
+
/**
|
57
|
+
* Verifies if an application can use DOM.
|
58
|
+
*/
|
59
|
+
export declare function canUseDOM(): boolean;
|
60
|
+
|
61
|
+
export declare type ChangeCallback<TElement extends HTMLElement, TValue, TEvent extends React_2.SyntheticEvent<TElement> | undefined> = (ev: TEvent, newValue: TValue | undefined) => void;
|
43
62
|
|
44
63
|
/**
|
45
|
-
*
|
64
|
+
* Clamps `value` to a number between the min and max.
|
65
|
+
*
|
66
|
+
* @param value - the value to be clamped
|
67
|
+
* @param min - the lowest valid value
|
68
|
+
* @param max - the highest valid value
|
46
69
|
*/
|
47
|
-
export declare
|
70
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
48
71
|
|
49
72
|
export declare const colGroupProperties: Record<string, number>;
|
50
73
|
|
51
74
|
export declare const colProperties: Record<string, number>;
|
52
75
|
|
53
|
-
export declare
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
76
|
+
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
|
77
|
+
[Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
|
78
|
+
}, Primary & 'root'> & PropsWithoutRef<Shorthands[Primary]>;
|
79
|
+
|
80
|
+
export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
|
81
|
+
components?: {
|
82
|
+
[Key in keyof Shorthands]-?: React_2.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
83
|
+
};
|
84
|
+
} & Shorthands;
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Matches any shorthand props type.
|
88
|
+
*
|
89
|
+
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
|
90
|
+
* it shouldn't be used as the type of a slot.
|
91
|
+
*/
|
92
|
+
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
|
93
|
+
as?: keyof JSX.IntrinsicElements;
|
94
|
+
}>;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
98
|
+
*
|
99
|
+
* @internal
|
100
|
+
*/
|
101
|
+
export declare const defaultSSRContextValue: SSRContextValue;
|
58
102
|
|
59
103
|
/**
|
60
104
|
* Default value can be a value or an initializer
|
@@ -76,9 +120,9 @@ export declare const divProperties: Record<string, number>;
|
|
76
120
|
export declare const formProperties: Record<string, number>;
|
77
121
|
|
78
122
|
/**
|
79
|
-
*
|
123
|
+
* Return type for `React.forwardRef`, including inference of the proper typing for the ref.
|
80
124
|
*/
|
81
|
-
export declare type
|
125
|
+
export declare type ForwardRefComponent<Props> = ObscureEventName extends keyof Props ? Required<Props>[ObscureEventName] extends React_2.PointerEventHandler<infer Element> ? React_2.ForwardRefExoticComponent<Props & React_2.RefAttributes<Element>> : never : never;
|
82
126
|
|
83
127
|
/**
|
84
128
|
* Given an element tagname and user props, filters the props to only allowed props for the given
|
@@ -87,7 +131,7 @@ export declare type GenericDictionary = Record<string, any>;
|
|
87
131
|
* @param props - Props object
|
88
132
|
* @param excludedPropNames - List of props to disallow
|
89
133
|
*/
|
90
|
-
export declare function getNativeElementProps<TAttributes extends
|
134
|
+
export declare function getNativeElementProps<TAttributes extends React_2.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
|
91
135
|
|
92
136
|
/**
|
93
137
|
* Gets native supported props for an html element provided the allowance set. Use one of the property
|
@@ -105,11 +149,39 @@ export declare function getNativeElementProps<TAttributes extends React.HTMLAttr
|
|
105
149
|
*/
|
106
150
|
export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
|
107
151
|
|
152
|
+
/**
|
153
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
154
|
+
*
|
155
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
156
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
157
|
+
*
|
158
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
159
|
+
*/
|
160
|
+
export declare const getPartitionedNativeProps: ({ primarySlotTagName, props, excludedPropNames, }: {
|
161
|
+
/** The primary slot's element type (e.g. 'div') */
|
162
|
+
primarySlotTagName: keyof JSX.IntrinsicElements;
|
163
|
+
/** The component's props object */
|
164
|
+
props: Pick<React_2.HTMLAttributes<HTMLElement>, 'style' | 'className'>;
|
165
|
+
/** List of native props to exclude from the returned value */
|
166
|
+
excludedPropNames?: string[] | undefined;
|
167
|
+
}) => {
|
168
|
+
root: {
|
169
|
+
style: React_2.CSSProperties | undefined;
|
170
|
+
className: string | undefined;
|
171
|
+
};
|
172
|
+
primary: React_2.HTMLAttributes<any>;
|
173
|
+
};
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Finds and swaps a provided key for it's right to left format.
|
177
|
+
*/
|
178
|
+
export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
|
179
|
+
|
108
180
|
/**
|
109
181
|
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
110
182
|
* collections.
|
111
183
|
*
|
112
|
-
* The root is
|
184
|
+
* The root is derived from a mix of `components` props and `as` prop.
|
113
185
|
*
|
114
186
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
115
187
|
*
|
@@ -121,9 +193,9 @@ export declare function getNativeProps<T extends Record<string, any>>(props: Rec
|
|
121
193
|
* @param slotNames - Name of which props are slots
|
122
194
|
* @returns An object containing the `slots` map and `slotProps` map.
|
123
195
|
*/
|
124
|
-
export declare
|
125
|
-
slots:
|
126
|
-
slotProps:
|
196
|
+
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
|
197
|
+
slots: Slots<R>;
|
198
|
+
slotProps: SlotProps<R>;
|
127
199
|
};
|
128
200
|
|
129
201
|
/**
|
@@ -159,6 +231,39 @@ export declare const imgProperties: Record<string, number>;
|
|
159
231
|
*/
|
160
232
|
export declare const inputProperties: Record<string, number>;
|
161
233
|
|
234
|
+
/**
|
235
|
+
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
|
236
|
+
* For slots that support custom components, use {@link ObjectShorthandProps} instead.
|
237
|
+
*
|
238
|
+
* The first param is the slot's default type if no `as` prop is specified.
|
239
|
+
* The second param is an optional union of alternative types that can be specified for the `as` prop.
|
240
|
+
*
|
241
|
+
* ```
|
242
|
+
* IntrinsicShorthandProps<'div'> // Slot is always div
|
243
|
+
* IntrinsicShorthandProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
|
244
|
+
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
|
245
|
+
* ```
|
246
|
+
*/
|
247
|
+
export declare type IntrinsicShorthandProps<DefaultAs extends keyof JSX.IntrinsicElements, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultAs> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({
|
248
|
+
as?: DefaultAs;
|
249
|
+
} & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
|
250
|
+
[As in AlternateAs]: {
|
251
|
+
as: As;
|
252
|
+
} & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[As]>>;
|
253
|
+
}[AlternateAs];
|
254
|
+
|
255
|
+
/**
|
256
|
+
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
|
257
|
+
*
|
258
|
+
* ```
|
259
|
+
* IsSingleton<'a'> // true
|
260
|
+
* IsSingleton<'a' | 'b' | 'c'> // false
|
261
|
+
* ```
|
262
|
+
*/
|
263
|
+
export declare type IsSingleton<T extends string> = {
|
264
|
+
[K in T]: Exclude<T, K> extends never ? true : false;
|
265
|
+
}[T];
|
266
|
+
|
162
267
|
/**
|
163
268
|
* An array of LABEL tag properties and events.
|
164
269
|
*
|
@@ -174,30 +279,36 @@ export declare const labelProperties: Record<string, number>;
|
|
174
279
|
export declare const liProperties: Record<string, number>;
|
175
280
|
|
176
281
|
/**
|
177
|
-
*
|
178
|
-
* appropriately.
|
179
|
-
*
|
180
|
-
* @param target - the target object to merge onto.
|
181
|
-
* @param propSets - one or more prop sets to deep merge onto the target.
|
282
|
+
* Simple constant function for returning null, used to render empty templates in JSX.
|
182
283
|
*/
|
183
|
-
export declare const
|
284
|
+
export declare const nullRender: () => null;
|
184
285
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
286
|
+
/**
|
287
|
+
* Defines the slot props for a slot that supports a Component type.
|
288
|
+
*
|
289
|
+
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
|
290
|
+
*/
|
291
|
+
export declare type ObjectShorthandProps<Props extends {
|
292
|
+
children?: React_2.ReactNode;
|
293
|
+
} = {}> = Props & {
|
294
|
+
children?: Props['children'] | ShorthandRenderFunction<Props>;
|
191
295
|
};
|
192
296
|
|
297
|
+
export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
|
298
|
+
|
193
299
|
/**
|
194
|
-
*
|
300
|
+
* This is part of a hack to infer the element type from a native element *props* type.
|
301
|
+
* The only place the original element is found in a native props type (at least that's workable
|
302
|
+
* for inference) is in the event handlers, so some of the helper types use this event handler
|
303
|
+
* name to infer the original element type.
|
304
|
+
*
|
305
|
+
* Notes:
|
306
|
+
* - Using an extremely obscure event handler reduces the likelihood that its signature will be
|
307
|
+
* modified in any component's props.
|
308
|
+
* - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be
|
309
|
+
* less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.
|
195
310
|
*/
|
196
|
-
|
197
|
-
|
198
|
-
export declare type ObjectShorthandProps<TProps extends ComponentProps = {}> = TProps & {
|
199
|
-
children?: TProps['children'] | ShorthandRenderFunction<TProps>;
|
200
|
-
};
|
311
|
+
declare type ObscureEventName = 'onLostPointerCaptureCapture';
|
201
312
|
|
202
313
|
/**
|
203
314
|
* An array of OL tag properties and events.
|
@@ -219,23 +330,49 @@ export declare const olProperties: Record<string, number>;
|
|
219
330
|
* @param obj - The object to clone
|
220
331
|
* @param exclusions - The array of keys to exclude
|
221
332
|
*/
|
222
|
-
export declare function omit<TObj extends Record<string, any
|
333
|
+
export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
337
|
+
*/
|
338
|
+
export declare const onlyChild: <P>(child: string | number | boolean | {} | React_2.ReactNodeArray | React_2.ReactPortal | React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | null | undefined) => React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)>;
|
223
339
|
|
224
340
|
export declare const optionProperties: Record<string, number>;
|
225
341
|
|
342
|
+
/**
|
343
|
+
* Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
|
344
|
+
* IntrinsicShorthandProps). This allows IntrinsicShorthandProps to be used with React.forwardRef.
|
345
|
+
*
|
346
|
+
* The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
|
347
|
+
* types, to prevent unions from being expanded.
|
348
|
+
*/
|
349
|
+
export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
|
350
|
+
|
226
351
|
/**
|
227
352
|
* A Ref function which can be treated like a ref object in that it has an attached
|
228
353
|
* current property, which will be updated as the ref is evaluated.
|
229
354
|
*/
|
230
|
-
export declare type RefObjectFunction<T> =
|
355
|
+
export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) => void);
|
356
|
+
|
357
|
+
/**
|
358
|
+
* Resets generated IDs, should be used only in tests.
|
359
|
+
*
|
360
|
+
* @private
|
361
|
+
*/
|
362
|
+
export declare function resetIdsForTests(): void;
|
231
363
|
|
232
364
|
/**
|
233
|
-
*
|
234
|
-
*
|
235
|
-
* @param
|
236
|
-
* @param
|
365
|
+
* Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
|
366
|
+
* being passed down to getSlots method
|
367
|
+
* @param value - the base ShorthandProps
|
368
|
+
* @param options - options to resolve ShorthandProps
|
237
369
|
*/
|
238
|
-
export declare
|
370
|
+
export declare function resolveShorthand<Props extends DefaultObjectShorthandProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
|
371
|
+
|
372
|
+
export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
|
373
|
+
required?: Required;
|
374
|
+
defaultProps?: Props;
|
375
|
+
};
|
239
376
|
|
240
377
|
/**
|
241
378
|
* An array of SELECT tag properties and events.
|
@@ -244,18 +381,45 @@ export declare const resolveShorthandProps: <TProps>(props: TProps, shorthandPro
|
|
244
381
|
*/
|
245
382
|
export declare const selectProperties: Record<string, number>;
|
246
383
|
|
247
|
-
export declare type ShorthandProps<
|
248
|
-
children?: TProps['children'] | ShorthandRenderFunction<TProps>;
|
249
|
-
});
|
384
|
+
export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal | number | null | undefined | Props;
|
250
385
|
|
251
|
-
export declare type ShorthandRenderFunction<
|
386
|
+
export declare type ShorthandRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
|
252
387
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
388
|
+
/**
|
389
|
+
* Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
|
390
|
+
*
|
391
|
+
* Useful for situations where a keydown needs to be transformed to a click event
|
392
|
+
*/
|
393
|
+
export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React_2.KeyboardEvent): boolean;
|
394
|
+
|
395
|
+
declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
|
396
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends ObjectShorthandProps<infer P> ? P : never;
|
397
|
+
};
|
398
|
+
|
399
|
+
export declare type Slots<S extends ObjectShorthandPropsRecord> = {
|
400
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends ObjectShorthandProps<infer P> ? React_2.ElementType<NonNullable<P>> : React_2.ElementType<NonNullable<S[K]>>;
|
257
401
|
};
|
258
402
|
|
403
|
+
export declare const SSRContext: React_2.Context<SSRContextValue>;
|
404
|
+
|
405
|
+
/**
|
406
|
+
* To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request
|
407
|
+
* to ensure the client and server are consistent.
|
408
|
+
*
|
409
|
+
* @internal
|
410
|
+
*/
|
411
|
+
export declare type SSRContextValue = {
|
412
|
+
current: number;
|
413
|
+
};
|
414
|
+
|
415
|
+
/**
|
416
|
+
* When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
|
417
|
+
* are consistent between the client and server.
|
418
|
+
*
|
419
|
+
* @public
|
420
|
+
*/
|
421
|
+
export declare const SSRProvider: React_2.FC;
|
422
|
+
|
259
423
|
/**
|
260
424
|
* An array of TABLE tag properties and events.
|
261
425
|
*
|
@@ -291,6 +455,11 @@ export declare const thProperties: Record<string, number>;
|
|
291
455
|
*/
|
292
456
|
export declare const trProperties: Record<string, number>;
|
293
457
|
|
458
|
+
/**
|
459
|
+
* Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)
|
460
|
+
*/
|
461
|
+
export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
|
462
|
+
|
294
463
|
/**
|
295
464
|
* Hook to store a value and generate callbacks for setting the value to true or false.
|
296
465
|
* The identity of the callbacks will always stay the same.
|
@@ -301,14 +470,14 @@ export declare const trProperties: Record<string, number>;
|
|
301
470
|
export declare function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks];
|
302
471
|
|
303
472
|
/** Updater callbacks returned by `useBoolean`. */
|
304
|
-
export declare
|
473
|
+
export declare type UseBooleanCallbacks = {
|
305
474
|
/** Set the value to true. Always has the same identity. */
|
306
475
|
setTrue: () => void;
|
307
476
|
/** Set the value to false. Always has the same identity. */
|
308
477
|
setFalse: () => void;
|
309
478
|
/** Toggle the value. Always has the same identity. */
|
310
479
|
toggle: () => void;
|
311
|
-
}
|
480
|
+
};
|
312
481
|
|
313
482
|
/**
|
314
483
|
* Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
|
@@ -323,6 +492,28 @@ export declare interface UseBooleanCallbacks {
|
|
323
492
|
*/
|
324
493
|
export declare function useConst<T>(initialValue: T | (() => T)): T;
|
325
494
|
|
495
|
+
/**
|
496
|
+
* A useState 'like' hook that allows optional user control
|
497
|
+
* Useful for components which allow uncontrolled and controlled behaviour for users
|
498
|
+
* @returns - https://reactjs.org/docs/hooks-state.html
|
499
|
+
*/
|
500
|
+
export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
|
501
|
+
|
502
|
+
export declare type UseControllableStateOptions<State> = {
|
503
|
+
/**
|
504
|
+
* User provided default state or factory initializer
|
505
|
+
*/
|
506
|
+
defaultState?: State | (() => State);
|
507
|
+
/**
|
508
|
+
* User provided controllable state, undefined state means internal state will be used
|
509
|
+
*/
|
510
|
+
state: State | undefined;
|
511
|
+
/**
|
512
|
+
* Used to initialize state if all user provided states are undefined
|
513
|
+
*/
|
514
|
+
initialState: State;
|
515
|
+
};
|
516
|
+
|
326
517
|
/**
|
327
518
|
* Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
|
328
519
|
* text box string.
|
@@ -334,26 +525,43 @@ export declare function useConst<T>(initialValue: T | (() => T)): T;
|
|
334
525
|
* is passed the previous value and returns the new value.
|
335
526
|
* @see https://reactjs.org/docs/uncontrolled-components.html
|
336
527
|
*/
|
337
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update:
|
528
|
+
export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>) => void]>;
|
338
529
|
|
339
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement, TEvent extends
|
530
|
+
export declare function useControllableValue<TValue, TElement extends HTMLElement, TEvent extends React_2.SyntheticEvent<TElement> | undefined>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>, onChange: ChangeCallback<TElement, TValue, TEvent>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>, ev?: React_2.FormEvent<TElement>) => void]>;
|
340
531
|
|
341
532
|
/**
|
342
533
|
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
343
534
|
*
|
344
535
|
* Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
|
345
|
-
* e.g. user props are
|
536
|
+
* e.g. user props are dependencies which could change on every render
|
346
537
|
* e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
|
347
538
|
*
|
348
539
|
* This should not be used often, but can be a useful re-render optimization since the callback is a ref and
|
349
|
-
* will not be invalidated between
|
540
|
+
* will not be invalidated between re-renders
|
350
541
|
*
|
351
542
|
* @param fn - The callback function that will be used
|
352
543
|
*/
|
353
544
|
export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return;
|
354
545
|
|
355
546
|
/**
|
356
|
-
*
|
547
|
+
* Checks if components was mounted the first time.
|
548
|
+
* Since concurrent mode will be released in the future this needs to be verified
|
549
|
+
* Currently (React 17) will always render the initial mount once
|
550
|
+
* https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx
|
551
|
+
* https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx
|
552
|
+
*
|
553
|
+
* @example
|
554
|
+
* const isFirstMount = useFirstMount();
|
555
|
+
*/
|
556
|
+
export declare function useFirstMount(): boolean;
|
557
|
+
|
558
|
+
/**
|
559
|
+
* Forces a re-render, similar to `forceUpdate` in class components.
|
560
|
+
*/
|
561
|
+
export declare function useForceUpdate(): DispatchWithoutAction;
|
562
|
+
|
563
|
+
/**
|
564
|
+
* Hook to generate a unique ID.
|
357
565
|
*
|
358
566
|
* @param prefix - Optional prefix for the ID
|
359
567
|
* @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
|
@@ -362,7 +570,22 @@ export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...
|
|
362
570
|
*/
|
363
571
|
export declare function useId(prefix?: string, providedId?: string): string;
|
364
572
|
|
365
|
-
|
573
|
+
/**
|
574
|
+
* React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
|
575
|
+
* useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
|
576
|
+
* ensure we don't get a render flash for certain operations, but we may also need affected components to render on
|
577
|
+
* the server.
|
578
|
+
*
|
579
|
+
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
580
|
+
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
|
581
|
+
*/
|
582
|
+
export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
|
586
|
+
* browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
|
587
|
+
*/
|
588
|
+
export declare function useIsSSR(): boolean;
|
366
589
|
|
367
590
|
/**
|
368
591
|
* React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
|
@@ -370,28 +593,73 @@ export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
|
370
593
|
* @param refs - Refs to collectively update with one ref value.
|
371
594
|
* @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
|
372
595
|
*/
|
373
|
-
export declare function useMergedRefs<T>(...refs: (
|
596
|
+
export declare function useMergedRefs<T>(...refs: (React_2.Ref<T> | undefined)[]): RefObjectFunction<T>;
|
374
597
|
|
375
598
|
/**
|
376
|
-
*
|
599
|
+
* Hook which asynchronously executes a callback once the component has been mounted.
|
600
|
+
*
|
601
|
+
* @param callback - Function to call before mount.
|
377
602
|
*/
|
378
|
-
export declare const
|
603
|
+
export declare const useMount: (callback: () => void) => void;
|
379
604
|
|
380
|
-
export declare type
|
605
|
+
export declare type UseOnClickOrScrollOutsideOptions = {
|
381
606
|
/**
|
382
607
|
* The element to listen for the click event
|
383
608
|
*/
|
384
|
-
element
|
609
|
+
element: Document | undefined;
|
385
610
|
/**
|
386
611
|
* Refs to elements that check if the click is outside
|
387
612
|
*/
|
388
|
-
refs:
|
613
|
+
refs: React_2.MutableRefObject<HTMLElement | undefined | null>[];
|
614
|
+
/**
|
615
|
+
* By default uses element.contains, but custom contain function can be provided
|
616
|
+
* @param parentRef - provided parent ref
|
617
|
+
* @param child - event target element
|
618
|
+
*/
|
619
|
+
contains?(parent: HTMLElement | null, child: HTMLElement): boolean;
|
620
|
+
/**
|
621
|
+
* Disables event listeners
|
622
|
+
*/
|
623
|
+
disabled?: boolean;
|
389
624
|
/**
|
390
625
|
* Called if the click is outside the element refs
|
391
626
|
*/
|
392
627
|
callback: (ev: MouseEvent | TouchEvent) => void;
|
393
628
|
};
|
394
629
|
|
630
|
+
/**
|
631
|
+
* Utility to perform checks where a click/touch event was made outside a component
|
632
|
+
*/
|
633
|
+
export declare const useOnClickOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
|
634
|
+
|
635
|
+
/**
|
636
|
+
* Utility to perform checks where a click/touch event was made outside a component
|
637
|
+
*/
|
638
|
+
export declare const useOnScrollOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
|
639
|
+
|
640
|
+
export declare const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
|
641
|
+
|
642
|
+
/**
|
643
|
+
* @internal
|
644
|
+
*/
|
645
|
+
export declare function useSSRContext(): SSRContextValue;
|
646
|
+
|
647
|
+
/**
|
648
|
+
* Helper to manage a browser timeout.
|
649
|
+
* Ensures that the timeout isn't set multiple times at once,
|
650
|
+
* and is cleaned up when the component is unloaded.
|
651
|
+
*
|
652
|
+
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
653
|
+
*/
|
654
|
+
export declare function useTimeout(): readonly [(fn: () => void, delay: number) => void, () => void];
|
655
|
+
|
656
|
+
/**
|
657
|
+
* Hook which synchronously executes a callback when the component is about to unmount.
|
658
|
+
*
|
659
|
+
* @param callback - Function to call during unmount.
|
660
|
+
*/
|
661
|
+
export declare const useUnmount: (callback: () => void) => void;
|
662
|
+
|
395
663
|
/**
|
396
664
|
* An array of VIDEO tag properties and events.
|
397
665
|
*
|
@@ -1,8 +1,16 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { AsIntrinsicElement, ComponentState, ObjectShorthandPropsRecord, ObjectShorthandProps, UnionToIntersection } from './types';
|
3
|
+
export declare type Slots<S extends ObjectShorthandPropsRecord> = {
|
4
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends ObjectShorthandProps<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<NonNullable<S[K]>>;
|
5
|
+
};
|
6
|
+
declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
|
7
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends ObjectShorthandProps<infer P> ? P : never;
|
8
|
+
};
|
1
9
|
/**
|
2
10
|
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
3
11
|
* collections.
|
4
12
|
*
|
5
|
-
* The root is
|
13
|
+
* The root is derived from a mix of `components` props and `as` prop.
|
6
14
|
*
|
7
15
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
8
16
|
*
|
@@ -14,7 +22,8 @@
|
|
14
22
|
* @param slotNames - Name of which props are slots
|
15
23
|
* @returns An object containing the `slots` map and `slotProps` map.
|
16
24
|
*/
|
17
|
-
export declare
|
18
|
-
slots:
|
19
|
-
slotProps:
|
25
|
+
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
|
26
|
+
slots: Slots<R>;
|
27
|
+
slotProps: SlotProps<R>;
|
20
28
|
};
|
29
|
+
export {};
|