@fluentui/react-utilities 9.0.0-nightly.f81b28ceb3.1 → 9.0.0-rc.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 +209 -8
- package/CHANGELOG.md +64 -6
- package/dist/react-utilities.d.ts +225 -198
- package/lib/compose/getSlots.d.ts +11 -10
- package/lib/compose/getSlots.js +21 -30
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.d.ts +0 -5
- package/lib/compose/index.js +0 -5
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/resolveShorthand.d.ts +10 -6
- package/lib/compose/resolveShorthand.js +13 -12
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.d.ts +86 -76
- package/lib/compose/types.js +5 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.d.ts +1 -1
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useBoolean.js +10 -21
- package/lib/hooks/useBoolean.js.map +1 -1
- package/lib/hooks/useConst.js +1 -1
- package/lib/hooks/useConst.js.map +1 -1
- package/lib/hooks/useControllableState.d.ts +16 -6
- package/lib/hooks/useControllableState.js +26 -25
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +6 -12
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +1 -1
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +1 -3
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.d.ts +1 -1
- package/lib/hooks/useId.js +9 -5
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedEventCallbacks.d.ts +18 -0
- package/lib/hooks/useMergedEventCallbacks.js +26 -0
- package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib/hooks/useMergedRefs.js +5 -13
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useMount.js +3 -3
- package/lib/hooks/useMount.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +30 -36
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +13 -15
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +3 -3
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useTimeout.js +13 -17
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/hooks/useUnmount.js +5 -7
- package/lib/hooks/useUnmount.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +9 -15
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib/utils/applyTriggerPropsToChildren.js +24 -4
- package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/utils/clamp.js +1 -3
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.d.ts +22 -0
- package/lib/utils/getNativeElementProps.js +26 -3
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +1 -1
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.d.ts +25 -0
- package/lib/utils/getReactCallbackName.js +26 -0
- package/lib/utils/getReactCallbackName.js.map +1 -0
- package/lib/utils/getTriggerChild.d.ts +22 -0
- package/lib/utils/getTriggerChild.js +26 -0
- package/lib/utils/getTriggerChild.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isFluentTrigger.d.ts +22 -0
- package/lib/utils/isFluentTrigger.js +8 -0
- package/lib/utils/isFluentTrigger.js.map +1 -0
- package/lib/utils/omit.js +2 -2
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.d.ts +6 -0
- package/lib/utils/properties.js +63 -44
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/shouldPreventDefaultOnKeyDown.js +4 -4
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/lib-commonjs/compose/getSlots.d.ts +11 -10
- package/lib-commonjs/compose/getSlots.js +23 -34
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.d.ts +0 -5
- package/lib-commonjs/compose/index.js +1 -11
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.d.ts +10 -6
- package/lib-commonjs/compose/resolveShorthand.js +14 -14
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.d.ts +86 -76
- package/lib-commonjs/compose/types.js +5 -1
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/hooks/index.d.ts +1 -1
- package/lib-commonjs/hooks/index.js +3 -3
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useBoolean.js +12 -23
- package/lib-commonjs/hooks/useBoolean.js.map +1 -1
- package/lib-commonjs/hooks/useConst.js +2 -2
- package/lib-commonjs/hooks/useConst.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
- package/lib-commonjs/hooks/useControllableState.js +28 -27
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +8 -14
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +2 -2
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +2 -4
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.d.ts +1 -1
- package/lib-commonjs/hooks/useId.js +11 -7
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +18 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib-commonjs/hooks/useMergedRefs.js +6 -15
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useMount.js +4 -4
- package/lib-commonjs/hooks/useMount.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +32 -38
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +15 -17
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +4 -4
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +15 -19
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/hooks/useUnmount.js +6 -8
- package/lib-commonjs/hooks/useUnmount.js.map +1 -1
- package/lib-commonjs/index.js +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +9 -15
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js +1 -1
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js +26 -6
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +1 -3
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
- package/lib-commonjs/utils/getNativeElementProps.js +29 -4
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
- package/lib-commonjs/utils/getReactCallbackName.js +35 -0
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
- package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
- package/lib-commonjs/utils/getTriggerChild.js +37 -0
- package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
- package/lib-commonjs/utils/index.d.ts +2 -1
- package/lib-commonjs/utils/index.js +5 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
- package/lib-commonjs/utils/isFluentTrigger.js +17 -0
- package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
- package/lib-commonjs/utils/omit.js +2 -2
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.d.ts +6 -0
- package/lib-commonjs/utils/properties.js +60 -41
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +5 -5
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/package.json +6 -11
- package/lib/compose/getSlotsCompat.d.ts +0 -22
- package/lib/compose/getSlotsCompat.js +0 -56
- package/lib/compose/getSlotsCompat.js.map +0 -1
- package/lib/compose/makeMergeProps.d.ts +0 -15
- package/lib/compose/makeMergeProps.js +0 -106
- package/lib/compose/makeMergeProps.js.map +0 -1
- package/lib/compose/makeMergePropsCompat.d.ts +0 -9
- package/lib/compose/makeMergePropsCompat.js +0 -9
- package/lib/compose/makeMergePropsCompat.js.map +0 -1
- package/lib/compose/nullRender.d.ts +0 -4
- package/lib/compose/nullRender.js +0 -7
- package/lib/compose/nullRender.js.map +0 -1
- package/lib/compose/resolveShorthandProps.d.ts +0 -8
- package/lib/compose/resolveShorthandProps.js +0 -30
- package/lib/compose/resolveShorthandProps.js.map +0 -1
- package/lib/hooks/useControllableValue.d.ts +0 -20
- package/lib/hooks/useControllableValue.js +0 -62
- package/lib/hooks/useControllableValue.js.map +0 -1
- package/lib/utils/onlyChild.d.ts +0 -5
- package/lib/utils/onlyChild.js +0 -13
- package/lib/utils/onlyChild.js.map +0 -1
- package/lib-commonjs/compose/getSlotsCompat.d.ts +0 -22
- package/lib-commonjs/compose/getSlotsCompat.js +0 -68
- package/lib-commonjs/compose/getSlotsCompat.js.map +0 -1
- package/lib-commonjs/compose/makeMergeProps.d.ts +0 -15
- package/lib-commonjs/compose/makeMergeProps.js +0 -117
- package/lib-commonjs/compose/makeMergeProps.js.map +0 -1
- package/lib-commonjs/compose/makeMergePropsCompat.d.ts +0 -9
- package/lib-commonjs/compose/makeMergePropsCompat.js +0 -17
- package/lib-commonjs/compose/makeMergePropsCompat.js.map +0 -1
- package/lib-commonjs/compose/nullRender.d.ts +0 -4
- package/lib-commonjs/compose/nullRender.js +0 -16
- package/lib-commonjs/compose/nullRender.js.map +0 -1
- package/lib-commonjs/compose/resolveShorthandProps.d.ts +0 -8
- package/lib-commonjs/compose/resolveShorthandProps.js +0 -41
- package/lib-commonjs/compose/resolveShorthandProps.js.map +0 -1
- package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
- package/lib-commonjs/hooks/useControllableValue.js +0 -73
- package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
- package/lib-commonjs/utils/onlyChild.d.ts +0 -5
- package/lib-commonjs/utils/onlyChild.js +0 -23
- package/lib-commonjs/utils/onlyChild.js.map +0 -1
@@ -11,7 +11,7 @@ export declare const anchorProperties: Record<string, number>;
|
|
11
11
|
/**
|
12
12
|
* Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
|
13
13
|
*/
|
14
|
-
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string |
|
14
|
+
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>> | ((props: TTriggerProps) => React_2.ReactElement | null) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactElement | null;
|
15
15
|
|
16
16
|
/**
|
17
17
|
* Helper type for inferring the type of the as prop from a Props type.
|
@@ -46,10 +46,6 @@ export declare const baseElementEvents: Record<string, number>;
|
|
46
46
|
*/
|
47
47
|
export declare const baseElementProperties: Record<string, number>;
|
48
48
|
|
49
|
-
export declare type BaseSlotsCompat = {
|
50
|
-
root: React_2.ElementType;
|
51
|
-
};
|
52
|
-
|
53
49
|
/**
|
54
50
|
* An array of BUTTON tag properties and events.
|
55
51
|
*
|
@@ -62,8 +58,6 @@ export declare const buttonProperties: Record<string, number>;
|
|
62
58
|
*/
|
63
59
|
export declare function canUseDOM(): boolean;
|
64
60
|
|
65
|
-
export declare type ChangeCallback<TElement extends HTMLElement, TValue, TEvent extends React_2.SyntheticEvent<TElement> | undefined> = (ev: TEvent, newValue: TValue | undefined) => void;
|
66
|
-
|
67
61
|
/**
|
68
62
|
* Clamps `value` to a number between the min and max.
|
69
63
|
*
|
@@ -77,62 +71,72 @@ export declare const colGroupProperties: Record<string, number>;
|
|
77
71
|
|
78
72
|
export declare const colProperties: Record<string, number>;
|
79
73
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
export declare type
|
85
|
-
as?: React_2.ElementType;
|
86
|
-
className?: string;
|
87
|
-
children?: React_2.ReactNode;
|
88
|
-
};
|
74
|
+
/**
|
75
|
+
* Defines the Props type for a component given its slots and the definition of which one is the primary slot,
|
76
|
+
* defaulting to root if one is not provided.
|
77
|
+
*/
|
78
|
+
export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<Slots, Primary & 'root'> & PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;
|
89
79
|
|
90
|
-
|
91
|
-
|
92
|
-
|
80
|
+
/**
|
81
|
+
* Defines the State object of a component given its slots.
|
82
|
+
*/
|
83
|
+
export declare type ComponentState<Slots extends SlotPropsRecord> = {
|
84
|
+
components: {
|
85
|
+
[Key in keyof Slots]-?: React_2.ComponentType<ExtractSlotProps<Slots[Key]>> | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
93
86
|
};
|
94
|
-
} &
|
87
|
+
} & {
|
88
|
+
[Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
|
89
|
+
};
|
95
90
|
|
96
91
|
/**
|
97
|
-
*
|
98
|
-
* * Ensures the specified ShorthandProps are of type ObjectShorthandProps<T>
|
99
|
-
* * Marks the given defaulted props as required (-?)
|
92
|
+
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
100
93
|
*
|
101
|
-
* @
|
102
|
-
* @template ShorthandPropNames - The keys of Props that correspond to ShorthandProps
|
103
|
-
* @template DefaultedPropNames - The keys of Props that will always have a default value provided
|
94
|
+
* @internal
|
104
95
|
*/
|
105
|
-
export declare
|
96
|
+
export declare const defaultSSRContextValue: SSRContextValue;
|
106
97
|
|
107
98
|
/**
|
108
|
-
*
|
99
|
+
* An array of DIV tag properties and events.
|
109
100
|
*
|
110
|
-
*
|
111
|
-
* it shouldn't be used as the type of a slot.
|
101
|
+
* @public
|
112
102
|
*/
|
113
|
-
export declare
|
114
|
-
children?: React_2.ReactNode;
|
115
|
-
as?: keyof JSX.IntrinsicElements;
|
116
|
-
}>;
|
103
|
+
export declare const divProperties: Record<string, number>;
|
117
104
|
|
118
105
|
/**
|
119
|
-
*
|
106
|
+
* HTML element types that are not allowed to have children.
|
120
107
|
*
|
121
|
-
*
|
108
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
122
109
|
*/
|
123
|
-
|
110
|
+
declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
|
124
111
|
|
125
112
|
/**
|
126
|
-
*
|
113
|
+
* Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.
|
127
114
|
*/
|
128
|
-
declare type
|
115
|
+
export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
|
129
116
|
|
130
117
|
/**
|
131
|
-
* An array of
|
118
|
+
* An array of FIELDSET tag properties and events.
|
132
119
|
*
|
133
120
|
* @public
|
134
121
|
*/
|
135
|
-
export declare const
|
122
|
+
export declare const fieldsetProperties: Record<string, number>;
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Allows a component to be tagged as a FluentUI trigger component.
|
126
|
+
*
|
127
|
+
* Triggers are special-case components: they attach event listeners and other props on their child,
|
128
|
+
* and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
|
129
|
+
*
|
130
|
+
* A component can be tagged as a trigger as follows:
|
131
|
+
* ```ts
|
132
|
+
* const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
|
133
|
+
*
|
134
|
+
* MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
|
135
|
+
* ```
|
136
|
+
*/
|
137
|
+
export declare type FluentTriggerComponent = {
|
138
|
+
isFluentTriggerComponent?: boolean;
|
139
|
+
};
|
136
140
|
|
137
141
|
/**
|
138
142
|
* An array of FORM tag properties and events.
|
@@ -146,10 +150,6 @@ export declare const formProperties: Record<string, number>;
|
|
146
150
|
*/
|
147
151
|
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;
|
148
152
|
|
149
|
-
declare type GenericDictionary = Record<string, any>;
|
150
|
-
|
151
|
-
declare type GenericDictionary_2 = Record<string, any>;
|
152
|
-
|
153
153
|
/**
|
154
154
|
* Given an element tagname and user props, filters the props to only allowed props for the given
|
155
155
|
* element type.
|
@@ -175,6 +175,29 @@ export declare function getNativeElementProps<TAttributes extends React_2.HTMLAt
|
|
175
175
|
*/
|
176
176
|
export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
|
177
177
|
|
178
|
+
/**
|
179
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
180
|
+
*
|
181
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
182
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
183
|
+
*
|
184
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
185
|
+
*/
|
186
|
+
export declare const getPartitionedNativeProps: <Props extends Pick<React_2.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
|
187
|
+
/** The primary slot's element type (e.g. 'div') */
|
188
|
+
primarySlotTagName: keyof JSX.IntrinsicElements;
|
189
|
+
/** The component's props object */
|
190
|
+
props: Props;
|
191
|
+
/** List of native props to exclude from the returned value */
|
192
|
+
excludedPropNames?: ExcludedPropKeys[] | undefined;
|
193
|
+
}) => {
|
194
|
+
root: {
|
195
|
+
style: React_2.CSSProperties | undefined;
|
196
|
+
className: string | undefined;
|
197
|
+
};
|
198
|
+
primary: Omit<Props, ExcludedPropKeys>;
|
199
|
+
};
|
200
|
+
|
178
201
|
/**
|
179
202
|
* Finds and swaps a provided key for it's right to left format.
|
180
203
|
*/
|
@@ -189,37 +212,39 @@ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
|
|
189
212
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
190
213
|
*
|
191
214
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
192
|
-
* primitives, the props will be filtered according
|
193
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
215
|
+
* primitives, the props will be filtered according to the slot type by the type system.
|
216
|
+
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
217
|
+
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
218
|
+
* runtime code filtering props in this function.
|
194
219
|
*
|
195
220
|
* @param state - State including slot definitions
|
196
|
-
* @param slotNames - Name of which props are slots
|
197
221
|
* @returns An object containing the `slots` map and `slotProps` map.
|
198
222
|
*/
|
199
|
-
export declare function getSlots<R extends
|
223
|
+
export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
|
200
224
|
slots: Slots<R>;
|
201
|
-
slotProps:
|
225
|
+
slotProps: ObjectSlotProps<R>;
|
202
226
|
};
|
203
227
|
|
204
228
|
/**
|
205
|
-
*
|
206
|
-
* collections.
|
207
|
-
*
|
208
|
-
* The root is always derived from the `as` prop.
|
229
|
+
* Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
|
209
230
|
*
|
210
|
-
*
|
211
|
-
*
|
212
|
-
*
|
213
|
-
* primitives, the props will be filtered according the the slot type. For example, if the
|
214
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
|
231
|
+
* In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
|
232
|
+
* it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
|
233
|
+
* This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
|
215
234
|
*
|
216
|
-
*
|
217
|
-
*
|
218
|
-
*
|
235
|
+
* For example, the following returns `<div id="child" />`:
|
236
|
+
* ```jsx
|
237
|
+
* getTriggerChild(
|
238
|
+
* <Tooltip>
|
239
|
+
* <MenuTrigger>
|
240
|
+
* <div id="child" />
|
241
|
+
* </MenuTrigger>
|
242
|
+
* </Tooltip>
|
243
|
+
* );
|
244
|
+
* ```
|
219
245
|
*/
|
220
|
-
export declare const
|
221
|
-
|
222
|
-
slotProps: Record<string, any>;
|
246
|
+
export declare const getTriggerChild: (children: React_2.ReactNode) => React_2.ReactElement & {
|
247
|
+
ref?: React_2.Ref<unknown>;
|
223
248
|
};
|
224
249
|
|
225
250
|
/**
|
@@ -256,25 +281,19 @@ export declare const imgProperties: Record<string, number>;
|
|
256
281
|
export declare const inputProperties: Record<string, number>;
|
257
282
|
|
258
283
|
/**
|
259
|
-
*
|
260
|
-
*
|
261
|
-
*
|
262
|
-
* The first param is the slot's default type if no `as` prop is specified.
|
263
|
-
* The second param is an optional union of alternative types that can be specified for the `as` prop.
|
264
|
-
*
|
265
|
-
* ```
|
266
|
-
* IntrinsicShorthandProps<'div'> // Slot is always div
|
267
|
-
* IntrinsicShorthandProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
|
268
|
-
* IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
|
269
|
-
* ```
|
284
|
+
* Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
|
285
|
+
* * Removes legacy string ref.
|
286
|
+
* * Disallows children for empty tags like 'img'.
|
270
287
|
*/
|
271
|
-
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
288
|
+
declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React_2.PropsWithRef<JSX.IntrinsicElements[Type]> & (Type extends EmptyIntrisicElements ? {
|
289
|
+
children?: never;
|
290
|
+
} : {});
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
294
|
+
* See the {@link FluentTriggerComponent} type for more info.
|
295
|
+
*/
|
296
|
+
export declare const isFluentTrigger: (element: React_2.ReactElement) => boolean | undefined;
|
278
297
|
|
279
298
|
/**
|
280
299
|
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
|
@@ -302,52 +321,10 @@ export declare const labelProperties: Record<string, number>;
|
|
302
321
|
*/
|
303
322
|
export declare const liProperties: Record<string, number>;
|
304
323
|
|
305
|
-
|
306
|
-
|
307
|
-
* appropriately.
|
308
|
-
*
|
309
|
-
* @param target - the target object to merge onto.
|
310
|
-
* @param propSets - one or more prop sets to deep merge onto the target.
|
311
|
-
*/
|
312
|
-
export declare const makeMergeProps: <TState>(options?: MergePropsOptions<TState>) => (target: TState, ...propSets: (Partial<TState> | undefined)[]) => TState;
|
313
|
-
|
314
|
-
/**
|
315
|
-
* Backwards-compatible version of makeMergeProps that has less restrictive type checking
|
316
|
-
*
|
317
|
-
* @deprecated Use makeMergeProps instead
|
318
|
-
*/
|
319
|
-
export declare const makeMergePropsCompat: <TState = Record<string, any>>(options?: MergePropsOptions<Record<string, any>> | undefined) => (target: GenericDictionary_2, ...propSets: (GenericDictionary_2 | undefined)[]) => TState;
|
320
|
-
|
321
|
-
export declare type MergePropsOptions<TState> = {
|
322
|
-
/**
|
323
|
-
* A list of props to deep merge. By default, `style` will
|
324
|
-
* always be deep merged so it's not required to be provided.
|
325
|
-
*/
|
326
|
-
deepMerge?: readonly (keyof TState)[];
|
327
|
-
};
|
328
|
-
|
329
|
-
/**
|
330
|
-
* Simple constant function for returning null, used to render empty templates in JSX.
|
331
|
-
*/
|
332
|
-
export declare const nullRender: () => null;
|
333
|
-
|
334
|
-
/**
|
335
|
-
* Defines the slot props for a slot that supports a Component type.
|
336
|
-
*
|
337
|
-
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
|
338
|
-
*/
|
339
|
-
export declare type ObjectShorthandProps<Props extends {
|
340
|
-
children?: React_2.ReactNode;
|
341
|
-
} = {}> = Props & {
|
342
|
-
children?: Props['children'] | ShorthandRenderFunction<Props>;
|
343
|
-
};
|
344
|
-
|
345
|
-
export declare type ObjectShorthandPropsCompat<TProps extends ComponentPropsCompat = {}> = TProps & Omit<ComponentPropsCompat, 'children'> & {
|
346
|
-
children?: TProps['children'] | ShorthandRenderFunctionCompat<TProps>;
|
324
|
+
declare type ObjectSlotProps<S extends SlotPropsRecord> = {
|
325
|
+
[K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : ExtractSlotProps<S[K]> extends React_2.ComponentType<infer P> ? P : never;
|
347
326
|
};
|
348
327
|
|
349
|
-
export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
|
350
|
-
|
351
328
|
/**
|
352
329
|
* This is part of a hack to infer the element type from a native element *props* type.
|
353
330
|
* The only place the original element is found in a native props type (at least that's workable
|
@@ -384,16 +361,11 @@ export declare const olProperties: Record<string, number>;
|
|
384
361
|
*/
|
385
362
|
export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
|
386
363
|
|
387
|
-
/**
|
388
|
-
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
389
|
-
*/
|
390
|
-
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>)>;
|
391
|
-
|
392
364
|
export declare const optionProperties: Record<string, number>;
|
393
365
|
|
394
366
|
/**
|
395
367
|
* Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
|
396
|
-
*
|
368
|
+
* IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
|
397
369
|
*
|
398
370
|
* The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
|
399
371
|
* types, to prevent unions from being expanded.
|
@@ -407,12 +379,9 @@ export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unkn
|
|
407
379
|
export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) => void);
|
408
380
|
|
409
381
|
/**
|
410
|
-
*
|
411
|
-
* Similar to Required<T> except it only requires a subset of the props.
|
382
|
+
* If type T includes `null`, remove it and add `undefined` instead.
|
412
383
|
*/
|
413
|
-
export declare type
|
414
|
-
[P in K]-?: T[P];
|
415
|
-
};
|
384
|
+
export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
|
416
385
|
|
417
386
|
/**
|
418
387
|
* Resets generated IDs, should be used only in tests.
|
@@ -422,33 +391,23 @@ export declare type RequiredPropsCompat<T, K extends keyof T> = Omit<T, K> & {
|
|
422
391
|
export declare function resetIdsForTests(): void;
|
423
392
|
|
424
393
|
/**
|
425
|
-
*
|
426
|
-
*/
|
427
|
-
export declare type ResolvedShorthandPropsCompat<T, K extends keyof T> = Omit<T, K> & {
|
428
|
-
[P in K]: T[P] extends ShorthandPropsCompat<infer U> ? ObjectShorthandPropsCompat<U> : T[P];
|
429
|
-
};
|
430
|
-
|
431
|
-
/**
|
432
|
-
* Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
|
394
|
+
* Resolves shorthands into slot props, to ensure normalization of the signature
|
433
395
|
* being passed down to getSlots method
|
434
|
-
* @param value - the base
|
435
|
-
* @param options - options to resolve
|
396
|
+
* @param value - the base shorthand props
|
397
|
+
* @param options - options to resolve shorthand props
|
436
398
|
*/
|
437
|
-
export declare
|
399
|
+
export declare const resolveShorthand: ResolveShorthandFunction;
|
438
400
|
|
439
|
-
export declare type
|
401
|
+
export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
|
402
|
+
<P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, true>): ReplaceNullWithUndefined<P>;
|
403
|
+
<P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>): ReplaceNullWithUndefined<P> | undefined;
|
404
|
+
};
|
405
|
+
|
406
|
+
export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
|
440
407
|
required?: Required;
|
441
408
|
defaultProps?: Props;
|
442
409
|
};
|
443
410
|
|
444
|
-
/**
|
445
|
-
* Ensures that the given slots are represented using object syntax. This ensures that
|
446
|
-
* the object can be merged along with other objects.
|
447
|
-
* @param props - The incoming props
|
448
|
-
* @param shorthandPropNames - An array of prop names to apply simplification to
|
449
|
-
*/
|
450
|
-
export declare const resolveShorthandProps: <TProps, TShorthandPropNames extends keyof TProps>(props: TProps, shorthandPropNames: readonly TShorthandPropNames[]) => ResolvedShorthandPropsCompat<TProps, TShorthandPropNames>;
|
451
|
-
|
452
411
|
/**
|
453
412
|
* An array of SELECT tag properties and events.
|
454
413
|
*
|
@@ -456,14 +415,6 @@ export declare const resolveShorthandProps: <TProps, TShorthandPropNames extends
|
|
456
415
|
*/
|
457
416
|
export declare const selectProperties: Record<string, number>;
|
458
417
|
|
459
|
-
export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal | number | null | undefined | Props;
|
460
|
-
|
461
|
-
export declare type ShorthandPropsCompat<TProps extends ComponentPropsCompat = {}> = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal | number | null | undefined | ObjectShorthandPropsCompat<TProps>;
|
462
|
-
|
463
|
-
export declare type ShorthandRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
|
464
|
-
|
465
|
-
export declare type ShorthandRenderFunctionCompat<TProps> = (Component: React_2.ElementType<TProps>, props: TProps) => React_2.ReactNode;
|
466
|
-
|
467
418
|
/**
|
468
419
|
* Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
|
469
420
|
*
|
@@ -471,20 +422,55 @@ export declare type ShorthandRenderFunctionCompat<TProps> = (Component: React_2.
|
|
471
422
|
*/
|
472
423
|
export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React_2.KeyboardEvent): boolean;
|
473
424
|
|
474
|
-
|
475
|
-
|
476
|
-
|
425
|
+
/**
|
426
|
+
* The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,
|
427
|
+
* or a component like `typeof Button`.
|
428
|
+
*
|
429
|
+
* If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).
|
430
|
+
*
|
431
|
+
* By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,
|
432
|
+
* wrap with `NonNullable` (see examples below).
|
433
|
+
*
|
434
|
+
* @example
|
435
|
+
* ```
|
436
|
+
* // Intrinsic element examples:
|
437
|
+
* Slot<'div'> // Slot is always div
|
438
|
+
* Slot<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
|
439
|
+
* Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as="div" or as="pre"
|
440
|
+
* NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)
|
441
|
+
*
|
442
|
+
* // Component examples:
|
443
|
+
* Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props
|
444
|
+
* NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
|
445
|
+
* ```
|
446
|
+
*/
|
447
|
+
export declare type Slot<Type extends keyof JSX.IntrinsicElements | React_2.ComponentType | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
|
448
|
+
as?: Type;
|
449
|
+
} & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
|
450
|
+
[As in AlternateAs]: {
|
451
|
+
as: As;
|
452
|
+
} & WithSlotRenderFunction<IntrisicElementProps<As>>;
|
453
|
+
}[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
|
477
454
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
455
|
+
/**
|
456
|
+
* Matches any component's Slots type (such as ButtonSlots).
|
457
|
+
*
|
458
|
+
* This should ONLY be used in type templates as in `extends SlotPropsRecord`;
|
459
|
+
* it shouldn't be used as a component's Slots type.
|
460
|
+
*/
|
461
|
+
export declare type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
|
462
|
+
|
463
|
+
export declare type SlotRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
|
483
464
|
|
484
|
-
export declare type Slots<S extends
|
485
|
-
[K in keyof S]
|
465
|
+
export declare type Slots<S extends SlotPropsRecord> = {
|
466
|
+
[K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? As : ExtractSlotProps<S[K]> extends React_2.ComponentType<infer P> ? React_2.ElementType<NonNullable<P>> : React_2.ElementType<ExtractSlotProps<S[K]>>;
|
486
467
|
};
|
487
468
|
|
469
|
+
/**
|
470
|
+
* The shorthand value of a slot allows specifying its child
|
471
|
+
*/
|
472
|
+
export declare type SlotShorthandValue = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal;
|
473
|
+
|
488
474
|
export declare const SSRContext: React_2.Context<SSRContextValue>;
|
489
475
|
|
490
476
|
/**
|
@@ -545,6 +531,16 @@ export declare const trProperties: Record<string, number>;
|
|
545
531
|
*/
|
546
532
|
export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
|
547
533
|
|
534
|
+
/**
|
535
|
+
* Matches any slot props type.
|
536
|
+
*
|
537
|
+
* This should ONLY be used in type templates as in `extends UnknownSlotProps`;
|
538
|
+
* it shouldn't be used as the type of a slot.
|
539
|
+
*/
|
540
|
+
export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
|
541
|
+
as?: keyof JSX.IntrinsicElements;
|
542
|
+
};
|
543
|
+
|
548
544
|
/**
|
549
545
|
* Hook to store a value and generate callbacks for setting the value to true or false.
|
550
546
|
* The identity of the callbacks will always stay the same.
|
@@ -578,42 +574,37 @@ export declare type UseBooleanCallbacks = {
|
|
578
574
|
export declare function useConst<T>(initialValue: T | (() => T)): T;
|
579
575
|
|
580
576
|
/**
|
581
|
-
* A useState
|
582
|
-
*
|
583
|
-
*
|
577
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
578
|
+
* such as a checked state or text input string.
|
579
|
+
*
|
580
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
581
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
582
|
+
*
|
583
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
584
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
585
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
586
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
587
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
588
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
584
589
|
*/
|
585
590
|
export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
|
586
591
|
|
587
592
|
export declare type UseControllableStateOptions<State> = {
|
588
593
|
/**
|
589
|
-
* User
|
594
|
+
* User-provided default state or initializer, for uncontrolled usage.
|
590
595
|
*/
|
591
596
|
defaultState?: State | (() => State);
|
592
597
|
/**
|
593
|
-
* User
|
598
|
+
* User-provided controlled state. `undefined` means internal state will be used.
|
594
599
|
*/
|
595
600
|
state: State | undefined;
|
596
601
|
/**
|
597
|
-
* Used
|
602
|
+
* Used as the initial state if `state` and `defaultState` are both `undefined`.
|
603
|
+
* If `undefined` is the correct initial state, pass that here.
|
598
604
|
*/
|
599
605
|
initialState: State;
|
600
606
|
};
|
601
607
|
|
602
|
-
/**
|
603
|
-
* Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
|
604
|
-
* text box string.
|
605
|
-
* @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
|
606
|
-
* and the internal state will be updated to reflect it.
|
607
|
-
* @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
|
608
|
-
* @returns An array of the current value and an updater callback. Like `React.useState`, the updater
|
609
|
-
* callback always has the same identity, and it can take either a new value, or a function which
|
610
|
-
* is passed the previous value and returns the new value.
|
611
|
-
* @see https://reactjs.org/docs/uncontrolled-components.html
|
612
|
-
*/
|
613
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>) => void]>;
|
614
|
-
|
615
|
-
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]>;
|
616
|
-
|
617
608
|
/**
|
618
609
|
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
619
610
|
*
|
@@ -648,7 +639,7 @@ export declare function useForceUpdate(): DispatchWithoutAction;
|
|
648
639
|
/**
|
649
640
|
* Hook to generate a unique ID.
|
650
641
|
*
|
651
|
-
* @param prefix - Optional prefix for the ID
|
642
|
+
* @param prefix - Optional prefix for the ID. Defaults to 'fui-'.
|
652
643
|
* @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
|
653
644
|
* without conditioning the hook call
|
654
645
|
* @returns The ID
|
@@ -672,6 +663,25 @@ export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
|
|
672
663
|
*/
|
673
664
|
export declare function useIsSSR(): boolean;
|
674
665
|
|
666
|
+
/**
|
667
|
+
* Combine two event callbacks into a single callback function that calls each one in order.
|
668
|
+
*
|
669
|
+
* This is useful to add an event listener to an existing element without overwriting the current listener, if any.
|
670
|
+
*
|
671
|
+
* For example:
|
672
|
+
* ```ts
|
673
|
+
* state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
|
674
|
+
* // Handle onChange
|
675
|
+
* });
|
676
|
+
* ```
|
677
|
+
*
|
678
|
+
* @param callback1 - The first callback to be called
|
679
|
+
* @param callback2 - The second callback to be called
|
680
|
+
*
|
681
|
+
* @returns An event callback that calls the callbacks in order, and is stable between renders
|
682
|
+
*/
|
683
|
+
export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
|
684
|
+
|
675
685
|
/**
|
676
686
|
* React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
|
677
687
|
* updates all provided refs
|
@@ -752,4 +762,21 @@ export declare const useUnmount: (callback: () => void) => void;
|
|
752
762
|
*/
|
753
763
|
export declare const videoProperties: Record<string, number>;
|
754
764
|
|
765
|
+
/**
|
766
|
+
* Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
|
767
|
+
* to be a render function that takes those props.
|
768
|
+
*/
|
769
|
+
declare type WithSlotRenderFunction<Props extends {
|
770
|
+
children?: unknown;
|
771
|
+
}> = Props & {
|
772
|
+
children?: Props['children'] | SlotRenderFunction<Props>;
|
773
|
+
};
|
774
|
+
|
775
|
+
/**
|
776
|
+
* Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.
|
777
|
+
*/
|
778
|
+
declare type WithSlotShorthandValue<Props extends {
|
779
|
+
children?: unknown;
|
780
|
+
}> = Props | Extract<SlotShorthandValue, Props['children']>;
|
781
|
+
|
755
782
|
export { }
|