@fluentui/react-utilities 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

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 (229) hide show
  1. package/CHANGELOG.json +355 -9
  2. package/CHANGELOG.md +185 -70
  3. package/dist/index.d.ts +517 -0
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/compose/getSlots.js +21 -30
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.js +0 -1
  8. package/lib/compose/index.js.map +1 -1
  9. package/lib/compose/resolveShorthand.js +13 -12
  10. package/lib/compose/resolveShorthand.js.map +1 -1
  11. package/lib/compose/types.js +1 -5
  12. package/lib/compose/types.js.map +1 -1
  13. package/lib/hooks/index.js +2 -6
  14. package/lib/hooks/index.js.map +1 -1
  15. package/lib/hooks/useControllableState.js +26 -26
  16. package/lib/hooks/useControllableState.js.map +1 -1
  17. package/lib/hooks/useEventCallback.js +6 -12
  18. package/lib/hooks/useEventCallback.js.map +1 -1
  19. package/lib/hooks/useFirstMount.js +1 -1
  20. package/lib/hooks/useFirstMount.js.map +1 -1
  21. package/lib/hooks/useForceUpdate.js +1 -3
  22. package/lib/hooks/useForceUpdate.js.map +1 -1
  23. package/lib/hooks/useId.js +9 -5
  24. package/lib/hooks/useId.js.map +1 -1
  25. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -1
  26. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  27. package/lib/hooks/useMergedEventCallbacks.js +26 -0
  28. package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
  29. package/lib/hooks/useMergedRefs.js +5 -13
  30. package/lib/hooks/useMergedRefs.js.map +1 -1
  31. package/lib/hooks/useOnClickOutside.js +30 -36
  32. package/lib/hooks/useOnClickOutside.js.map +1 -1
  33. package/lib/hooks/useOnScrollOutside.js +13 -15
  34. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  35. package/lib/hooks/usePrevious.js +3 -3
  36. package/lib/hooks/usePrevious.js.map +1 -1
  37. package/lib/hooks/useTimeout.js +13 -18
  38. package/lib/hooks/useTimeout.js.map +1 -1
  39. package/lib/index.js +4 -4
  40. package/lib/index.js.map +1 -1
  41. package/lib/ssr/SSRContext.js +9 -15
  42. package/lib/ssr/SSRContext.js.map +1 -1
  43. package/lib/ssr/canUseDOM.js.map +1 -1
  44. package/lib/ssr/index.js.map +1 -1
  45. package/lib/utils/applyTriggerPropsToChildren.js +24 -4
  46. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  47. package/lib/utils/clamp.js +1 -3
  48. package/lib/utils/clamp.js.map +1 -1
  49. package/lib/utils/getNativeElementProps.js +28 -4
  50. package/lib/utils/getNativeElementProps.js.map +1 -1
  51. package/lib/utils/getRTLSafeKey.js +1 -1
  52. package/lib/utils/getRTLSafeKey.js.map +1 -1
  53. package/lib/utils/getReactCallbackName.js +26 -0
  54. package/lib/utils/getReactCallbackName.js.map +1 -0
  55. package/lib/utils/getTriggerChild.js +26 -0
  56. package/lib/utils/getTriggerChild.js.map +1 -0
  57. package/lib/utils/index.js +2 -1
  58. package/lib/utils/index.js.map +1 -1
  59. package/lib/utils/isFluentTrigger.js +8 -0
  60. package/lib/utils/isFluentTrigger.js.map +1 -0
  61. package/lib/utils/omit.js +2 -2
  62. package/lib/utils/omit.js.map +1 -1
  63. package/lib/utils/properties.js +72 -49
  64. package/lib/utils/properties.js.map +1 -1
  65. package/lib/utils/shouldPreventDefaultOnKeyDown.js +8 -4
  66. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  67. package/lib-commonjs/compose/getSlots.js +23 -34
  68. package/lib-commonjs/compose/getSlots.js.map +1 -1
  69. package/lib-commonjs/compose/index.js +1 -3
  70. package/lib-commonjs/compose/index.js.map +1 -1
  71. package/lib-commonjs/compose/resolveShorthand.js +14 -14
  72. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  73. package/lib-commonjs/compose/types.js +1 -5
  74. package/lib-commonjs/compose/types.js.map +1 -1
  75. package/lib-commonjs/hooks/index.js +5 -13
  76. package/lib-commonjs/hooks/index.js.map +1 -1
  77. package/lib-commonjs/hooks/useControllableState.js +27 -28
  78. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  79. package/lib-commonjs/hooks/useEventCallback.js +8 -14
  80. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  81. package/lib-commonjs/hooks/useFirstMount.js +2 -2
  82. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  83. package/lib-commonjs/hooks/useForceUpdate.js +2 -4
  84. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  85. package/lib-commonjs/hooks/useId.js +11 -7
  86. package/lib-commonjs/hooks/useId.js.map +1 -1
  87. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +2 -2
  88. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  89. package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
  90. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
  91. package/lib-commonjs/hooks/useMergedRefs.js +6 -15
  92. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  93. package/lib-commonjs/hooks/useOnClickOutside.js +32 -38
  94. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  95. package/lib-commonjs/hooks/useOnScrollOutside.js +15 -17
  96. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  97. package/lib-commonjs/hooks/usePrevious.js +4 -4
  98. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  99. package/lib-commonjs/hooks/useTimeout.js +14 -20
  100. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  101. package/lib-commonjs/index.js +158 -5
  102. package/lib-commonjs/index.js.map +1 -1
  103. package/lib-commonjs/ssr/SSRContext.js +9 -15
  104. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  105. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  106. package/lib-commonjs/ssr/index.js +1 -1
  107. package/lib-commonjs/ssr/index.js.map +1 -1
  108. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +26 -6
  109. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  110. package/lib-commonjs/utils/clamp.js +1 -3
  111. package/lib-commonjs/utils/clamp.js.map +1 -1
  112. package/lib-commonjs/utils/getNativeElementProps.js +31 -5
  113. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  114. package/lib-commonjs/utils/getRTLSafeKey.js +1 -1
  115. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  116. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  117. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  118. package/lib-commonjs/utils/getTriggerChild.js +37 -0
  119. package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
  120. package/lib-commonjs/utils/index.js +5 -3
  121. package/lib-commonjs/utils/index.js.map +1 -1
  122. package/lib-commonjs/utils/isFluentTrigger.js +17 -0
  123. package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
  124. package/lib-commonjs/utils/omit.js +2 -2
  125. package/lib-commonjs/utils/omit.js.map +1 -1
  126. package/lib-commonjs/utils/properties.js +70 -47
  127. package/lib-commonjs/utils/properties.js.map +1 -1
  128. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +9 -5
  129. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  130. package/package.json +14 -17
  131. package/dist/react-utilities.d.ts +0 -648
  132. package/lib/compose/getSlots.d.ts +0 -29
  133. package/lib/compose/index.d.ts +0 -4
  134. package/lib/compose/nullRender.d.ts +0 -4
  135. package/lib/compose/nullRender.js +0 -7
  136. package/lib/compose/nullRender.js.map +0 -1
  137. package/lib/compose/resolveShorthand.d.ts +0 -12
  138. package/lib/compose/types.d.ts +0 -104
  139. package/lib/hooks/index.d.ts +0 -16
  140. package/lib/hooks/useBoolean.d.ts +0 -17
  141. package/lib/hooks/useBoolean.js +0 -39
  142. package/lib/hooks/useBoolean.js.map +0 -1
  143. package/lib/hooks/useConst.d.ts +0 -12
  144. package/lib/hooks/useConst.js +0 -30
  145. package/lib/hooks/useConst.js.map +0 -1
  146. package/lib/hooks/useControllableState.d.ts +0 -21
  147. package/lib/hooks/useControllableValue.d.ts +0 -20
  148. package/lib/hooks/useControllableValue.js +0 -62
  149. package/lib/hooks/useControllableValue.js.map +0 -1
  150. package/lib/hooks/useEventCallback.d.ts +0 -13
  151. package/lib/hooks/useFirstMount.d.ts +0 -11
  152. package/lib/hooks/useForceUpdate.d.ts +0 -4
  153. package/lib/hooks/useId.d.ts +0 -15
  154. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  155. package/lib/hooks/useMergedRefs.d.ts +0 -13
  156. package/lib/hooks/useMount.d.ts +0 -6
  157. package/lib/hooks/useMount.js +0 -17
  158. package/lib/hooks/useMount.js.map +0 -1
  159. package/lib/hooks/useOnClickOutside.d.ts +0 -29
  160. package/lib/hooks/useOnScrollOutside.d.ts +0 -5
  161. package/lib/hooks/usePrevious.d.ts +0 -1
  162. package/lib/hooks/useTimeout.d.ts +0 -8
  163. package/lib/hooks/useUnmount.d.ts +0 -6
  164. package/lib/hooks/useUnmount.js +0 -19
  165. package/lib/hooks/useUnmount.js.map +0 -1
  166. package/lib/index.d.ts +0 -4
  167. package/lib/ssr/SSRContext.d.ts +0 -33
  168. package/lib/ssr/canUseDOM.d.ts +0 -4
  169. package/lib/ssr/index.d.ts +0 -2
  170. package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
  171. package/lib/utils/clamp.d.ts +0 -8
  172. package/lib/utils/getNativeElementProps.d.ts +0 -9
  173. package/lib/utils/getRTLSafeKey.d.ts +0 -4
  174. package/lib/utils/index.d.ts +0 -8
  175. package/lib/utils/omit.d.ts +0 -14
  176. package/lib/utils/onlyChild.d.ts +0 -5
  177. package/lib/utils/onlyChild.js +0 -13
  178. package/lib/utils/onlyChild.js.map +0 -1
  179. package/lib/utils/properties.d.ts +0 -148
  180. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
  181. package/lib-commonjs/compose/getSlots.d.ts +0 -29
  182. package/lib-commonjs/compose/index.d.ts +0 -4
  183. package/lib-commonjs/compose/nullRender.d.ts +0 -4
  184. package/lib-commonjs/compose/nullRender.js +0 -16
  185. package/lib-commonjs/compose/nullRender.js.map +0 -1
  186. package/lib-commonjs/compose/resolveShorthand.d.ts +0 -12
  187. package/lib-commonjs/compose/types.d.ts +0 -104
  188. package/lib-commonjs/hooks/index.d.ts +0 -16
  189. package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
  190. package/lib-commonjs/hooks/useBoolean.js +0 -50
  191. package/lib-commonjs/hooks/useBoolean.js.map +0 -1
  192. package/lib-commonjs/hooks/useConst.d.ts +0 -12
  193. package/lib-commonjs/hooks/useConst.js +0 -40
  194. package/lib-commonjs/hooks/useConst.js.map +0 -1
  195. package/lib-commonjs/hooks/useControllableState.d.ts +0 -21
  196. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  197. package/lib-commonjs/hooks/useControllableValue.js +0 -73
  198. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
  199. package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
  200. package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
  201. package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
  202. package/lib-commonjs/hooks/useId.d.ts +0 -15
  203. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  204. package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
  205. package/lib-commonjs/hooks/useMount.d.ts +0 -6
  206. package/lib-commonjs/hooks/useMount.js +0 -27
  207. package/lib-commonjs/hooks/useMount.js.map +0 -1
  208. package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
  209. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
  210. package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
  211. package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
  212. package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
  213. package/lib-commonjs/hooks/useUnmount.js +0 -29
  214. package/lib-commonjs/hooks/useUnmount.js.map +0 -1
  215. package/lib-commonjs/index.d.ts +0 -4
  216. package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
  217. package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
  218. package/lib-commonjs/ssr/index.d.ts +0 -2
  219. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
  220. package/lib-commonjs/utils/clamp.d.ts +0 -8
  221. package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -9
  222. package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
  223. package/lib-commonjs/utils/index.d.ts +0 -8
  224. package/lib-commonjs/utils/omit.d.ts +0 -14
  225. package/lib-commonjs/utils/onlyChild.d.ts +0 -5
  226. package/lib-commonjs/utils/onlyChild.js +0 -23
  227. package/lib-commonjs/utils/onlyChild.js.map +0 -1
  228. package/lib-commonjs/utils/properties.d.ts +0 -148
  229. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
@@ -1,4 +0,0 @@
1
- /**
2
- * Finds and swaps a provided key for it's right to left format.
3
- */
4
- export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
@@ -1,8 +0,0 @@
1
- export * from './applyTriggerPropsToChildren';
2
- export * from './clamp';
3
- export * from './getNativeElementProps';
4
- export * from './getRTLSafeKey';
5
- export * from './omit';
6
- export * from './onlyChild';
7
- export * from './properties';
8
- export * from './shouldPreventDefaultOnKeyDown';
@@ -1,14 +0,0 @@
1
- /**
2
- * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
3
- * props. This ends up faster than using object ...rest or reduce to filter.
4
- *
5
- * This behaves very much like filteredAssign, but does not merge many objects together,
6
- * uses an exclusion object map, and avoids spreads all for optimal performance.
7
- *
8
- * See perf test for background:
9
- * https://jsperf.com/omit-vs-rest-vs-reduce/1
10
- *
11
- * @param obj - The object to clone
12
- * @param exclusions - The array of keys to exclude
13
- */
14
- export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
- */
5
- export declare const onlyChild: <P>(child: string | number | boolean | {} | React.ReactNodeArray | React.ReactPortal | React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined) => React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
- */
5
-
6
- export var onlyChild = function (child) {
7
- if (! /*#__PURE__*/React.isValidElement(child)) {
8
- throw new Error("Component's child must be a single element");
9
- }
10
-
11
- return child.type === React.Fragment ? onlyChild(child.props.children) : child;
12
- };
13
- //# sourceMappingURL=onlyChild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;AAEG;;AACH,OAAO,IAAM,SAAS,GAAG,UACvB,KADuB,EAC8F;AAErH,MAAI,eAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,SAAS,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,CAAzC,GAAkE,KAAzE;AACD,CARM","sourceRoot":""}
@@ -1,148 +0,0 @@
1
- /**
2
- * An array of events that are allowed on every html element type.
3
- *
4
- * @public
5
- */
6
- export declare const baseElementEvents: Record<string, number>;
7
- /**
8
- * An array of element attributes which are allowed on every html element type.
9
- *
10
- * @public
11
- */
12
- export declare const baseElementProperties: Record<string, number>;
13
- /**
14
- * An array of HTML element properties and events.
15
- *
16
- * @public
17
- */
18
- export declare const htmlElementProperties: Record<string, number>;
19
- /**
20
- * An array of LABEL tag properties and events.
21
- *
22
- * @public
23
- */
24
- export declare const labelProperties: Record<string, number>;
25
- /**
26
- * An array of AUDIO tag properties and events.
27
-
28
- * @public
29
- */
30
- export declare const audioProperties: Record<string, number>;
31
- /**
32
- * An array of VIDEO tag properties and events.
33
- *
34
- * @public
35
- */
36
- export declare const videoProperties: Record<string, number>;
37
- /**
38
- * An array of OL tag properties and events.
39
- *
40
- * @public
41
- */
42
- export declare const olProperties: Record<string, number>;
43
- /**
44
- * An array of LI tag properties and events.
45
- *
46
- * @public
47
- */
48
- export declare const liProperties: Record<string, number>;
49
- /**
50
- * An array of A tag properties and events.
51
- *
52
- * @public
53
- */
54
- export declare const anchorProperties: Record<string, number>;
55
- /**
56
- * An array of BUTTON tag properties and events.
57
- *
58
- * @public
59
- */
60
- export declare const buttonProperties: Record<string, number>;
61
- /**
62
- * An array of INPUT tag properties and events.
63
- *
64
- * @public
65
- */
66
- export declare const inputProperties: Record<string, number>;
67
- /**
68
- * An array of TEXTAREA tag properties and events.
69
- *
70
- * @public
71
- */
72
- export declare const textAreaProperties: Record<string, number>;
73
- /**
74
- * An array of SELECT tag properties and events.
75
- *
76
- * @public
77
- */
78
- export declare const selectProperties: Record<string, number>;
79
- export declare const optionProperties: Record<string, number>;
80
- /**
81
- * An array of TABLE tag properties and events.
82
- *
83
- * @public
84
- */
85
- export declare const tableProperties: Record<string, number>;
86
- /**
87
- * An array of TR tag properties and events.
88
- *
89
- * @public
90
- */
91
- export declare const trProperties: Record<string, number>;
92
- /**
93
- * An array of TH tag properties and events.
94
- *
95
- * @public
96
- */
97
- export declare const thProperties: Record<string, number>;
98
- /**
99
- * An array of TD tag properties and events.
100
- *
101
- * @public
102
- */
103
- export declare const tdProperties: Record<string, number>;
104
- export declare const colGroupProperties: Record<string, number>;
105
- export declare const colProperties: Record<string, number>;
106
- /**
107
- * An array of FORM tag properties and events.
108
- *
109
- * @public
110
- */
111
- export declare const formProperties: Record<string, number>;
112
- /**
113
- * An array of IFRAME tag properties and events.
114
- *
115
- * @public
116
- */
117
- export declare const iframeProperties: Record<string, number>;
118
- /**
119
- * An array of IMAGE tag properties and events.
120
- *
121
- * @public
122
- */
123
- export declare const imgProperties: Record<string, number>;
124
- /**
125
- * @deprecated Use imgProperties for img elements.
126
- */
127
- export declare const imageProperties: Record<string, number>;
128
- /**
129
- * An array of DIV tag properties and events.
130
- *
131
- * @public
132
- */
133
- export declare const divProperties: Record<string, number>;
134
- /**
135
- * Gets native supported props for an html element provided the allowance set. Use one of the property
136
- * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
137
- * props set. Note that all data- and aria- prefixed attributes will be allowed.
138
- * NOTE: getNativeProps should always be applied first when adding props to a react component. The
139
- * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
140
- * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
141
- * the component after an onClick function is added, then the getNativeProps onClick will override it.
142
- *
143
- * @public
144
- * @param props - The unfiltered input props
145
- * @param allowedPropsNames - The array or record of allowed prop names.
146
- * @returns The filtered props
147
- */
148
- export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
4
- *
5
- * Useful for situations where a keydown needs to be transformed to a click event
6
- */
7
- export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent): boolean;
@@ -1,29 +0,0 @@
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
- };
9
- /**
10
- * Given the state and an array of slot names, will break out `slots` and `slotProps`
11
- * collections.
12
- *
13
- * The root is derived from a mix of `components` props and `as` prop.
14
- *
15
- * Slots will render as null if they are rendered as primitives with undefined children.
16
- *
17
- * The slotProps will always omit the `as` prop within them, and for slots that are string
18
- * primitives, the props will be filtered according the the slot type. For example, if the
19
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
20
- *
21
- * @param state - State including slot definitions
22
- * @param slotNames - Name of which props are slots
23
- * @returns An object containing the `slots` map and `slotProps` map.
24
- */
25
- export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
26
- slots: Slots<R>;
27
- slotProps: SlotProps<R>;
28
- };
29
- export {};
@@ -1,4 +0,0 @@
1
- export * from './getSlots';
2
- export * from './nullRender';
3
- export * from './resolveShorthand';
4
- export * from './types';
@@ -1,4 +0,0 @@
1
- /**
2
- * Simple constant function for returning null, used to render empty templates in JSX.
3
- */
4
- export declare const nullRender: () => null;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.nullRender = void 0;
7
- /**
8
- * Simple constant function for returning null, used to render empty templates in JSX.
9
- */
10
-
11
- var nullRender = function () {
12
- return null;
13
- };
14
-
15
- exports.nullRender = nullRender;
16
- //# sourceMappingURL=nullRender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACI,IAAM,UAAU,GAAG,YAAA;AAAM,SAAA,IAAA;AAAI,CAA7B;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","sourceRoot":""}
@@ -1,12 +0,0 @@
1
- import type { DefaultObjectShorthandProps, ShorthandProps } from './types';
2
- export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
3
- required?: Required;
4
- defaultProps?: Props;
5
- };
6
- /**
7
- * Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
8
- * being passed down to getSlots method
9
- * @param value - the base ShorthandProps
10
- * @param options - options to resolve ShorthandProps
11
- */
12
- export declare function resolveShorthand<Props extends DefaultObjectShorthandProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
@@ -1,104 +0,0 @@
1
- import * as React from 'react';
2
- export declare type ShorthandRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
3
- export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
4
- export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props;
5
- /**
6
- * Matches any shorthand props type.
7
- *
8
- * This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
9
- * it shouldn't be used as the type of a slot.
10
- */
11
- export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
12
- children?: React.ReactNode;
13
- as?: keyof JSX.IntrinsicElements;
14
- }>;
15
- /**
16
- * Defines the slot props for a slot that supports a Component type.
17
- *
18
- * For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
19
- */
20
- export declare type ObjectShorthandProps<Props extends {
21
- children?: React.ReactNode;
22
- } = {}> = Props & {
23
- children?: Props['children'] | ShorthandRenderFunction<Props>;
24
- };
25
- /**
26
- * Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
27
- * For slots that support custom components, use {@link ObjectShorthandProps} instead.
28
- *
29
- * The first param is the slot's default type if no `as` prop is specified.
30
- * The second param is an optional union of alternative types that can be specified for the `as` prop.
31
- *
32
- * ```
33
- * IntrinsicShorthandProps<'div'> // Slot is always div
34
- * IntrinsicShorthandProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
35
- * IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
36
- * ```
37
- */
38
- 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' : ({
39
- as?: DefaultAs;
40
- } & ObjectShorthandProps<React.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
41
- [As in AlternateAs]: {
42
- as: As;
43
- } & ObjectShorthandProps<React.PropsWithRef<JSX.IntrinsicElements[As]>>;
44
- }[AlternateAs];
45
- /**
46
- * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
47
- *
48
- * ```
49
- * IsSingleton<'a'> // true
50
- * IsSingleton<'a' | 'b' | 'c'> // false
51
- * ```
52
- */
53
- export declare type IsSingleton<T extends string> = {
54
- [K in T]: Exclude<T, K> extends never ? true : false;
55
- }[T];
56
- /**
57
- * Helper type for inferring the type of the as prop from a Props type.
58
- *
59
- * For example:
60
- * ```
61
- * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
62
- * ```
63
- */
64
- export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
65
- as?: As;
66
- };
67
- /**
68
- * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)
69
- */
70
- export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
71
- /**
72
- * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
73
- * IntrinsicShorthandProps). This allows IntrinsicShorthandProps to be used with React.forwardRef.
74
- *
75
- * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
76
- * types, to prevent unions from being expanded.
77
- */
78
- export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
79
- export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
80
- [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
81
- }, Primary> & PropsWithoutRef<Shorthands[Primary]>;
82
- export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
83
- components?: {
84
- [Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
85
- };
86
- } & Shorthands;
87
- /**
88
- * This is part of a hack to infer the element type from a native element *props* type.
89
- * The only place the original element is found in a native props type (at least that's workable
90
- * for inference) is in the event handlers, so some of the helper types use this event handler
91
- * name to infer the original element type.
92
- *
93
- * Notes:
94
- * - Using an extremely obscure event handler reduces the likelihood that its signature will be
95
- * modified in any component's props.
96
- * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be
97
- * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.
98
- */
99
- declare type ObscureEventName = 'onLostPointerCaptureCapture';
100
- /**
101
- * Return type for `React.forwardRef`, including inference of the proper typing for the ref.
102
- */
103
- export declare type ForwardRefComponent<Props> = ObscureEventName extends keyof Props ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element> ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>> : never : never;
104
- export {};
@@ -1,16 +0,0 @@
1
- export * from './useControllableState';
2
- export * from './useBoolean';
3
- export * from './useConst';
4
- export * from './useControllableValue';
5
- export * from './useEventCallback';
6
- export * from './useFirstMount';
7
- export * from './useId';
8
- export * from './useIsomorphicLayoutEffect';
9
- export * from './useMergedRefs';
10
- export * from './useMount';
11
- export * from './useOnClickOutside';
12
- export * from './useOnScrollOutside';
13
- export * from './usePrevious';
14
- export * from './useTimeout';
15
- export * from './useUnmount';
16
- export * from './useForceUpdate';
@@ -1,17 +0,0 @@
1
- /** Updater callbacks returned by `useBoolean`. */
2
- export declare type UseBooleanCallbacks = {
3
- /** Set the value to true. Always has the same identity. */
4
- setTrue: () => void;
5
- /** Set the value to false. Always has the same identity. */
6
- setFalse: () => void;
7
- /** Toggle the value. Always has the same identity. */
8
- toggle: () => void;
9
- };
10
- /**
11
- * Hook to store a value and generate callbacks for setting the value to true or false.
12
- * The identity of the callbacks will always stay the same.
13
- *
14
- * @param initialState - Initial value
15
- * @returns Array with the current value and an object containing the updater callbacks.
16
- */
17
- export declare function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks];
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBoolean = void 0;
7
-
8
- var React = /*#__PURE__*/require("react");
9
-
10
- var useConst_1 = /*#__PURE__*/require("./useConst");
11
- /**
12
- * Hook to store a value and generate callbacks for setting the value to true or false.
13
- * The identity of the callbacks will always stay the same.
14
- *
15
- * @param initialState - Initial value
16
- * @returns Array with the current value and an object containing the updater callbacks.
17
- */
18
-
19
-
20
- function useBoolean(initialState) {
21
- var _a = React.useState(initialState),
22
- value = _a[0],
23
- setValue = _a[1];
24
-
25
- var setTrue = useConst_1.useConst(function () {
26
- return function () {
27
- setValue(true);
28
- };
29
- });
30
- var setFalse = useConst_1.useConst(function () {
31
- return function () {
32
- setValue(false);
33
- };
34
- });
35
- var toggle = useConst_1.useConst(function () {
36
- return function () {
37
- setValue(function (currentValue) {
38
- return !currentValue;
39
- });
40
- };
41
- });
42
- return [value, {
43
- setTrue: setTrue,
44
- setFalse: setFalse,
45
- toggle: toggle
46
- }];
47
- }
48
-
49
- exports.useBoolean = useBoolean;
50
- //# sourceMappingURL=useBoolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useBoolean.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;AAYA;;;;;;AAMG;;;AACH,SAAgB,UAAhB,CAA2B,YAA3B,EAAgD;AACxC,MAAA,EAAA,GAAoB,KAAK,CAAC,QAAN,CAAe,YAAf,CAApB;AAAA,MAAC,KAAK,GAAA,EAAA,CAAA,CAAA,CAAN;AAAA,MAAQ,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAhB;;AAEN,MAAM,OAAO,GAAG,UAAA,CAAA,QAAA,CAAS,YAAA;AAAM,WAAA,YAAA;AAC7B,MAAA,QAAQ,CAAC,IAAD,CAAR;AAD6B,KAAA;AAE9B,GAFe,CAAhB;AAGA,MAAM,QAAQ,GAAG,UAAA,CAAA,QAAA,CAAS,YAAA;AAAM,WAAA,YAAA;AAC9B,MAAA,QAAQ,CAAC,KAAD,CAAR;AAD8B,KAAA;AAE/B,GAFgB,CAAjB;AAGA,MAAM,MAAM,GAAG,UAAA,CAAA,QAAA,CAAS,YAAA;AAAM,WAAA,YAAA;AAC5B,MAAA,QAAQ,CAAC,UAAA,YAAA,EAAY;AAAI,eAAA,CAAA,YAAA;AAAa,OAA9B,CAAR;AAD4B,KAAA;AAE7B,GAFc,CAAf;AAIA,SAAO,CAAC,KAAD,EAAQ;AAAE,IAAA,OAAO,EAAA,OAAT;AAAW,IAAA,QAAQ,EAAA,QAAnB;AAAqB,IAAA,MAAM,EAAA;AAA3B,GAAR,CAAP;AACD;;AAdD,OAAA,CAAA,UAAA,GAAA,UAAA","sourceRoot":""}
@@ -1,12 +0,0 @@
1
- /**
2
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
3
- * always return the same value (and if the initializer is a function, only call it once).
4
- * This is similar to setting a private member in a class constructor.
5
- *
6
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
7
- *
8
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
9
- * only the value/function passed in the first time this is called is respected.
10
- * @returns The value. The identity of this value will always be the same.
11
- */
12
- export declare function useConst<T>(initialValue: T | (() => T)): T;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useConst = void 0;
7
-
8
- var React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
11
- * always return the same value (and if the initializer is a function, only call it once).
12
- * This is similar to setting a private member in a class constructor.
13
- *
14
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
15
- *
16
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
17
- * only the value/function passed in the first time this is called is respected.
18
- * @returns The value. The identity of this value will always be the same.
19
- */
20
-
21
-
22
- function useConst(initialValue) {
23
- // Use useRef to store the value because it's the least expensive built-in hook that works here
24
- // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive
25
- // internally due to reducer handling which we don't need)
26
- var ref = React.useRef();
27
-
28
- if (ref.current === undefined) {
29
- // Box the value in an object so we can tell if it's initialized even if the initializer
30
- // returns/is undefined
31
- ref.current = {
32
- value: typeof initialValue === 'function' ? initialValue() : initialValue
33
- };
34
- }
35
-
36
- return ref.current.value;
37
- }
38
-
39
- exports.useConst = useConst;
40
- //# sourceMappingURL=useConst.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useConst.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;;;;;;;AAUG;;;AACH,SAAgB,QAAhB,CAA4B,YAA5B,EAAuD;AACrD;AACA;AACA;AACA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAN,EAAZ;;AACA,MAAI,GAAG,CAAC,OAAJ,KAAgB,SAApB,EAA+B;AAC7B;AACA;AACA,IAAA,GAAG,CAAC,OAAJ,GAAc;AACZ,MAAA,KAAK,EAAE,OAAO,YAAP,KAAwB,UAAxB,GAAsC,YAAyB,EAA/D,GAAoE;AAD/D,KAAd;AAGD;;AACD,SAAO,GAAG,CAAC,OAAJ,CAAY,KAAnB;AACD;;AAbD,OAAA,CAAA,QAAA,GAAA,QAAA","sourceRoot":""}
@@ -1,21 +0,0 @@
1
- import * as React from 'react';
2
- export declare type UseControllableStateOptions<State> = {
3
- /**
4
- * User provided default state or factory initializer
5
- */
6
- defaultState?: State | (() => State);
7
- /**
8
- * User provided controllable state, undefined state means internal state will be used
9
- */
10
- state: State | undefined;
11
- /**
12
- * Used to initialize state if all user provided states are undefined
13
- */
14
- initialState: State;
15
- };
16
- /**
17
- * A useState 'like' hook that allows optional user control
18
- * Useful for components which allow uncontrolled and controlled behaviour for users
19
- * @returns - https://reactjs.org/docs/hooks-state.html
20
- */
21
- export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React.Dispatch<React.SetStateAction<State>>];
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- export declare type ChangeCallback<TElement extends HTMLElement, TValue, TEvent extends React.SyntheticEvent<TElement> | undefined> = (ev: TEvent, newValue: TValue | undefined) => void;
3
- /**
4
- * Default value can be a value or an initializer
5
- */
6
- declare type DefaultValue<TValue> = TValue | (() => TValue);
7
- /**
8
- * Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
9
- * text box string.
10
- * @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
11
- * and the internal state will be updated to reflect it.
12
- * @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
13
- * @returns An array of the current value and an updater callback. Like `React.useState`, the updater
14
- * callback always has the same identity, and it can take either a new value, or a function which
15
- * is passed the previous value and returns the new value.
16
- * @see https://reactjs.org/docs/uncontrolled-components.html
17
- */
18
- export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React.SetStateAction<TValue>) => void]>;
19
- 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]>;
20
- export {};