@fluentui/react-utilities 9.0.0-nightly.f81b28ceb3.1 → 9.0.0-rc.1

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.
Files changed (206) hide show
  1. package/CHANGELOG.json +167 -8
  2. package/CHANGELOG.md +44 -6
  3. package/dist/react-utilities.d.ts +218 -198
  4. package/lib/compose/getSlots.d.ts +11 -10
  5. package/lib/compose/getSlots.js +21 -30
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.d.ts +0 -5
  8. package/lib/compose/index.js +0 -5
  9. package/lib/compose/index.js.map +1 -1
  10. package/lib/compose/resolveShorthand.d.ts +10 -6
  11. package/lib/compose/resolveShorthand.js +13 -12
  12. package/lib/compose/resolveShorthand.js.map +1 -1
  13. package/lib/compose/types.d.ts +86 -76
  14. package/lib/compose/types.js +5 -1
  15. package/lib/compose/types.js.map +1 -1
  16. package/lib/hooks/index.d.ts +1 -1
  17. package/lib/hooks/index.js +1 -1
  18. package/lib/hooks/index.js.map +1 -1
  19. package/lib/hooks/useBoolean.js +10 -21
  20. package/lib/hooks/useBoolean.js.map +1 -1
  21. package/lib/hooks/useConst.js +1 -1
  22. package/lib/hooks/useConst.js.map +1 -1
  23. package/lib/hooks/useControllableState.d.ts +16 -6
  24. package/lib/hooks/useControllableState.js +26 -25
  25. package/lib/hooks/useControllableState.js.map +1 -1
  26. package/lib/hooks/useEventCallback.js +6 -12
  27. package/lib/hooks/useEventCallback.js.map +1 -1
  28. package/lib/hooks/useFirstMount.js +1 -1
  29. package/lib/hooks/useFirstMount.js.map +1 -1
  30. package/lib/hooks/useForceUpdate.js +1 -3
  31. package/lib/hooks/useForceUpdate.js.map +1 -1
  32. package/lib/hooks/useId.js +2 -4
  33. package/lib/hooks/useId.js.map +1 -1
  34. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -1
  35. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  36. package/lib/hooks/useMergedEventCallbacks.d.ts +18 -0
  37. package/lib/hooks/useMergedEventCallbacks.js +26 -0
  38. package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
  39. package/lib/hooks/useMergedRefs.js +5 -13
  40. package/lib/hooks/useMergedRefs.js.map +1 -1
  41. package/lib/hooks/useMount.js +3 -3
  42. package/lib/hooks/useMount.js.map +1 -1
  43. package/lib/hooks/useOnClickOutside.js +30 -36
  44. package/lib/hooks/useOnClickOutside.js.map +1 -1
  45. package/lib/hooks/useOnScrollOutside.js +13 -15
  46. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  47. package/lib/hooks/usePrevious.js +3 -3
  48. package/lib/hooks/usePrevious.js.map +1 -1
  49. package/lib/hooks/useTimeout.js +13 -17
  50. package/lib/hooks/useTimeout.js.map +1 -1
  51. package/lib/hooks/useUnmount.js +5 -7
  52. package/lib/hooks/useUnmount.js.map +1 -1
  53. package/lib/ssr/SSRContext.js +9 -15
  54. package/lib/ssr/SSRContext.js.map +1 -1
  55. package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
  56. package/lib/utils/applyTriggerPropsToChildren.js +24 -4
  57. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  58. package/lib/utils/clamp.js +1 -3
  59. package/lib/utils/clamp.js.map +1 -1
  60. package/lib/utils/getNativeElementProps.d.ts +22 -0
  61. package/lib/utils/getNativeElementProps.js +24 -2
  62. package/lib/utils/getNativeElementProps.js.map +1 -1
  63. package/lib/utils/getRTLSafeKey.js +1 -1
  64. package/lib/utils/getRTLSafeKey.js.map +1 -1
  65. package/lib/utils/getReactCallbackName.d.ts +25 -0
  66. package/lib/utils/getReactCallbackName.js +26 -0
  67. package/lib/utils/getReactCallbackName.js.map +1 -0
  68. package/lib/utils/getTriggerChild.d.ts +22 -0
  69. package/lib/utils/getTriggerChild.js +26 -0
  70. package/lib/utils/getTriggerChild.js.map +1 -0
  71. package/lib/utils/index.d.ts +2 -1
  72. package/lib/utils/index.js +2 -1
  73. package/lib/utils/index.js.map +1 -1
  74. package/lib/utils/isFluentTrigger.d.ts +22 -0
  75. package/lib/utils/isFluentTrigger.js +8 -0
  76. package/lib/utils/isFluentTrigger.js.map +1 -0
  77. package/lib/utils/omit.js +2 -2
  78. package/lib/utils/omit.js.map +1 -1
  79. package/lib/utils/properties.js +55 -44
  80. package/lib/utils/properties.js.map +1 -1
  81. package/lib/utils/shouldPreventDefaultOnKeyDown.js +4 -4
  82. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  83. package/lib-commonjs/compose/getSlots.d.ts +11 -10
  84. package/lib-commonjs/compose/getSlots.js +23 -34
  85. package/lib-commonjs/compose/getSlots.js.map +1 -1
  86. package/lib-commonjs/compose/index.d.ts +0 -5
  87. package/lib-commonjs/compose/index.js +1 -11
  88. package/lib-commonjs/compose/index.js.map +1 -1
  89. package/lib-commonjs/compose/resolveShorthand.d.ts +10 -6
  90. package/lib-commonjs/compose/resolveShorthand.js +14 -14
  91. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  92. package/lib-commonjs/compose/types.d.ts +86 -76
  93. package/lib-commonjs/compose/types.js +5 -1
  94. package/lib-commonjs/compose/types.js.map +1 -1
  95. package/lib-commonjs/hooks/index.d.ts +1 -1
  96. package/lib-commonjs/hooks/index.js +3 -3
  97. package/lib-commonjs/hooks/index.js.map +1 -1
  98. package/lib-commonjs/hooks/useBoolean.js +12 -23
  99. package/lib-commonjs/hooks/useBoolean.js.map +1 -1
  100. package/lib-commonjs/hooks/useConst.js +2 -2
  101. package/lib-commonjs/hooks/useConst.js.map +1 -1
  102. package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
  103. package/lib-commonjs/hooks/useControllableState.js +28 -27
  104. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  105. package/lib-commonjs/hooks/useEventCallback.js +8 -14
  106. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  107. package/lib-commonjs/hooks/useFirstMount.js +2 -2
  108. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  109. package/lib-commonjs/hooks/useForceUpdate.js +2 -4
  110. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  111. package/lib-commonjs/hooks/useId.js +4 -6
  112. package/lib-commonjs/hooks/useId.js.map +1 -1
  113. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +2 -2
  114. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  115. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +18 -0
  116. package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
  117. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
  118. package/lib-commonjs/hooks/useMergedRefs.js +6 -15
  119. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  120. package/lib-commonjs/hooks/useMount.js +4 -4
  121. package/lib-commonjs/hooks/useMount.js.map +1 -1
  122. package/lib-commonjs/hooks/useOnClickOutside.js +32 -38
  123. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  124. package/lib-commonjs/hooks/useOnScrollOutside.js +15 -17
  125. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  126. package/lib-commonjs/hooks/usePrevious.js +4 -4
  127. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  128. package/lib-commonjs/hooks/useTimeout.js +15 -19
  129. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  130. package/lib-commonjs/hooks/useUnmount.js +6 -8
  131. package/lib-commonjs/hooks/useUnmount.js.map +1 -1
  132. package/lib-commonjs/index.js +1 -1
  133. package/lib-commonjs/ssr/SSRContext.js +9 -15
  134. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  135. package/lib-commonjs/ssr/index.js +1 -1
  136. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
  137. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +26 -6
  138. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  139. package/lib-commonjs/utils/clamp.js +1 -3
  140. package/lib-commonjs/utils/clamp.js.map +1 -1
  141. package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
  142. package/lib-commonjs/utils/getNativeElementProps.js +28 -4
  143. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  144. package/lib-commonjs/utils/getRTLSafeKey.js +1 -1
  145. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  146. package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
  147. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  148. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  149. package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
  150. package/lib-commonjs/utils/getTriggerChild.js +37 -0
  151. package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
  152. package/lib-commonjs/utils/index.d.ts +2 -1
  153. package/lib-commonjs/utils/index.js +5 -3
  154. package/lib-commonjs/utils/index.js.map +1 -1
  155. package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
  156. package/lib-commonjs/utils/isFluentTrigger.js +17 -0
  157. package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
  158. package/lib-commonjs/utils/omit.js +2 -2
  159. package/lib-commonjs/utils/omit.js.map +1 -1
  160. package/lib-commonjs/utils/properties.js +51 -40
  161. package/lib-commonjs/utils/properties.js.map +1 -1
  162. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +5 -5
  163. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  164. package/package.json +6 -11
  165. package/lib/compose/getSlotsCompat.d.ts +0 -22
  166. package/lib/compose/getSlotsCompat.js +0 -56
  167. package/lib/compose/getSlotsCompat.js.map +0 -1
  168. package/lib/compose/makeMergeProps.d.ts +0 -15
  169. package/lib/compose/makeMergeProps.js +0 -106
  170. package/lib/compose/makeMergeProps.js.map +0 -1
  171. package/lib/compose/makeMergePropsCompat.d.ts +0 -9
  172. package/lib/compose/makeMergePropsCompat.js +0 -9
  173. package/lib/compose/makeMergePropsCompat.js.map +0 -1
  174. package/lib/compose/nullRender.d.ts +0 -4
  175. package/lib/compose/nullRender.js +0 -7
  176. package/lib/compose/nullRender.js.map +0 -1
  177. package/lib/compose/resolveShorthandProps.d.ts +0 -8
  178. package/lib/compose/resolveShorthandProps.js +0 -30
  179. package/lib/compose/resolveShorthandProps.js.map +0 -1
  180. package/lib/hooks/useControllableValue.d.ts +0 -20
  181. package/lib/hooks/useControllableValue.js +0 -62
  182. package/lib/hooks/useControllableValue.js.map +0 -1
  183. package/lib/utils/onlyChild.d.ts +0 -5
  184. package/lib/utils/onlyChild.js +0 -13
  185. package/lib/utils/onlyChild.js.map +0 -1
  186. package/lib-commonjs/compose/getSlotsCompat.d.ts +0 -22
  187. package/lib-commonjs/compose/getSlotsCompat.js +0 -68
  188. package/lib-commonjs/compose/getSlotsCompat.js.map +0 -1
  189. package/lib-commonjs/compose/makeMergeProps.d.ts +0 -15
  190. package/lib-commonjs/compose/makeMergeProps.js +0 -117
  191. package/lib-commonjs/compose/makeMergeProps.js.map +0 -1
  192. package/lib-commonjs/compose/makeMergePropsCompat.d.ts +0 -9
  193. package/lib-commonjs/compose/makeMergePropsCompat.js +0 -17
  194. package/lib-commonjs/compose/makeMergePropsCompat.js.map +0 -1
  195. package/lib-commonjs/compose/nullRender.d.ts +0 -4
  196. package/lib-commonjs/compose/nullRender.js +0 -16
  197. package/lib-commonjs/compose/nullRender.js.map +0 -1
  198. package/lib-commonjs/compose/resolveShorthandProps.d.ts +0 -8
  199. package/lib-commonjs/compose/resolveShorthandProps.js +0 -41
  200. package/lib-commonjs/compose/resolveShorthandProps.js.map +0 -1
  201. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  202. package/lib-commonjs/hooks/useControllableValue.js +0 -73
  203. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
  204. package/lib-commonjs/utils/onlyChild.d.ts +0 -5
  205. package/lib-commonjs/utils/onlyChild.js +0 -23
  206. 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 | ((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;
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,65 @@ export declare const colGroupProperties: Record<string, number>;
77
71
 
78
72
  export declare const colProperties: Record<string, number>;
79
73
 
80
- export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
81
- [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
82
- }, Primary> & PropsWithoutRef<Shorthands[Primary]>;
83
-
84
- export declare type ComponentPropsCompat = {
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
- export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
91
- components?: {
92
- [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);
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
- } & Shorthands;
87
+ } & {
88
+ [Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
89
+ };
95
90
 
96
91
  /**
97
- * Converts a components Props type to a State type:
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
- * @template Props - The component's Props type
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 type ComponentStateCompat<Props, ShorthandPropNames extends keyof Props = never, DefaultedPropNames extends keyof ResolvedShorthandPropsCompat<Props, ShorthandPropNames> = never> = RequiredPropsCompat<ResolvedShorthandPropsCompat<Props, ShorthandPropNames>, DefaultedPropNames>;
96
+ export declare const defaultSSRContextValue: SSRContextValue;
106
97
 
107
98
  /**
108
- * Matches any shorthand props type.
99
+ * An array of DIV tag properties and events.
109
100
  *
110
- * This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
111
- * it shouldn't be used as the type of a slot.
101
+ * @public
112
102
  */
113
- export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
114
- children?: React_2.ReactNode;
115
- as?: keyof JSX.IntrinsicElements;
116
- }>;
103
+ export declare const divProperties: Record<string, number>;
117
104
 
118
105
  /**
119
- * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
106
+ * HTML element types that are not allowed to have children.
120
107
  *
121
- * @internal
108
+ * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
122
109
  */
123
- export declare const defaultSSRContextValue: SSRContextValue;
110
+ declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
124
111
 
125
112
  /**
126
- * Default value can be a value or an initializer
113
+ * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.
127
114
  */
128
- declare type DefaultValue<TValue> = TValue | (() => TValue);
115
+ export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
129
116
 
130
117
  /**
131
- * An array of DIV tag properties and events.
118
+ * Allows a component to be tagged as a FluentUI trigger component.
132
119
  *
133
- * @public
120
+ * Triggers are special-case components: they attach event listeners and other props on their child,
121
+ * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
122
+ *
123
+ * A component can be tagged as a trigger as follows:
124
+ * ```ts
125
+ * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
126
+ *
127
+ * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
128
+ * ```
134
129
  */
135
- export declare const divProperties: Record<string, number>;
130
+ export declare type FluentTriggerComponent = {
131
+ isFluentTriggerComponent?: boolean;
132
+ };
136
133
 
137
134
  /**
138
135
  * An array of FORM tag properties and events.
@@ -146,10 +143,6 @@ export declare const formProperties: Record<string, number>;
146
143
  */
147
144
  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
145
 
149
- declare type GenericDictionary = Record<string, any>;
150
-
151
- declare type GenericDictionary_2 = Record<string, any>;
152
-
153
146
  /**
154
147
  * Given an element tagname and user props, filters the props to only allowed props for the given
155
148
  * element type.
@@ -175,6 +168,29 @@ export declare function getNativeElementProps<TAttributes extends React_2.HTMLAt
175
168
  */
176
169
  export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
177
170
 
171
+ /**
172
+ * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
173
+ *
174
+ * This function is only for use with components that have a primary slot other than `root`.
175
+ * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
176
+ *
177
+ * @returns An object containing the native props for the `root` and primary slots.
178
+ */
179
+ export declare const getPartitionedNativeProps: <Props extends Pick<React_2.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
180
+ /** The primary slot's element type (e.g. 'div') */
181
+ primarySlotTagName: keyof JSX.IntrinsicElements;
182
+ /** The component's props object */
183
+ props: Props;
184
+ /** List of native props to exclude from the returned value */
185
+ excludedPropNames?: ExcludedPropKeys[] | undefined;
186
+ }) => {
187
+ root: {
188
+ style: React_2.CSSProperties | undefined;
189
+ className: string | undefined;
190
+ };
191
+ primary: Omit<Props, ExcludedPropKeys>;
192
+ };
193
+
178
194
  /**
179
195
  * Finds and swaps a provided key for it's right to left format.
180
196
  */
@@ -189,37 +205,39 @@ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
189
205
  * Slots will render as null if they are rendered as primitives with undefined children.
190
206
  *
191
207
  * The slotProps will always omit the `as` prop within them, and for slots that are string
192
- * primitives, the props will be filtered according the the slot type. For example, if the
193
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
208
+ * primitives, the props will be filtered according to the slot type by the type system.
209
+ * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
210
+ * anchor props. Note that this is only enforced at build time by Typescript -- there is no
211
+ * runtime code filtering props in this function.
194
212
  *
195
213
  * @param state - State including slot definitions
196
- * @param slotNames - Name of which props are slots
197
214
  * @returns An object containing the `slots` map and `slotProps` map.
198
215
  */
199
- export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
216
+ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
200
217
  slots: Slots<R>;
201
- slotProps: SlotProps<R>;
218
+ slotProps: ObjectSlotProps<R>;
202
219
  };
203
220
 
204
221
  /**
205
- * Given the state and an array of slot names, will break out `slots` and `slotProps`
206
- * collections.
222
+ * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
207
223
  *
208
- * The root is always derived from the `as` prop.
209
- *
210
- * Slots will render as null if they are rendered as primitives with undefined children.
224
+ * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
225
+ * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
226
+ * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
211
227
  *
212
- * The slotProps will always omit the `as` prop within them, and for slots that are string
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.
215
- *
216
- * @param state - State including slot definitions
217
- * @param slotNames - Name of which props are slots
218
- * @returns An object containing the `slots` map and `slotProps` map.
228
+ * For example, the following returns `<div id="child" />`:
229
+ * ```jsx
230
+ * getTriggerChild(
231
+ * <Tooltip>
232
+ * <MenuTrigger>
233
+ * <div id="child" />
234
+ * </MenuTrigger>
235
+ * </Tooltip>
236
+ * );
237
+ * ```
219
238
  */
220
- export declare const getSlotsCompat: (state: GenericDictionary, slotNames?: readonly string[] | undefined) => {
221
- slots: Record<string, any>;
222
- slotProps: Record<string, any>;
239
+ export declare const getTriggerChild: (children: React_2.ReactNode) => React_2.ReactElement & {
240
+ ref?: React_2.Ref<unknown>;
223
241
  };
224
242
 
225
243
  /**
@@ -256,25 +274,19 @@ export declare const imgProperties: Record<string, number>;
256
274
  export declare const inputProperties: Record<string, number>;
257
275
 
258
276
  /**
259
- * Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
260
- * For slots that support custom components, use {@link ObjectShorthandProps} instead.
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
- * ```
277
+ * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
278
+ * * Removes legacy string ref.
279
+ * * Disallows children for empty tags like 'img'.
270
280
  */
271
- 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' : ({
272
- as?: DefaultAs;
273
- } & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
274
- [As in AlternateAs]: {
275
- as: As;
276
- } & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[As]>>;
277
- }[AlternateAs];
281
+ declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React_2.PropsWithRef<JSX.IntrinsicElements[Type]> & (Type extends EmptyIntrisicElements ? {
282
+ children?: never;
283
+ } : {});
284
+
285
+ /**
286
+ * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
287
+ * See the {@link FluentTriggerComponent} type for more info.
288
+ */
289
+ export declare const isFluentTrigger: (element: React_2.ReactElement) => boolean | undefined;
278
290
 
279
291
  /**
280
292
  * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
@@ -302,52 +314,10 @@ export declare const labelProperties: Record<string, number>;
302
314
  */
303
315
  export declare const liProperties: Record<string, number>;
304
316
 
305
- /**
306
- * Helper which deep clones props, but respectively assigns JSX, object refs, and class names
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)[];
317
+ declare type ObjectSlotProps<S extends SlotPropsRecord> = {
318
+ [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;
327
319
  };
328
320
 
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>;
347
- };
348
-
349
- export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
350
-
351
321
  /**
352
322
  * This is part of a hack to infer the element type from a native element *props* type.
353
323
  * The only place the original element is found in a native props type (at least that's workable
@@ -384,16 +354,11 @@ export declare const olProperties: Record<string, number>;
384
354
  */
385
355
  export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
386
356
 
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
357
  export declare const optionProperties: Record<string, number>;
393
358
 
394
359
  /**
395
360
  * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
396
- * IntrinsicShorthandProps). This allows IntrinsicShorthandProps to be used with React.forwardRef.
361
+ * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
397
362
  *
398
363
  * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
399
364
  * types, to prevent unions from being expanded.
@@ -407,12 +372,9 @@ export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unkn
407
372
  export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) => void);
408
373
 
409
374
  /**
410
- * Helper type to mark the given props as required.
411
- * Similar to Required<T> except it only requires a subset of the props.
375
+ * If type T includes `null`, remove it and add `undefined` instead.
412
376
  */
413
- export declare type RequiredPropsCompat<T, K extends keyof T> = Omit<T, K> & {
414
- [P in K]-?: T[P];
415
- };
377
+ export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
416
378
 
417
379
  /**
418
380
  * Resets generated IDs, should be used only in tests.
@@ -422,33 +384,23 @@ export declare type RequiredPropsCompat<T, K extends keyof T> = Omit<T, K> & {
422
384
  export declare function resetIdsForTests(): void;
423
385
 
424
386
  /**
425
- * Helper type to convert the given props of type ShorthandProps into ObjectShorthandProps
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
387
+ * Resolves shorthands into slot props, to ensure normalization of the signature
433
388
  * being passed down to getSlots method
434
- * @param value - the base ShorthandProps
435
- * @param options - options to resolve ShorthandProps
389
+ * @param value - the base shorthand props
390
+ * @param options - options to resolve shorthand props
436
391
  */
437
- export declare function resolveShorthand<Props extends DefaultObjectShorthandProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
392
+ export declare const resolveShorthand: ResolveShorthandFunction;
393
+
394
+ export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
395
+ <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, true>): ReplaceNullWithUndefined<P>;
396
+ <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>): ReplaceNullWithUndefined<P> | undefined;
397
+ };
438
398
 
439
- export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
399
+ export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
440
400
  required?: Required;
441
401
  defaultProps?: Props;
442
402
  };
443
403
 
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
404
  /**
453
405
  * An array of SELECT tag properties and events.
454
406
  *
@@ -456,14 +408,6 @@ export declare const resolveShorthandProps: <TProps, TShorthandPropNames extends
456
408
  */
457
409
  export declare const selectProperties: Record<string, number>;
458
410
 
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
411
  /**
468
412
  * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
469
413
  *
@@ -471,20 +415,55 @@ export declare type ShorthandRenderFunctionCompat<TProps> = (Component: React_2.
471
415
  */
472
416
  export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React_2.KeyboardEvent): boolean;
473
417
 
474
- declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
475
- [K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends ObjectShorthandProps<infer P> ? P : never;
476
- };
418
+ /**
419
+ * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,
420
+ * or a component like `typeof Button`.
421
+ *
422
+ * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).
423
+ *
424
+ * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,
425
+ * wrap with `NonNullable` (see examples below).
426
+ *
427
+ * @example
428
+ * ```
429
+ * // Intrinsic element examples:
430
+ * Slot<'div'> // Slot is always div
431
+ * Slot<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
432
+ * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as="div" or as="pre"
433
+ * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)
434
+ *
435
+ * // Component examples:
436
+ * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props
437
+ * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
438
+ * ```
439
+ */
440
+ 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 ? {
441
+ as?: Type;
442
+ } & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
443
+ [As in AlternateAs]: {
444
+ as: As;
445
+ } & WithSlotRenderFunction<IntrisicElementProps<As>>;
446
+ }[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
477
447
 
478
- export declare type SlotPropsCompat<TSlots extends BaseSlotsCompat, TProps, TRootProps extends React_2.HTMLAttributes<HTMLElement>> = {
479
- [key in keyof Omit<TSlots, 'root'>]: key extends keyof TProps ? TProps[key] : any;
480
- } & {
481
- root: TRootProps;
482
- };
448
+ /**
449
+ * Matches any component's Slots type (such as ButtonSlots).
450
+ *
451
+ * This should ONLY be used in type templates as in `extends SlotPropsRecord`;
452
+ * it shouldn't be used as a component's Slots type.
453
+ */
454
+ export declare type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
455
+
456
+ export declare type SlotRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
483
457
 
484
- export declare type Slots<S extends ObjectShorthandPropsRecord> = {
485
- [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]>>;
458
+ export declare type Slots<S extends SlotPropsRecord> = {
459
+ [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
460
  };
487
461
 
462
+ /**
463
+ * The shorthand value of a slot allows specifying its child
464
+ */
465
+ export declare type SlotShorthandValue = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal;
466
+
488
467
  export declare const SSRContext: React_2.Context<SSRContextValue>;
489
468
 
490
469
  /**
@@ -545,6 +524,16 @@ export declare const trProperties: Record<string, number>;
545
524
  */
546
525
  export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
547
526
 
527
+ /**
528
+ * Matches any slot props type.
529
+ *
530
+ * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
531
+ * it shouldn't be used as the type of a slot.
532
+ */
533
+ export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
534
+ as?: keyof JSX.IntrinsicElements;
535
+ };
536
+
548
537
  /**
549
538
  * Hook to store a value and generate callbacks for setting the value to true or false.
550
539
  * The identity of the callbacks will always stay the same.
@@ -578,42 +567,37 @@ export declare type UseBooleanCallbacks = {
578
567
  export declare function useConst<T>(initialValue: T | (() => T)): T;
579
568
 
580
569
  /**
581
- * A useState 'like' hook that allows optional user control
582
- * Useful for components which allow uncontrolled and controlled behaviour for users
583
- * @returns - https://reactjs.org/docs/hooks-state.html
570
+ * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
571
+ * such as a checked state or text input string.
572
+ *
573
+ * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
574
+ * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
575
+ *
576
+ * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
577
+ * of the current value and an updater (dispatch) function. The updater function is referentially
578
+ * stable (won't change during the component's lifecycle). It can take either a new value, or a
579
+ * function which is passed the previous value and returns the new value. Unlike `setState`, calls
580
+ * to the updater function will only be respected if the component is uncontrolled.
581
+ * @see https://reactjs.org/docs/uncontrolled-components.html
584
582
  */
585
583
  export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
586
584
 
587
585
  export declare type UseControllableStateOptions<State> = {
588
586
  /**
589
- * User provided default state or factory initializer
587
+ * User-provided default state or initializer, for uncontrolled usage.
590
588
  */
591
589
  defaultState?: State | (() => State);
592
590
  /**
593
- * User provided controllable state, undefined state means internal state will be used
591
+ * User-provided controlled state. `undefined` means internal state will be used.
594
592
  */
595
593
  state: State | undefined;
596
594
  /**
597
- * Used to initialize state if all user provided states are undefined
595
+ * Used as the initial state if `state` and `defaultState` are both `undefined`.
596
+ * If `undefined` is the correct initial state, pass that here.
598
597
  */
599
598
  initialState: State;
600
599
  };
601
600
 
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
601
  /**
618
602
  * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
619
603
  *
@@ -672,6 +656,25 @@ export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
672
656
  */
673
657
  export declare function useIsSSR(): boolean;
674
658
 
659
+ /**
660
+ * Combine two event callbacks into a single callback function that calls each one in order.
661
+ *
662
+ * This is useful to add an event listener to an existing element without overwriting the current listener, if any.
663
+ *
664
+ * For example:
665
+ * ```ts
666
+ * state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
667
+ * // Handle onChange
668
+ * });
669
+ * ```
670
+ *
671
+ * @param callback1 - The first callback to be called
672
+ * @param callback2 - The second callback to be called
673
+ *
674
+ * @returns An event callback that calls the callbacks in order, and is stable between renders
675
+ */
676
+ export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
677
+
675
678
  /**
676
679
  * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
677
680
  * updates all provided refs
@@ -752,4 +755,21 @@ export declare const useUnmount: (callback: () => void) => void;
752
755
  */
753
756
  export declare const videoProperties: Record<string, number>;
754
757
 
758
+ /**
759
+ * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
760
+ * to be a render function that takes those props.
761
+ */
762
+ declare type WithSlotRenderFunction<Props extends {
763
+ children?: unknown;
764
+ }> = Props & {
765
+ children?: Props['children'] | SlotRenderFunction<Props>;
766
+ };
767
+
768
+ /**
769
+ * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.
770
+ */
771
+ declare type WithSlotShorthandValue<Props extends {
772
+ children?: unknown;
773
+ }> = Props | Extract<SlotShorthandValue, Props['children']>;
774
+
755
775
  export { }
@@ -1,10 +1,10 @@
1
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]>>;
2
+ import type { AsIntrinsicElement, ComponentState, ExtractSlotProps, SlotPropsRecord, UnionToIntersection } from './types';
3
+ export declare type Slots<S extends SlotPropsRecord> = {
4
+ [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? As : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<ExtractSlotProps<S[K]>>;
5
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;
6
+ declare type ObjectSlotProps<S extends SlotPropsRecord> = {
7
+ [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? P : never;
8
8
  };
9
9
  /**
10
10
  * Given the state and an array of slot names, will break out `slots` and `slotProps`
@@ -15,15 +15,16 @@ declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
15
15
  * Slots will render as null if they are rendered as primitives with undefined children.
16
16
  *
17
17
  * The slotProps will always omit the `as` prop within them, and for slots that are string
18
- * primitives, the props will be filtered according the the slot type. For example, if the
19
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
18
+ * primitives, the props will be filtered according to the slot type by the type system.
19
+ * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
20
+ * anchor props. Note that this is only enforced at build time by Typescript -- there is no
21
+ * runtime code filtering props in this function.
20
22
  *
21
23
  * @param state - State including slot definitions
22
- * @param slotNames - Name of which props are slots
23
24
  * @returns An object containing the `slots` map and `slotProps` map.
24
25
  */
25
- export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
26
+ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
26
27
  slots: Slots<R>;
27
- slotProps: SlotProps<R>;
28
+ slotProps: ObjectSlotProps<R>;
28
29
  };
29
30
  export {};