@fluentui/react-utilities 9.0.0-rc.8 → 9.0.1-0

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 (212) hide show
  1. package/CHANGELOG.json +114 -1
  2. package/CHANGELOG.md +47 -2
  3. package/dist/index.d.ts +31 -278
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/compose/getSlots.js.map +1 -1
  6. package/lib/compose/resolveShorthand.js.map +1 -1
  7. package/lib/compose/types.js.map +1 -1
  8. package/lib/hooks/index.js +0 -4
  9. package/lib/hooks/index.js.map +1 -1
  10. package/lib/hooks/useControllableState.js +3 -2
  11. package/lib/hooks/useControllableState.js.map +1 -1
  12. package/lib/hooks/useEventCallback.js +1 -0
  13. package/lib/hooks/useEventCallback.js.map +1 -1
  14. package/lib/hooks/useFirstMount.js +1 -0
  15. package/lib/hooks/useFirstMount.js.map +1 -1
  16. package/lib/hooks/useForceUpdate.js +1 -0
  17. package/lib/hooks/useForceUpdate.js.map +1 -1
  18. package/lib/hooks/useId.js +0 -2
  19. package/lib/hooks/useId.js.map +1 -1
  20. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -0
  21. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  22. package/lib/hooks/useMergedEventCallbacks.js +1 -0
  23. package/lib/hooks/useMergedEventCallbacks.js.map +1 -1
  24. package/lib/hooks/useMergedRefs.js +1 -0
  25. package/lib/hooks/useMergedRefs.js.map +1 -1
  26. package/lib/hooks/useOnClickOutside.js +2 -1
  27. package/lib/hooks/useOnClickOutside.js.map +1 -1
  28. package/lib/hooks/useOnScrollOutside.js +1 -0
  29. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  30. package/lib/hooks/usePrevious.js +4 -0
  31. package/lib/hooks/usePrevious.js.map +1 -1
  32. package/lib/hooks/useTimeout.js +2 -2
  33. package/lib/hooks/useTimeout.js.map +1 -1
  34. package/lib/index.js +4 -4
  35. package/lib/index.js.map +1 -1
  36. package/lib/ssr/SSRContext.js +1 -1
  37. package/lib/ssr/SSRContext.js.map +1 -1
  38. package/lib/ssr/canUseDOM.js.map +1 -1
  39. package/lib/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  40. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -0
  41. package/lib/{utils → trigger}/getTriggerChild.js +2 -0
  42. package/lib/trigger/getTriggerChild.js.map +1 -0
  43. package/lib/trigger/index.js +5 -0
  44. package/lib/trigger/index.js.map +1 -0
  45. package/lib/{utils → trigger}/isFluentTrigger.js +0 -0
  46. package/lib/trigger/isFluentTrigger.js.map +1 -0
  47. package/lib/trigger/types.js +2 -0
  48. package/lib/trigger/types.js.map +1 -0
  49. package/lib/utils/clamp.js +1 -0
  50. package/lib/utils/clamp.js.map +1 -1
  51. package/lib/utils/getNativeElementProps.js.map +1 -1
  52. package/lib/utils/getRTLSafeKey.js +1 -0
  53. package/lib/utils/getRTLSafeKey.js.map +1 -1
  54. package/lib/utils/getReactCallbackName.js.map +1 -1
  55. package/lib/utils/index.js +0 -3
  56. package/lib/utils/index.js.map +1 -1
  57. package/lib/utils/omit.js.map +1 -1
  58. package/lib/utils/properties.js +2 -6
  59. package/lib/utils/properties.js.map +1 -1
  60. package/lib/utils/shouldPreventDefaultOnKeyDown.js +1 -0
  61. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  62. package/lib-commonjs/compose/getSlots.js.map +1 -1
  63. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  64. package/lib-commonjs/hooks/index.js +0 -8
  65. package/lib-commonjs/hooks/index.js.map +1 -1
  66. package/lib-commonjs/hooks/useControllableState.js +3 -3
  67. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  68. package/lib-commonjs/hooks/useEventCallback.js +1 -0
  69. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  70. package/lib-commonjs/hooks/useFirstMount.js +1 -0
  71. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  72. package/lib-commonjs/hooks/useForceUpdate.js +1 -0
  73. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  74. package/lib-commonjs/hooks/useId.js +0 -2
  75. package/lib-commonjs/hooks/useId.js.map +1 -1
  76. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -0
  77. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  78. package/lib-commonjs/hooks/useMergedEventCallbacks.js +1 -0
  79. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -1
  80. package/lib-commonjs/hooks/useMergedRefs.js +1 -0
  81. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  82. package/lib-commonjs/hooks/useOnClickOutside.js +2 -1
  83. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  84. package/lib-commonjs/hooks/useOnScrollOutside.js +1 -0
  85. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  86. package/lib-commonjs/hooks/usePrevious.js +4 -0
  87. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  88. package/lib-commonjs/hooks/useTimeout.js +2 -3
  89. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  90. package/lib-commonjs/index.js +8 -223
  91. package/lib-commonjs/index.js.map +1 -1
  92. package/lib-commonjs/ssr/SSRContext.js +1 -1
  93. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  94. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  95. package/lib-commonjs/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  96. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -0
  97. package/lib-commonjs/{utils → trigger}/getTriggerChild.js +2 -0
  98. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -0
  99. package/lib-commonjs/trigger/index.js +16 -0
  100. package/lib-commonjs/trigger/index.js.map +1 -0
  101. package/lib-commonjs/{utils → trigger}/isFluentTrigger.js +0 -0
  102. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -0
  103. package/lib-commonjs/trigger/types.js +6 -0
  104. package/lib-commonjs/trigger/types.js.map +1 -0
  105. package/lib-commonjs/utils/clamp.js +1 -0
  106. package/lib-commonjs/utils/clamp.js.map +1 -1
  107. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  108. package/lib-commonjs/utils/getRTLSafeKey.js +1 -0
  109. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  110. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  111. package/lib-commonjs/utils/index.js +0 -6
  112. package/lib-commonjs/utils/index.js.map +1 -1
  113. package/lib-commonjs/utils/omit.js.map +1 -1
  114. package/lib-commonjs/utils/properties.js +3 -7
  115. package/lib-commonjs/utils/properties.js.map +1 -1
  116. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +1 -0
  117. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  118. package/package.json +4 -7
  119. package/lib/compose/getSlots.d.ts +0 -30
  120. package/lib/compose/index.d.ts +0 -3
  121. package/lib/compose/resolveShorthand.d.ts +0 -16
  122. package/lib/compose/types.d.ts +0 -161
  123. package/lib/hooks/index.d.ts +0 -16
  124. package/lib/hooks/useBoolean.d.ts +0 -17
  125. package/lib/hooks/useBoolean.js +0 -28
  126. package/lib/hooks/useBoolean.js.map +0 -1
  127. package/lib/hooks/useConst.d.ts +0 -12
  128. package/lib/hooks/useConst.js +0 -30
  129. package/lib/hooks/useConst.js.map +0 -1
  130. package/lib/hooks/useControllableState.d.ts +0 -31
  131. package/lib/hooks/useEventCallback.d.ts +0 -13
  132. package/lib/hooks/useFirstMount.d.ts +0 -11
  133. package/lib/hooks/useForceUpdate.d.ts +0 -4
  134. package/lib/hooks/useId.d.ts +0 -15
  135. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  136. package/lib/hooks/useMergedEventCallbacks.d.ts +0 -18
  137. package/lib/hooks/useMergedRefs.d.ts +0 -13
  138. package/lib/hooks/useMount.d.ts +0 -6
  139. package/lib/hooks/useMount.js +0 -17
  140. package/lib/hooks/useMount.js.map +0 -1
  141. package/lib/hooks/useOnClickOutside.d.ts +0 -29
  142. package/lib/hooks/useOnScrollOutside.d.ts +0 -5
  143. package/lib/hooks/usePrevious.d.ts +0 -1
  144. package/lib/hooks/useTimeout.d.ts +0 -8
  145. package/lib/hooks/useUnmount.d.ts +0 -6
  146. package/lib/hooks/useUnmount.js +0 -17
  147. package/lib/hooks/useUnmount.js.map +0 -1
  148. package/lib/index.d.ts +0 -8
  149. package/lib/ssr/SSRContext.d.ts +0 -33
  150. package/lib/ssr/canUseDOM.d.ts +0 -4
  151. package/lib/ssr/index.d.ts +0 -2
  152. package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
  153. package/lib/utils/applyTriggerPropsToChildren.js.map +0 -1
  154. package/lib/utils/clamp.d.ts +0 -8
  155. package/lib/utils/getNativeElementProps.d.ts +0 -31
  156. package/lib/utils/getRTLSafeKey.d.ts +0 -4
  157. package/lib/utils/getReactCallbackName.d.ts +0 -25
  158. package/lib/utils/getTriggerChild.d.ts +0 -22
  159. package/lib/utils/getTriggerChild.js.map +0 -1
  160. package/lib/utils/index.d.ts +0 -9
  161. package/lib/utils/isFluentTrigger.d.ts +0 -22
  162. package/lib/utils/isFluentTrigger.js.map +0 -1
  163. package/lib/utils/omit.d.ts +0 -14
  164. package/lib/utils/properties.d.ts +0 -160
  165. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
  166. package/lib-commonjs/compose/getSlots.d.ts +0 -30
  167. package/lib-commonjs/compose/index.d.ts +0 -3
  168. package/lib-commonjs/compose/resolveShorthand.d.ts +0 -16
  169. package/lib-commonjs/compose/types.d.ts +0 -161
  170. package/lib-commonjs/hooks/index.d.ts +0 -16
  171. package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
  172. package/lib-commonjs/hooks/useBoolean.js +0 -39
  173. package/lib-commonjs/hooks/useBoolean.js.map +0 -1
  174. package/lib-commonjs/hooks/useConst.d.ts +0 -12
  175. package/lib-commonjs/hooks/useConst.js +0 -40
  176. package/lib-commonjs/hooks/useConst.js.map +0 -1
  177. package/lib-commonjs/hooks/useControllableState.d.ts +0 -31
  178. package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
  179. package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
  180. package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
  181. package/lib-commonjs/hooks/useId.d.ts +0 -15
  182. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  183. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +0 -18
  184. package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
  185. package/lib-commonjs/hooks/useMount.d.ts +0 -6
  186. package/lib-commonjs/hooks/useMount.js +0 -27
  187. package/lib-commonjs/hooks/useMount.js.map +0 -1
  188. package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
  189. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
  190. package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
  191. package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
  192. package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
  193. package/lib-commonjs/hooks/useUnmount.js +0 -27
  194. package/lib-commonjs/hooks/useUnmount.js.map +0 -1
  195. package/lib-commonjs/index.d.ts +0 -8
  196. package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
  197. package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
  198. package/lib-commonjs/ssr/index.d.ts +0 -2
  199. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
  200. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +0 -1
  201. package/lib-commonjs/utils/clamp.d.ts +0 -8
  202. package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -31
  203. package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
  204. package/lib-commonjs/utils/getReactCallbackName.d.ts +0 -25
  205. package/lib-commonjs/utils/getTriggerChild.d.ts +0 -22
  206. package/lib-commonjs/utils/getTriggerChild.js.map +0 -1
  207. package/lib-commonjs/utils/index.d.ts +0 -9
  208. package/lib-commonjs/utils/isFluentTrigger.d.ts +0 -22
  209. package/lib-commonjs/utils/isFluentTrigger.js.map +0 -1
  210. package/lib-commonjs/utils/omit.d.ts +0 -14
  211. package/lib-commonjs/utils/properties.d.ts +0 -160
  212. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
package/dist/index.d.ts CHANGED
@@ -2,13 +2,7 @@ import { DispatchWithoutAction } from 'react';
2
2
  import * as React_2 from 'react';
3
3
 
4
4
  /**
5
- * An array of A tag properties and events.
6
- *
7
- * @public
8
- */
9
- export declare const anchorProperties: Record<string, number>;
10
-
11
- /**
5
+ * @internal
12
6
  * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
13
7
  */
14
8
  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;
@@ -21,44 +15,17 @@ export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: Reac
21
15
  * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
22
16
  * ```
23
17
  */
24
- export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
18
+ declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
25
19
  as?: As;
26
20
  };
27
21
 
28
- /**
29
- * An array of AUDIO tag properties and events.
30
-
31
- * @public
32
- */
33
- export declare const audioProperties: Record<string, number>;
34
-
35
- /**
36
- * An array of events that are allowed on every html element type.
37
- *
38
- * @public
39
- */
40
- export declare const baseElementEvents: Record<string, number>;
41
-
42
- /**
43
- * An array of element attributes which are allowed on every html element type.
44
- *
45
- * @public
46
- */
47
- export declare const baseElementProperties: Record<string, number>;
48
-
49
- /**
50
- * An array of BUTTON tag properties and events.
51
- *
52
- * @public
53
- */
54
- export declare const buttonProperties: Record<string, number>;
55
-
56
22
  /**
57
23
  * Verifies if an application can use DOM.
58
24
  */
59
25
  export declare function canUseDOM(): boolean;
60
26
 
61
27
  /**
28
+ * @internal
62
29
  * Clamps `value` to a number between the min and max.
63
30
  *
64
31
  * @param value - the value to be clamped
@@ -67,10 +34,6 @@ export declare function canUseDOM(): boolean;
67
34
  */
68
35
  export declare const clamp: (value: number, min: number, max: number) => number;
69
36
 
70
- export declare const colGroupProperties: Record<string, number>;
71
-
72
- export declare const colProperties: Record<string, number>;
73
-
74
37
  /**
75
38
  * Defines the Props type for a component given its slots and the definition of which one is the primary slot,
76
39
  * defaulting to root if one is not provided.
@@ -88,20 +51,6 @@ export declare type ComponentState<Slots extends SlotPropsRecord> = {
88
51
  [Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
89
52
  };
90
53
 
91
- /**
92
- * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
93
- *
94
- * @internal
95
- */
96
- export declare const defaultSSRContextValue: SSRContextValue;
97
-
98
- /**
99
- * An array of DIV tag properties and events.
100
- *
101
- * @public
102
- */
103
- export declare const divProperties: Record<string, number>;
104
-
105
54
  /**
106
55
  * HTML element types that are not allowed to have children.
107
56
  *
@@ -115,13 +64,7 @@ declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' |
115
64
  export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
116
65
 
117
66
  /**
118
- * An array of FIELDSET tag properties and events.
119
- *
120
- * @public
121
- */
122
- export declare const fieldsetProperties: Record<string, number>;
123
-
124
- /**
67
+ * @internal
125
68
  * Allows a component to be tagged as a FluentUI trigger component.
126
69
  *
127
70
  * Triggers are special-case components: they attach event listeners and other props on their child,
@@ -138,13 +81,6 @@ export declare type FluentTriggerComponent = {
138
81
  isFluentTriggerComponent?: boolean;
139
82
  };
140
83
 
141
- /**
142
- * An array of FORM tag properties and events.
143
- *
144
- * @public
145
- */
146
- export declare const formProperties: Record<string, number>;
147
-
148
84
  /**
149
85
  * Return type for `React.forwardRef`, including inference of the proper typing for the ref.
150
86
  */
@@ -159,22 +95,6 @@ export declare type ForwardRefComponent<Props> = ObscureEventName extends keyof
159
95
  */
160
96
  export declare function getNativeElementProps<TAttributes extends React_2.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
161
97
 
162
- /**
163
- * Gets native supported props for an html element provided the allowance set. Use one of the property
164
- * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
165
- * props set. Note that all data- and aria- prefixed attributes will be allowed.
166
- * NOTE: getNativeProps should always be applied first when adding props to a react component. The
167
- * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
168
- * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
169
- * the component after an onClick function is added, then the getNativeProps onClick will override it.
170
- *
171
- * @public
172
- * @param props - The unfiltered input props
173
- * @param allowedPropsNames - The array or record of allowed prop names.
174
- * @returns The filtered props
175
- */
176
- export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
177
-
178
98
  /**
179
99
  * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
180
100
  *
@@ -199,6 +119,7 @@ export declare const getPartitionedNativeProps: <Props extends Pick<React_2.HTML
199
119
  };
200
120
 
201
121
  /**
122
+ * @internal
202
123
  * Finds and swaps a provided key for it's right to left format.
203
124
  */
204
125
  export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
@@ -226,6 +147,7 @@ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentStat
226
147
  };
227
148
 
228
149
  /**
150
+ * @internal
229
151
  * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
230
152
  *
231
153
  * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
@@ -243,43 +165,10 @@ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentStat
243
165
  * );
244
166
  * ```
245
167
  */
246
- export declare const getTriggerChild: (children: React_2.ReactNode) => React_2.ReactElement & {
247
- ref?: React_2.Ref<unknown>;
168
+ export declare const getTriggerChild: <P = any>(children: React_2.ReactNode) => React_2.ReactElement<P, string | React_2.JSXElementConstructor<any>> & {
169
+ ref?: React_2.Ref<unknown> | undefined;
248
170
  };
249
171
 
250
- /**
251
- * An array of HTML element properties and events.
252
- *
253
- * @public
254
- */
255
- export declare const htmlElementProperties: Record<string, number>;
256
-
257
- /**
258
- * An array of IFRAME tag properties and events.
259
- *
260
- * @public
261
- */
262
- export declare const iframeProperties: Record<string, number>;
263
-
264
- /**
265
- * @deprecated Use imgProperties for img elements.
266
- */
267
- export declare const imageProperties: Record<string, number>;
268
-
269
- /**
270
- * An array of IMAGE tag properties and events.
271
- *
272
- * @public
273
- */
274
- export declare const imgProperties: Record<string, number>;
275
-
276
- /**
277
- * An array of INPUT tag properties and events.
278
- *
279
- * @public
280
- */
281
- export declare const inputProperties: Record<string, number>;
282
-
283
172
  /**
284
173
  * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
285
174
  * * Removes legacy string ref.
@@ -289,12 +178,6 @@ declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = Re
289
178
  children?: never;
290
179
  } : {});
291
180
 
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;
297
-
298
181
  /**
299
182
  * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
300
183
  *
@@ -303,24 +186,10 @@ export declare const isFluentTrigger: (element: React_2.ReactElement) => boolean
303
186
  * IsSingleton<'a' | 'b' | 'c'> // false
304
187
  * ```
305
188
  */
306
- export declare type IsSingleton<T extends string> = {
189
+ declare type IsSingleton<T extends string> = {
307
190
  [K in T]: Exclude<T, K> extends never ? true : false;
308
191
  }[T];
309
192
 
310
- /**
311
- * An array of LABEL tag properties and events.
312
- *
313
- * @public
314
- */
315
- export declare const labelProperties: Record<string, number>;
316
-
317
- /**
318
- * An array of LI tag properties and events.
319
- *
320
- * @public
321
- */
322
- export declare const liProperties: Record<string, number>;
323
-
324
193
  declare type ObjectSlotProps<S extends SlotPropsRecord> = {
325
194
  [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;
326
195
  };
@@ -339,30 +208,6 @@ declare type ObjectSlotProps<S extends SlotPropsRecord> = {
339
208
  */
340
209
  declare type ObscureEventName = 'onLostPointerCaptureCapture';
341
210
 
342
- /**
343
- * An array of OL tag properties and events.
344
- *
345
- * @public
346
- */
347
- export declare const olProperties: Record<string, number>;
348
-
349
- /**
350
- * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
351
- * props. This ends up faster than using object ...rest or reduce to filter.
352
- *
353
- * This behaves very much like filteredAssign, but does not merge many objects together,
354
- * uses an exclusion object map, and avoids spreads all for optimal performance.
355
- *
356
- * See perf test for background:
357
- * https://jsperf.com/omit-vs-rest-vs-reduce/1
358
- *
359
- * @param obj - The object to clone
360
- * @param exclusions - The array of keys to exclude
361
- */
362
- export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
363
-
364
- export declare const optionProperties: Record<string, number>;
365
-
366
211
  /**
367
212
  * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
368
213
  * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
@@ -370,9 +215,10 @@ export declare const optionProperties: Record<string, number>;
370
215
  * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
371
216
  * types, to prevent unions from being expanded.
372
217
  */
373
- export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
218
+ declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
374
219
 
375
220
  /**
221
+ * @internal
376
222
  * A Ref function which can be treated like a ref object in that it has an attached
377
223
  * current property, which will be updated as the ref is evaluated.
378
224
  */
@@ -381,12 +227,10 @@ export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) =>
381
227
  /**
382
228
  * If type T includes `null`, remove it and add `undefined` instead.
383
229
  */
384
- export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
230
+ declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
385
231
 
386
232
  /**
387
233
  * Resets generated IDs, should be used only in tests.
388
- *
389
- * @private
390
234
  */
391
235
  export declare function resetIdsForTests(): void;
392
236
 
@@ -409,13 +253,7 @@ export declare type ResolveShorthandOptions<Props, Required extends boolean = fa
409
253
  };
410
254
 
411
255
  /**
412
- * An array of SELECT tag properties and events.
413
- *
414
- * @public
415
- */
416
- export declare const selectProperties: Record<string, number>;
417
-
418
- /**
256
+ * @internal
419
257
  * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
420
258
  *
421
259
  * Useful for situations where a keydown needs to be transformed to a click event
@@ -444,7 +282,7 @@ export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React_2
444
282
  * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
445
283
  * ```
446
284
  */
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 ? {
285
+ export declare type Slot<Type extends keyof JSX.IntrinsicElements | React_2.ComponentType | React_2.VoidFunctionComponent | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
448
286
  as?: Type;
449
287
  } & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
450
288
  [As in AlternateAs]: {
@@ -478,18 +316,6 @@ export declare type Slots<S extends SlotPropsRecord> = {
478
316
  */
479
317
  export declare type SlotShorthandValue = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal;
480
318
 
481
- export declare const SSRContext: React_2.Context<SSRContextValue>;
482
-
483
- /**
484
- * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request
485
- * to ensure the client and server are consistent.
486
- *
487
- * @internal
488
- */
489
- export declare type SSRContextValue = {
490
- current: number;
491
- };
492
-
493
319
  /**
494
320
  * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
495
321
  * are consistent between the client and server.
@@ -498,45 +324,10 @@ export declare type SSRContextValue = {
498
324
  */
499
325
  export declare const SSRProvider: React_2.FC;
500
326
 
501
- /**
502
- * An array of TABLE tag properties and events.
503
- *
504
- * @public
505
- */
506
- export declare const tableProperties: Record<string, number>;
507
-
508
- /**
509
- * An array of TD tag properties and events.
510
- *
511
- * @public
512
- */
513
- export declare const tdProperties: Record<string, number>;
514
-
515
- /**
516
- * An array of TEXTAREA tag properties and events.
517
- *
518
- * @public
519
- */
520
- export declare const textAreaProperties: Record<string, number>;
521
-
522
- /**
523
- * An array of TH tag properties and events.
524
- *
525
- * @public
526
- */
527
- export declare const thProperties: Record<string, number>;
528
-
529
- /**
530
- * An array of TR tag properties and events.
531
- *
532
- * @public
533
- */
534
- export declare const trProperties: Record<string, number>;
535
-
536
327
  /**
537
328
  * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)
538
329
  */
539
- export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
330
+ declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
540
331
 
541
332
  /**
542
333
  * Matches any slot props type.
@@ -544,43 +335,13 @@ export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U :
544
335
  * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
545
336
  * it shouldn't be used as the type of a slot.
546
337
  */
547
- export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
338
+ declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
548
339
  as?: keyof JSX.IntrinsicElements;
549
340
  };
550
341
 
551
342
  /**
552
- * Hook to store a value and generate callbacks for setting the value to true or false.
553
- * The identity of the callbacks will always stay the same.
554
- *
555
- * @param initialState - Initial value
556
- * @returns Array with the current value and an object containing the updater callbacks.
557
- */
558
- export declare function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks];
559
-
560
- /** Updater callbacks returned by `useBoolean`. */
561
- export declare type UseBooleanCallbacks = {
562
- /** Set the value to true. Always has the same identity. */
563
- setTrue: () => void;
564
- /** Set the value to false. Always has the same identity. */
565
- setFalse: () => void;
566
- /** Toggle the value. Always has the same identity. */
567
- toggle: () => void;
568
- };
569
-
570
- /**
571
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
572
- * always return the same value (and if the initializer is a function, only call it once).
573
- * This is similar to setting a private member in a class constructor.
574
- *
575
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
343
+ * @internal
576
344
  *
577
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
578
- * only the value/function passed in the first time this is called is respected.
579
- * @returns The value. The identity of this value will always be the same.
580
- */
581
- export declare function useConst<T>(initialValue: T | (() => T)): T;
582
-
583
- /**
584
345
  * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
585
346
  * such as a checked state or text input string.
586
347
  *
@@ -596,6 +357,9 @@ export declare function useConst<T>(initialValue: T | (() => T)): T;
596
357
  */
597
358
  export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
598
359
 
360
+ /**
361
+ * @internal
362
+ */
599
363
  export declare type UseControllableStateOptions<State> = {
600
364
  /**
601
365
  * User-provided default state or initializer, for uncontrolled usage.
@@ -613,6 +377,7 @@ export declare type UseControllableStateOptions<State> = {
613
377
  };
614
378
 
615
379
  /**
380
+ * @internal
616
381
  * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
617
382
  *
618
383
  * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
@@ -627,6 +392,7 @@ export declare type UseControllableStateOptions<State> = {
627
392
  export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return;
628
393
 
629
394
  /**
395
+ * @internal
630
396
  * Checks if components was mounted the first time.
631
397
  * Since concurrent mode will be released in the future this needs to be verified
632
398
  * Currently (React 17) will always render the initial mount once
@@ -639,6 +405,7 @@ export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...
639
405
  export declare function useFirstMount(): boolean;
640
406
 
641
407
  /**
408
+ * @internal
642
409
  * Forces a re-render, similar to `forceUpdate` in class components.
643
410
  */
644
411
  export declare function useForceUpdate(): DispatchWithoutAction;
@@ -654,6 +421,7 @@ export declare function useForceUpdate(): DispatchWithoutAction;
654
421
  export declare function useId(prefix?: string, providedId?: string): string;
655
422
 
656
423
  /**
424
+ * @internal
657
425
  * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
658
426
  * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
659
427
  * ensure we don't get a render flash for certain operations, but we may also need affected components to render on
@@ -671,6 +439,7 @@ export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
671
439
  export declare function useIsSSR(): boolean;
672
440
 
673
441
  /**
442
+ * @internal
674
443
  * Combine two event callbacks into a single callback function that calls each one in order.
675
444
  *
676
445
  * This is useful to add an event listener to an existing element without overwriting the current listener, if any.
@@ -690,6 +459,7 @@ export declare function useIsSSR(): boolean;
690
459
  export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
691
460
 
692
461
  /**
462
+ * @internal
693
463
  * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
694
464
  * updates all provided refs
695
465
  * @param refs - Refs to collectively update with one ref value.
@@ -698,12 +468,8 @@ export declare function useMergedEventCallbacks<Args extends unknown[]>(callback
698
468
  export declare function useMergedRefs<T>(...refs: (React_2.Ref<T> | undefined)[]): RefObjectFunction<T>;
699
469
 
700
470
  /**
701
- * Hook which asynchronously executes a callback once the component has been mounted.
702
- *
703
- * @param callback - Function to call before mount.
471
+ * @internal
704
472
  */
705
- export declare const useMount: (callback: () => void) => void;
706
-
707
473
  export declare type UseOnClickOrScrollOutsideOptions = {
708
474
  /**
709
475
  * The element to listen for the click event
@@ -730,23 +496,24 @@ export declare type UseOnClickOrScrollOutsideOptions = {
730
496
  };
731
497
 
732
498
  /**
499
+ * @internal
733
500
  * Utility to perform checks where a click/touch event was made outside a component
734
501
  */
735
502
  export declare const useOnClickOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
736
503
 
737
504
  /**
505
+ * @internal
738
506
  * Utility to perform checks where a click/touch event was made outside a component
739
507
  */
740
508
  export declare const useOnScrollOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
741
509
 
742
- export declare const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
743
-
744
510
  /**
745
511
  * @internal
746
512
  */
747
- export declare function useSSRContext(): SSRContextValue;
513
+ export declare const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
748
514
 
749
515
  /**
516
+ * @internal
750
517
  * Helper to manage a browser timeout.
751
518
  * Ensures that the timeout isn't set multiple times at once,
752
519
  * and is cleaned up when the component is unloaded.
@@ -755,20 +522,6 @@ export declare function useSSRContext(): SSRContextValue;
755
522
  */
756
523
  export declare function useTimeout(): readonly [(fn: () => void, delay: number) => void, () => void];
757
524
 
758
- /**
759
- * Hook which synchronously executes a callback when the component is about to unmount.
760
- *
761
- * @param callback - Function to call during unmount.
762
- */
763
- export declare const useUnmount: (callback: () => void) => void;
764
-
765
- /**
766
- * An array of VIDEO tag properties and events.
767
- *
768
- * @public
769
- */
770
- export declare const videoProperties: Record<string, number>;
771
-
772
525
  /**
773
526
  * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
774
527
  * to be a render function that takes those props.
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":["compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,IAAT,QAAqB,eAArB;AA6BA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EACoB;AAKxB,QAAM,KAAK,GAAG,EAAd;AACA,QAAM,SAAS,GAAG,EAAlB;AAEA,QAAM,SAAS,GAAgB,MAAM,CAAC,IAAP,CAAY,KAAK,CAAC,UAAlB,CAA/B;;AACA,OAAK,MAAM,QAAX,IAAuB,SAAvB,EAAkC;AAChC,UAAM,CAAC,IAAD,EAAO,KAAP,IAAgB,OAAO,CAAC,KAAD,EAAQ,QAAR,CAA7B;AACA,IAAA,KAAK,CAAC,QAAD,CAAL,GAAkB,IAAlB;AACA,IAAA,SAAS,CAAC,QAAD,CAAT,GAAsB,KAAtB;AACD;;AACD,SAAO;AAAE,IAAA,KAAF;AAAS,IAAA,SAAS,EAAG;AAArB,GAAP;AACD;;AAED,SAAS,OAAT,CACE,KADF,EAEE,QAFF,EAEa;;;AAEX,MAAI,KAAK,CAAC,QAAD,CAAL,KAAoB,SAAxB,EAAmC;AACjC,WAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD;;AACD,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,EAAE,EAAE,MAAhB;AAAwB,OAAG;AAA3B,MAAoC,KAAK,CAAC,QAAD,CAA/C;AAEA,QAAM,IAAI,GAAI,CAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAAhB,MAAiC,SAAjC,IAA8C,OAAO,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAAP,KAAsC,QAApF,GACV,MAAM,KAAI,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAApB,CAAN,IAA0C,KADhC,GAEV,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAFJ;;AAIA,MAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;AAClC,UAAM,MAAM,GAAG,QAAf;AACA,WAAO,CACL,KAAK,CAAC,QADD,EAEJ;AACC,MAAA,QAAQ,EAAE,MAAM,CAAC,IAAD,EAAO,IAAP;AADjB,KAFI,CAAP;AAMD;;AAED,QAAM,gBAAgB,GAAG,OAAO,IAAP,KAAgB,QAAhB,KAA4B,CAAA,EAAA,GAAA,KAAK,CAAC,QAAD,CAAL,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAe,EAAA,CAAE,EAA7C,CAAzB;AACA,QAAM,SAAS,GAAI,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAD,CAAN,EAAmB,CAAC,IAAD,CAAnB,CAAP,GAAoC,KAAK,CAAC,QAAD,CAA5E;AAEA,SAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: (slotProps as unknown) as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,IAAT,QAAqB,eAArB;AA6BA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EACoB;EAKxB,MAAM,KAAK,GAAG,EAAd;EACA,MAAM,SAAS,GAAG,EAAlB;EAEA,MAAM,SAAS,GAAgB,MAAM,CAAC,IAAP,CAAY,KAAK,CAAC,UAAlB,CAA/B;;EACA,KAAK,MAAM,QAAX,IAAuB,SAAvB,EAAkC;IAChC,MAAM,CAAC,IAAD,EAAO,KAAP,IAAgB,OAAO,CAAC,KAAD,EAAQ,QAAR,CAA7B;IACA,KAAK,CAAC,QAAD,CAAL,GAAkB,IAAlB;IACA,SAAS,CAAC,QAAD,CAAT,GAAsB,KAAtB;EACD;;EACD,OAAO;IAAE,KAAF;IAAS,SAAS,EAAG;EAArB,CAAP;AACD;;AAED,SAAS,OAAT,CACE,KADF,EAEE,QAFF,EAEa;;;EAEX,IAAI,KAAK,CAAC,QAAD,CAAL,KAAoB,SAAxB,EAAmC;IACjC,OAAO,CAAC,IAAD,EAAO,SAAP,CAAP;EACD;;EACD,MAAM;IAAE,QAAF;IAAY,EAAE,EAAE,MAAhB;IAAwB,GAAG;EAA3B,IAAoC,KAAK,CAAC,QAAD,CAA/C;EAEA,MAAM,IAAI,GAAI,CAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAAhB,MAAiC,SAAjC,IAA8C,OAAO,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAAP,KAAsC,QAApF,GACV,MAAM,KAAI,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAApB,CAAN,IAA0C,KADhC,GAEV,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAFJ;;EAIA,IAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;IAClC,MAAM,MAAM,GAAG,QAAf;IACA,OAAO,CACL,KAAK,CAAC,QADD,EAEJ;MACC,QAAQ,EAAE,MAAM,CAAC,IAAD,EAAO,IAAP;IADjB,CAFI,CAAP;EAMD;;EAED,MAAM,gBAAgB,GAAG,OAAO,IAAP,KAAgB,QAAhB,KAA4B,CAAA,EAAA,GAAA,KAAK,CAAC,QAAD,CAAL,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAe,EAAA,CAAE,EAA7C,CAAzB;EACA,MAAM,SAAS,GAAI,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAD,CAAN,EAAmB,CAAC,IAAD,CAAnB,CAAP,GAAoC,KAAK,CAAC,QAAD,CAA5E;EAEA,OAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: (slotProps as unknown) as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["compose/resolveShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,OAA/B;AAkBA;;;;;AAKG;;AACH,OAAO,MAAM,gBAAgB,GAA6B,CAAC,KAAD,EAAQ,OAAR,KAAmB;AAC3E,QAAM;AAAE,IAAA,QAAQ,GAAG,KAAb;AAAoB,IAAA;AAApB,MAAqC,OAAO,IAAI,EAAtD;;AACA,MAAI,KAAK,KAAK,IAAV,IAAmB,KAAK,KAAK,SAAV,IAAuB,CAAC,QAA/C,EAA0D;AACxD,WAAO,SAAP;AACD;;AAED,MAAI,iBAAiB,GAAG,EAAxB;;AAEA,MAAI,OAAO,KAAP,KAAiB,QAAjB,IAA6B,OAAO,KAAP,KAAiB,QAA9C,IAA0D,KAAK,CAAC,OAAN,CAAc,KAAd,CAA1D,iBAAkF,cAAc,CAAC,KAAD,CAApG,EAA6G;AAC3G,IAAA,iBAAiB,CAAC,QAAlB,GAA6B,KAA7B;AACD,GAFD,MAEO,IAAI,OAAO,KAAP,KAAiB,QAArB,EAA+B;AACpC,IAAA,iBAAiB,GAAG,KAApB;AACD;;AAED,SAAO,YAAY,GAAG,EAAE,GAAG,YAAL;AAAmB,OAAG;AAAtB,GAAH,GAA+C,iBAAlE;AACD,CAfM","sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["compose/resolveShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,OAA/B;AAkBA;;;;;AAKG;;AACH,OAAO,MAAM,gBAAgB,GAA6B,CAAC,KAAD,EAAQ,OAAR,KAAmB;EAC3E,MAAM;IAAE,QAAQ,GAAG,KAAb;IAAoB;EAApB,IAAqC,OAAO,IAAI,EAAtD;;EACA,IAAI,KAAK,KAAK,IAAV,IAAmB,KAAK,KAAK,SAAV,IAAuB,CAAC,QAA/C,EAA0D;IACxD,OAAO,SAAP;EACD;;EAED,IAAI,iBAAiB,GAAG,EAAxB;;EAEA,IAAI,OAAO,KAAP,KAAiB,QAAjB,IAA6B,OAAO,KAAP,KAAiB,QAA9C,IAA0D,KAAK,CAAC,OAAN,CAAc,KAAd,CAA1D,iBAAkF,cAAc,CAAC,KAAD,CAApG,EAA6G;IAC3G,iBAAiB,CAAC,QAAlB,GAA6B,KAA7B;EACD,CAFD,MAEO,IAAI,OAAO,KAAP,KAAiB,QAArB,EAA+B;IACpC,iBAAiB,GAAG,KAApB;EACD;;EAED,OAAO,YAAY,GAAG,EAAE,GAAG,YAAL;IAAmB,GAAG;EAAtB,CAAH,GAA+C,iBAAlE;AACD,CAfM","sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\n};\n\n/**\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["compose/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactChild | React.ReactNodeArray | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props extends { children?: unknown }> = Props & {\n children?: Props['children'] | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrisicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React.PropsWithRef<JSX.IntrinsicElements[Type]> &\n (Type extends EmptyIntrisicElements ? { children?: never } : {});\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrisicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrisicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["compose/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactChild | React.ReactNodeArray | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n */\ntype WithSlotRenderFunction<Props extends { children?: unknown }> = Props & {\n children?: Props['children'] | SlotRenderFunction<Props>;\n};\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrisicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React.PropsWithRef<JSX.IntrinsicElements[Type]> &\n (Type extends EmptyIntrisicElements ? { children?: never } : {});\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrisicElementProps<Type>>\n : Type extends React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrisicElementProps<As>>;\n }[AlternateAs]\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n// Note: the `Omit<Slots, Primary & 'root'>` above is a little tricky. Here's what it's doing:\n// * If the Primary slot is 'root', then omit the `root` slot prop.\n// * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n// We need both props to allow the user to specify native props for either slot because the `root` slot is\n// special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n"]}
@@ -1,5 +1,3 @@
1
- export * from './useBoolean';
2
- export * from './useConst';
3
1
  export * from './useControllableState';
4
2
  export * from './useEventCallback';
5
3
  export * from './useFirstMount';
@@ -8,10 +6,8 @@ export * from './useId';
8
6
  export * from './useIsomorphicLayoutEffect';
9
7
  export * from './useMergedEventCallbacks';
10
8
  export * from './useMergedRefs';
11
- export * from './useMount';
12
9
  export * from './useOnClickOutside';
13
10
  export * from './useOnScrollOutside';
14
11
  export * from './usePrevious';
15
12
  export * from './useTimeout';
16
- export * from './useUnmount';
17
13
  //# sourceMappingURL=index.js.map