@fluentui/react-utilities 0.0.0-nightly050f89bf0020211102.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/CHANGELOG.json +1637 -0
  2. package/CHANGELOG.md +677 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/dist/react-utilities.d.ts +648 -0
  6. package/lib/compose/getSlots.d.ts +29 -0
  7. package/lib/compose/getSlots.js +72 -0
  8. package/lib/compose/getSlots.js.map +1 -0
  9. package/lib/compose/index.d.ts +4 -0
  10. package/lib/compose/index.js +5 -0
  11. package/lib/compose/index.js.map +1 -0
  12. package/lib/compose/nullRender.d.ts +4 -0
  13. package/lib/compose/nullRender.js +7 -0
  14. package/lib/compose/nullRender.js.map +1 -0
  15. package/lib/compose/resolveShorthand.d.ts +12 -0
  16. package/lib/compose/resolveShorthand.js +30 -0
  17. package/lib/compose/resolveShorthand.js.map +1 -0
  18. package/lib/compose/types.d.ts +104 -0
  19. package/lib/compose/types.js +6 -0
  20. package/lib/compose/types.js.map +1 -0
  21. package/lib/hooks/index.d.ts +16 -0
  22. package/lib/hooks/index.js +17 -0
  23. package/lib/hooks/index.js.map +1 -0
  24. package/lib/hooks/useBoolean.d.ts +17 -0
  25. package/lib/hooks/useBoolean.js +39 -0
  26. package/lib/hooks/useBoolean.js.map +1 -0
  27. package/lib/hooks/useConst.d.ts +12 -0
  28. package/lib/hooks/useConst.js +30 -0
  29. package/lib/hooks/useConst.js.map +1 -0
  30. package/lib/hooks/useControllableState.d.ts +21 -0
  31. package/lib/hooks/useControllableState.js +72 -0
  32. package/lib/hooks/useControllableState.js.map +1 -0
  33. package/lib/hooks/useControllableValue.d.ts +20 -0
  34. package/lib/hooks/useControllableValue.js +62 -0
  35. package/lib/hooks/useControllableValue.js.map +1 -0
  36. package/lib/hooks/useEventCallback.d.ts +13 -0
  37. package/lib/hooks/useEventCallback.js +34 -0
  38. package/lib/hooks/useEventCallback.js.map +1 -0
  39. package/lib/hooks/useFirstMount.d.ts +11 -0
  40. package/lib/hooks/useFirstMount.js +23 -0
  41. package/lib/hooks/useFirstMount.js.map +1 -0
  42. package/lib/hooks/useForceUpdate.d.ts +4 -0
  43. package/lib/hooks/useForceUpdate.js +11 -0
  44. package/lib/hooks/useForceUpdate.js.map +1 -0
  45. package/lib/hooks/useId.d.ts +15 -0
  46. package/lib/hooks/useId.js +27 -0
  47. package/lib/hooks/useId.js.map +1 -0
  48. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  49. package/lib/hooks/useIsomorphicLayoutEffect.js +15 -0
  50. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  51. package/lib/hooks/useMergedRefs.d.ts +13 -0
  52. package/lib/hooks/useMergedRefs.js +34 -0
  53. package/lib/hooks/useMergedRefs.js.map +1 -0
  54. package/lib/hooks/useMount.d.ts +6 -0
  55. package/lib/hooks/useMount.js +17 -0
  56. package/lib/hooks/useMount.js.map +1 -0
  57. package/lib/hooks/useOnClickOutside.d.ts +29 -0
  58. package/lib/hooks/useOnClickOutside.js +142 -0
  59. package/lib/hooks/useOnClickOutside.js.map +1 -0
  60. package/lib/hooks/useOnScrollOutside.d.ts +5 -0
  61. package/lib/hooks/useOnScrollOutside.js +38 -0
  62. package/lib/hooks/useOnScrollOutside.js.map +1 -0
  63. package/lib/hooks/usePrevious.d.ts +1 -0
  64. package/lib/hooks/usePrevious.js +9 -0
  65. package/lib/hooks/usePrevious.js.map +1 -0
  66. package/lib/hooks/useTimeout.d.ts +8 -0
  67. package/lib/hooks/useTimeout.js +33 -0
  68. package/lib/hooks/useTimeout.js.map +1 -0
  69. package/lib/hooks/useUnmount.d.ts +6 -0
  70. package/lib/hooks/useUnmount.js +19 -0
  71. package/lib/hooks/useUnmount.js.map +1 -0
  72. package/lib/index.d.ts +4 -0
  73. package/lib/index.js +5 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/ssr/SSRContext.d.ts +33 -0
  76. package/lib/ssr/SSRContext.js +71 -0
  77. package/lib/ssr/SSRContext.js.map +1 -0
  78. package/lib/ssr/canUseDOM.d.ts +4 -0
  79. package/lib/ssr/canUseDOM.js +8 -0
  80. package/lib/ssr/canUseDOM.js.map +1 -0
  81. package/lib/ssr/index.d.ts +2 -0
  82. package/lib/ssr/index.js +3 -0
  83. package/lib/ssr/index.js.map +1 -0
  84. package/lib/tsdoc-metadata.json +11 -0
  85. package/lib/utils/applyTriggerPropsToChildren.d.ts +5 -0
  86. package/lib/utils/applyTriggerPropsToChildren.js +16 -0
  87. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -0
  88. package/lib/utils/clamp.d.ts +8 -0
  89. package/lib/utils/clamp.js +11 -0
  90. package/lib/utils/clamp.js.map +1 -0
  91. package/lib/utils/getNativeElementProps.d.ts +9 -0
  92. package/lib/utils/getNativeElementProps.js +38 -0
  93. package/lib/utils/getNativeElementProps.js.map +1 -0
  94. package/lib/utils/getRTLSafeKey.d.ts +4 -0
  95. package/lib/utils/getRTLSafeKey.js +21 -0
  96. package/lib/utils/getRTLSafeKey.js.map +1 -0
  97. package/lib/utils/index.d.ts +8 -0
  98. package/lib/utils/index.js +9 -0
  99. package/lib/utils/index.js.map +1 -0
  100. package/lib/utils/omit.d.ts +14 -0
  101. package/lib/utils/omit.js +27 -0
  102. package/lib/utils/omit.js.map +1 -0
  103. package/lib/utils/onlyChild.d.ts +5 -0
  104. package/lib/utils/onlyChild.js +13 -0
  105. package/lib/utils/onlyChild.js.map +1 -0
  106. package/lib/utils/properties.d.ts +148 -0
  107. package/lib/utils/properties.js +218 -0
  108. package/lib/utils/properties.js.map +1 -0
  109. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  110. package/lib/utils/shouldPreventDefaultOnKeyDown.js +20 -0
  111. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  112. package/lib-commonjs/compose/getSlots.d.ts +29 -0
  113. package/lib-commonjs/compose/getSlots.js +85 -0
  114. package/lib-commonjs/compose/getSlots.js.map +1 -0
  115. package/lib-commonjs/compose/index.d.ts +4 -0
  116. package/lib-commonjs/compose/index.js +16 -0
  117. package/lib-commonjs/compose/index.js.map +1 -0
  118. package/lib-commonjs/compose/nullRender.d.ts +4 -0
  119. package/lib-commonjs/compose/nullRender.js +16 -0
  120. package/lib-commonjs/compose/nullRender.js.map +1 -0
  121. package/lib-commonjs/compose/resolveShorthand.d.ts +12 -0
  122. package/lib-commonjs/compose/resolveShorthand.js +41 -0
  123. package/lib-commonjs/compose/resolveShorthand.js.map +1 -0
  124. package/lib-commonjs/compose/types.d.ts +104 -0
  125. package/lib-commonjs/compose/types.js +10 -0
  126. package/lib-commonjs/compose/types.js.map +1 -0
  127. package/lib-commonjs/hooks/index.d.ts +16 -0
  128. package/lib-commonjs/hooks/index.js +40 -0
  129. package/lib-commonjs/hooks/index.js.map +1 -0
  130. package/lib-commonjs/hooks/useBoolean.d.ts +17 -0
  131. package/lib-commonjs/hooks/useBoolean.js +50 -0
  132. package/lib-commonjs/hooks/useBoolean.js.map +1 -0
  133. package/lib-commonjs/hooks/useConst.d.ts +12 -0
  134. package/lib-commonjs/hooks/useConst.js +40 -0
  135. package/lib-commonjs/hooks/useConst.js.map +1 -0
  136. package/lib-commonjs/hooks/useControllableState.d.ts +21 -0
  137. package/lib-commonjs/hooks/useControllableState.js +82 -0
  138. package/lib-commonjs/hooks/useControllableState.js.map +1 -0
  139. package/lib-commonjs/hooks/useControllableValue.d.ts +20 -0
  140. package/lib-commonjs/hooks/useControllableValue.js +73 -0
  141. package/lib-commonjs/hooks/useControllableValue.js.map +1 -0
  142. package/lib-commonjs/hooks/useEventCallback.d.ts +13 -0
  143. package/lib-commonjs/hooks/useEventCallback.js +45 -0
  144. package/lib-commonjs/hooks/useEventCallback.js.map +1 -0
  145. package/lib-commonjs/hooks/useFirstMount.d.ts +11 -0
  146. package/lib-commonjs/hooks/useFirstMount.js +33 -0
  147. package/lib-commonjs/hooks/useFirstMount.js.map +1 -0
  148. package/lib-commonjs/hooks/useForceUpdate.d.ts +4 -0
  149. package/lib-commonjs/hooks/useForceUpdate.js +21 -0
  150. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -0
  151. package/lib-commonjs/hooks/useId.d.ts +15 -0
  152. package/lib-commonjs/hooks/useId.js +40 -0
  153. package/lib-commonjs/hooks/useId.js.map +1 -0
  154. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  155. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +24 -0
  156. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  157. package/lib-commonjs/hooks/useMergedRefs.d.ts +13 -0
  158. package/lib-commonjs/hooks/useMergedRefs.js +45 -0
  159. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -0
  160. package/lib-commonjs/hooks/useMount.d.ts +6 -0
  161. package/lib-commonjs/hooks/useMount.js +27 -0
  162. package/lib-commonjs/hooks/useMount.js.map +1 -0
  163. package/lib-commonjs/hooks/useOnClickOutside.d.ts +29 -0
  164. package/lib-commonjs/hooks/useOnClickOutside.js +153 -0
  165. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -0
  166. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +5 -0
  167. package/lib-commonjs/hooks/useOnScrollOutside.js +49 -0
  168. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -0
  169. package/lib-commonjs/hooks/usePrevious.d.ts +1 -0
  170. package/lib-commonjs/hooks/usePrevious.js +19 -0
  171. package/lib-commonjs/hooks/usePrevious.js.map +1 -0
  172. package/lib-commonjs/hooks/useTimeout.d.ts +8 -0
  173. package/lib-commonjs/hooks/useTimeout.js +44 -0
  174. package/lib-commonjs/hooks/useTimeout.js.map +1 -0
  175. package/lib-commonjs/hooks/useUnmount.d.ts +6 -0
  176. package/lib-commonjs/hooks/useUnmount.js +29 -0
  177. package/lib-commonjs/hooks/useUnmount.js.map +1 -0
  178. package/lib-commonjs/index.d.ts +4 -0
  179. package/lib-commonjs/index.js +16 -0
  180. package/lib-commonjs/index.js.map +1 -0
  181. package/lib-commonjs/ssr/SSRContext.d.ts +33 -0
  182. package/lib-commonjs/ssr/SSRContext.js +86 -0
  183. package/lib-commonjs/ssr/SSRContext.js.map +1 -0
  184. package/lib-commonjs/ssr/canUseDOM.d.ts +4 -0
  185. package/lib-commonjs/ssr/canUseDOM.js +17 -0
  186. package/lib-commonjs/ssr/canUseDOM.js.map +1 -0
  187. package/lib-commonjs/ssr/index.d.ts +2 -0
  188. package/lib-commonjs/ssr/index.js +12 -0
  189. package/lib-commonjs/ssr/index.js.map +1 -0
  190. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +5 -0
  191. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +27 -0
  192. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -0
  193. package/lib-commonjs/utils/clamp.d.ts +8 -0
  194. package/lib-commonjs/utils/clamp.js +20 -0
  195. package/lib-commonjs/utils/clamp.js.map +1 -0
  196. package/lib-commonjs/utils/getNativeElementProps.d.ts +9 -0
  197. package/lib-commonjs/utils/getNativeElementProps.js +48 -0
  198. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -0
  199. package/lib-commonjs/utils/getRTLSafeKey.d.ts +4 -0
  200. package/lib-commonjs/utils/getRTLSafeKey.js +30 -0
  201. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -0
  202. package/lib-commonjs/utils/index.d.ts +8 -0
  203. package/lib-commonjs/utils/index.js +24 -0
  204. package/lib-commonjs/utils/index.js.map +1 -0
  205. package/lib-commonjs/utils/omit.d.ts +14 -0
  206. package/lib-commonjs/utils/omit.js +36 -0
  207. package/lib-commonjs/utils/omit.js.map +1 -0
  208. package/lib-commonjs/utils/onlyChild.d.ts +5 -0
  209. package/lib-commonjs/utils/onlyChild.js +23 -0
  210. package/lib-commonjs/utils/onlyChild.js.map +1 -0
  211. package/lib-commonjs/utils/properties.d.ts +148 -0
  212. package/lib-commonjs/utils/properties.js +227 -0
  213. package/lib-commonjs/utils/properties.js.map +1 -0
  214. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  215. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +30 -0
  216. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  217. package/package.json +55 -0
@@ -0,0 +1,218 @@
1
+ var toObjectMap = function () {
2
+ var items = [];
3
+
4
+ for (var _i = 0; _i < arguments.length; _i++) {
5
+ items[_i] = arguments[_i];
6
+ }
7
+
8
+ var result = {};
9
+
10
+ for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
11
+ var item = items_1[_a];
12
+ var keys = Array.isArray(item) ? item : Object.keys(item);
13
+
14
+ for (var _b = 0, keys_1 = keys; _b < keys_1.length; _b++) {
15
+ var key = keys_1[_b];
16
+ result[key] = 1;
17
+ }
18
+ }
19
+
20
+ return result;
21
+ };
22
+ /**
23
+ * An array of events that are allowed on every html element type.
24
+ *
25
+ * @public
26
+ */
27
+
28
+
29
+ export var baseElementEvents = /*#__PURE__*/toObjectMap(['onAuxClick', 'onCopy', 'onCut', 'onPaste', 'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate', 'onFocus', 'onFocusCapture', 'onBlur', 'onBlurCapture', 'onChange', 'onInput', 'onSubmit', 'onLoad', 'onError', 'onKeyDown', 'onKeyDownCapture', 'onKeyPress', 'onKeyUp', 'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting', 'onClick', 'onClickCapture', 'onContextMenu', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseDownCapture', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onMouseUpCapture', 'onSelect', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'onScroll', 'onWheel', 'onPointerCancel', 'onPointerDown', 'onPointerEnter', 'onPointerLeave', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onPointerUp', 'onGotPointerCapture', 'onLostPointerCapture']);
30
+ /**
31
+ * An array of element attributes which are allowed on every html element type.
32
+ *
33
+ * @public
34
+ */
35
+
36
+ export var baseElementProperties = /*#__PURE__*/toObjectMap(['accessKey', 'children', 'className', 'contentEditable', 'dir', 'draggable', 'hidden', 'htmlFor', 'id', 'lang', 'ref', 'role', 'style', 'tabIndex', 'title', 'translate', 'spellCheck', 'name']);
37
+ /**
38
+ * An array of HTML element properties and events.
39
+ *
40
+ * @public
41
+ */
42
+
43
+ export var htmlElementProperties = /*#__PURE__*/toObjectMap(baseElementProperties, baseElementEvents);
44
+ /**
45
+ * An array of LABEL tag properties and events.
46
+ *
47
+ * @public
48
+ */
49
+
50
+ export var labelProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['form']);
51
+ /**
52
+ * An array of AUDIO tag properties and events.
53
+
54
+ * @public
55
+ */
56
+
57
+ export var audioProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['height', 'loop', 'muted', 'preload', 'src', 'width']);
58
+ /**
59
+ * An array of VIDEO tag properties and events.
60
+ *
61
+ * @public
62
+ */
63
+
64
+ export var videoProperties = /*#__PURE__*/toObjectMap(audioProperties, ['poster']);
65
+ /**
66
+ * An array of OL tag properties and events.
67
+ *
68
+ * @public
69
+ */
70
+
71
+ export var olProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['start']);
72
+ /**
73
+ * An array of LI tag properties and events.
74
+ *
75
+ * @public
76
+ */
77
+
78
+ export var liProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['value']);
79
+ /**
80
+ * An array of A tag properties and events.
81
+ *
82
+ * @public
83
+ */
84
+
85
+ export var anchorProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['download', 'href', 'hrefLang', 'media', 'rel', 'target', 'type']);
86
+ /**
87
+ * An array of BUTTON tag properties and events.
88
+ *
89
+ * @public
90
+ */
91
+
92
+ export var buttonProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['autoFocus', 'disabled', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'type', 'value']);
93
+ /**
94
+ * An array of INPUT tag properties and events.
95
+ *
96
+ * @public
97
+ */
98
+
99
+ export var inputProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['accept', 'alt', 'autoCapitalize', 'autoComplete', 'checked', 'dirname', 'form', 'height', 'inputMode', 'list', 'max', 'maxLength', 'min', 'multiple', 'pattern', 'placeholder', 'readOnly', 'required', 'src', 'step', 'size', 'type', 'value', 'width']);
100
+ /**
101
+ * An array of TEXTAREA tag properties and events.
102
+ *
103
+ * @public
104
+ */
105
+
106
+ export var textAreaProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['autoCapitalize', 'cols', 'dirname', 'form', 'maxLength', 'placeholder', 'readOnly', 'required', 'rows', 'wrap']);
107
+ /**
108
+ * An array of SELECT tag properties and events.
109
+ *
110
+ * @public
111
+ */
112
+
113
+ export var selectProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['form', 'multiple', 'required']);
114
+ export var optionProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['selected', 'value']);
115
+ /**
116
+ * An array of TABLE tag properties and events.
117
+ *
118
+ * @public
119
+ */
120
+
121
+ export var tableProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['cellPadding', 'cellSpacing']);
122
+ /**
123
+ * An array of TR tag properties and events.
124
+ *
125
+ * @public
126
+ */
127
+
128
+ export var trProperties = htmlElementProperties;
129
+ /**
130
+ * An array of TH tag properties and events.
131
+ *
132
+ * @public
133
+ */
134
+
135
+ export var thProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['rowSpan', 'scope']);
136
+ /**
137
+ * An array of TD tag properties and events.
138
+ *
139
+ * @public
140
+ */
141
+
142
+ export var tdProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['colSpan', 'headers', 'rowSpan', 'scope']);
143
+ export var colGroupProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span']);
144
+ export var colProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span']);
145
+ /**
146
+ * An array of FORM tag properties and events.
147
+ *
148
+ * @public
149
+ */
150
+
151
+ export var formProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['acceptCharset', 'action', 'encType', 'encType', 'method', 'noValidate', 'target']);
152
+ /**
153
+ * An array of IFRAME tag properties and events.
154
+ *
155
+ * @public
156
+ */
157
+
158
+ export var iframeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['allow', 'allowFullScreen', 'allowPaymentRequest', 'allowTransparency', 'csp', 'height', 'importance', 'referrerPolicy', 'sandbox', 'src', 'srcDoc', 'width']);
159
+ /**
160
+ * An array of IMAGE tag properties and events.
161
+ *
162
+ * @public
163
+ */
164
+
165
+ export var imgProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['alt', 'crossOrigin', 'height', 'src', 'srcSet', 'useMap', 'width']);
166
+ /**
167
+ * @deprecated Use imgProperties for img elements.
168
+ */
169
+
170
+ export var imageProperties = imgProperties;
171
+ /**
172
+ * An array of DIV tag properties and events.
173
+ *
174
+ * @public
175
+ */
176
+
177
+ export var divProperties = htmlElementProperties;
178
+ /**
179
+ * Gets native supported props for an html element provided the allowance set. Use one of the property
180
+ * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
181
+ * props set. Note that all data- and aria- prefixed attributes will be allowed.
182
+ * NOTE: getNativeProps should always be applied first when adding props to a react component. The
183
+ * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
184
+ * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
185
+ * the component after an onClick function is added, then the getNativeProps onClick will override it.
186
+ *
187
+ * @public
188
+ * @param props - The unfiltered input props
189
+ * @param allowedPropsNames - The array or record of allowed prop names.
190
+ * @returns The filtered props
191
+ */
192
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
193
+
194
+ export function getNativeProps( // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
+ props, allowedPropNames, excludedPropNames) {
196
+ // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for
197
+ // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.
198
+ // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then
199
+ // return native props.
200
+ // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797
201
+ var isArray = Array.isArray(allowedPropNames); // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+
203
+ var result = {};
204
+ var keys = Object.keys(props);
205
+
206
+ for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
207
+ var key = keys_2[_i];
208
+ var isNativeProp = !isArray && allowedPropNames[key] || isArray && allowedPropNames.indexOf(key) >= 0 || key.indexOf('data-') === 0 || key.indexOf('aria-') === 0;
209
+
210
+ if (isNativeProp && (!excludedPropNames || (excludedPropNames === null || excludedPropNames === void 0 ? void 0 : excludedPropNames.indexOf(key)) === -1)) {
211
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
212
+ result[key] = props[key];
213
+ }
214
+ }
215
+
216
+ return result;
217
+ }
218
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/properties.ts"],"names":[],"mappings":"AAAA,IAAM,WAAW,GAAG,YAAA;AAAC,MAAA,KAAA,GAAA,EAAA;;OAAA,IAAA,EAAA,GAAA,C,EAAA,EAAA,GAAA,SAAA,CAAA,M,EAAA,EAAA,E,EAA+C;AAA/C,IAAA,KAAA,CAAA,EAAA,CAAA,GAAA,SAAA,CAAA,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A,MAAA,CAAA,EAAA,CAAT;AACH,QAAM,YAAY,GACf,CAAC,OAAD,IAAa,gBAA2C,CAAC,GAAD,CAAzD,IACC,OAAO,IAAK,gBAA6B,CAAC,OAA9B,CAAsC,GAAtC,KAA8C,CAD3D,IAEA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAFzB,IAGA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAJ3B;;AAMA,QAAI,YAAY,KAAK,CAAC,iBAAD,IAAsB,CAAA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAE,OAAnB,CAA2B,GAA3B,CAAA,MAAoC,CAAC,CAAhE,CAAhB,EAAoF;AAClF;AACA,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,KAAM,CAAC,GAAD,CAApB;AACD;AACF;;AAED,SAAO,MAAP;AACD","sourceRoot":""}
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,20 @@
1
+ import { Space, Enter } from '@fluentui/keyboard-keys';
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
+
8
+ export function shouldPreventDefaultOnKeyDown(e) {
9
+ var key = e.key;
10
+ var target = e.target;
11
+ var matchesByKey = key === Space || key === Enter;
12
+
13
+ if ((target === null || target === void 0 ? void 0 : target.tagName) === 'A') {
14
+ return key === Space;
15
+ }
16
+
17
+ var ignoredByTag = (target === null || target === void 0 ? void 0 : target.tagName) === 'INPUT' || (target === null || target === void 0 ? void 0 : target.tagName) === 'TEXTAREA' || (target === null || target === void 0 ? void 0 : target.isContentEditable) === true;
18
+ return matchesByKey && !ignoredByTag;
19
+ }
20
+ //# sourceMappingURL=shouldPreventDefaultOnKeyDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/shouldPreventDefaultOnKeyDown.ts"],"names":[],"mappings":"AAAA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AAGA;;;;AAIG;;AACH,OAAM,SAAU,6BAAV,CAAwC,CAAxC,EAA8E;AAClF,MAAM,GAAG,GAAG,CAAC,CAAC,GAAd;AACA,MAAM,MAAM,GAA4B,CAAC,CAAC,MAA1C;AAEA,MAAM,YAAY,GAAG,GAAG,KAAK,KAAR,IAAiB,GAAG,KAAK,KAA9C;;AAEA,MAAI,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,GAAxB,EAA6B;AAC3B,WAAO,GAAG,KAAK,KAAf;AACD;;AAED,MAAM,YAAY,GAChB,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,OAApB,IAA+B,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,UAAnD,IAAiE,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,iBAAR,MAA8B,IADjG;AAGA,SAAO,YAAY,IAAI,CAAC,YAAxB;AACD","sourceRoot":""}
@@ -0,0 +1,29 @@
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 {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSlots = void 0;
7
+
8
+ var tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ var React = /*#__PURE__*/require("react");
11
+
12
+ var nullRender_1 = /*#__PURE__*/require("./nullRender");
13
+
14
+ var omit_1 = /*#__PURE__*/require("../utils/omit");
15
+ /**
16
+ * Given the state and an array of slot names, will break out `slots` and `slotProps`
17
+ * collections.
18
+ *
19
+ * The root is derived from a mix of `components` props and `as` prop.
20
+ *
21
+ * Slots will render as null if they are rendered as primitives with undefined children.
22
+ *
23
+ * The slotProps will always omit the `as` prop within them, and for slots that are string
24
+ * primitives, the props will be filtered according the the slot type. For example, if the
25
+ * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
26
+ *
27
+ * @param state - State including slot definitions
28
+ * @param slotNames - Name of which props are slots
29
+ * @returns An object containing the `slots` map and `slotProps` map.
30
+ */
31
+
32
+
33
+ function getSlots(state, slotNames) {
34
+ if (slotNames === void 0) {
35
+ slotNames = ['root'];
36
+ }
37
+
38
+ var slots = {};
39
+ var slotProps = {};
40
+
41
+ for (var _i = 0, slotNames_1 = slotNames; _i < slotNames_1.length; _i++) {
42
+ var slotName = slotNames_1[_i];
43
+
44
+ var _a = getSlot(state, slotName),
45
+ slot = _a[0],
46
+ props = _a[1];
47
+
48
+ slots[slotName] = slot;
49
+ slotProps[slotName] = props;
50
+ }
51
+
52
+ return {
53
+ slots: slots,
54
+ slotProps: slotProps
55
+ };
56
+ }
57
+
58
+ exports.getSlots = getSlots;
59
+
60
+ function getSlot(state, slotName) {
61
+ var _a, _b, _c;
62
+
63
+ if (state[slotName] === undefined) {
64
+ return [nullRender_1.nullRender, undefined];
65
+ }
66
+
67
+ var _d = state[slotName],
68
+ children = _d.children,
69
+ asProp = _d.as,
70
+ rest = tslib_1.__rest(_d, ["children", "as"]);
71
+
72
+ var slot = ((_a = state.components) === null || _a === void 0 ? void 0 : _a[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_b = state.components) === null || _b === void 0 ? void 0 : _b[slotName]) || 'div' : state.components[slotName];
73
+
74
+ if (typeof children === 'function') {
75
+ var render = children;
76
+ return [React.Fragment, {
77
+ children: render(slot, rest)
78
+ }];
79
+ }
80
+
81
+ var shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
82
+ var slotProps = shouldOmitAsProp ? omit_1.omit(state[slotName], ['as']) : state[slotName];
83
+ return [slot, slotProps];
84
+ }
85
+ //# sourceMappingURL=getSlots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":";;;;;;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Slots';
2
+ export * from './nullRender';
3
+ export * from './resolveShorthand';
4
+ export * from './types';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./getSlots"), exports);
10
+
11
+ tslib_1.__exportStar(require("./nullRender"), exports);
12
+
13
+ tslib_1.__exportStar(require("./resolveShorthand"), exports);
14
+
15
+ tslib_1.__exportStar(require("./types"), exports);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compose/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Simple constant function for returning null, used to render empty templates in JSX.
3
+ */
4
+ export declare const nullRender: () => null;
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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":""}
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveShorthand = void 0;
7
+
8
+ var tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ var react_1 = /*#__PURE__*/require("react");
11
+ /**
12
+ * Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
13
+ * being passed down to getSlots method
14
+ * @param value - the base ShorthandProps
15
+ * @param options - options to resolve ShorthandProps
16
+ */
17
+
18
+
19
+ function resolveShorthand(value, options) {
20
+ var _a = options || {},
21
+ _b = _a.required,
22
+ required = _b === void 0 ? false : _b,
23
+ defaultProps = _a.defaultProps;
24
+
25
+ if (value === null || value === undefined && !required) {
26
+ return undefined;
27
+ }
28
+
29
+ var resolvedShorthand = {};
30
+
31
+ if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || react_1.isValidElement(value)) {
32
+ resolvedShorthand.children = value;
33
+ } else if (typeof value === 'object') {
34
+ resolvedShorthand = value;
35
+ }
36
+
37
+ return defaultProps ? tslib_1.__assign(tslib_1.__assign({}, defaultProps), resolvedShorthand) : resolvedShorthand;
38
+ }
39
+
40
+ exports.resolveShorthand = resolveShorthand;
41
+ //# sourceMappingURL=resolveShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AASA;;;;;AAKG;;;AACH,SAAgB,gBAAhB,CACE,KADF,EAEE,OAFF,EAEoD;AAE5C,MAAA,EAAA,GAAqC,OAAO,IAAI,EAAhD;AAAA,MAAE,EAAA,GAAA,EAAA,CAAA,QAAF;AAAA,MAAE,QAAQ,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,KAAH,GAAQ,EAAlB;AAAA,MAAoB,YAAY,GAAA,EAAA,CAAA,YAAhC;;AACN,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,IAAkF,OAAA,CAAA,cAAA,CAAe,KAAf,CAAtF,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,SAAQ,YAAY,GAAE,OAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,EAAM,YAAN,CAAA,EAAuB,iBAAvB,CAAF,GAA+C,iBAAnE;AAGD;;AApBD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourceRoot":""}
@@ -0,0 +1,104 @@
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 {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ }); // A definition like this would also work, but typescript is more likely to unnecessarily expand
6
+ // the props type with this version (and it's likely much more expensive to evaluate)
7
+ // export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>
8
+ // ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>
9
+ // : never;
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":";;;;IA2IA;AACA;AACA;AACA;AACA","sourceRoot":""}
@@ -0,0 +1,16 @@
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';