@fluentui/react-utilities 9.0.0-alpha.9 → 9.0.0-beta.4

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