@fluentui/react-utilities 0.0.0-nightlyff78d1e27a20220217.1 → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/CHANGELOG.json +232 -7
  2. package/CHANGELOG.md +159 -73
  3. package/dist/{react-utilities.d.ts → index.d.ts} +39 -272
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/compose/getSlots.js.map +1 -1
  6. package/lib/compose/resolveShorthand.js.map +1 -1
  7. package/lib/compose/types.js +1 -5
  8. package/lib/compose/types.js.map +1 -1
  9. package/lib/hooks/index.js +1 -5
  10. package/lib/hooks/index.js.map +1 -1
  11. package/lib/hooks/useControllableState.js +3 -2
  12. package/lib/hooks/useControllableState.js.map +1 -1
  13. package/lib/hooks/useEventCallback.js +1 -0
  14. package/lib/hooks/useEventCallback.js.map +1 -1
  15. package/lib/hooks/useFirstMount.js +1 -0
  16. package/lib/hooks/useFirstMount.js.map +1 -1
  17. package/lib/hooks/useForceUpdate.js +1 -0
  18. package/lib/hooks/useForceUpdate.js.map +1 -1
  19. package/lib/hooks/useId.js +9 -5
  20. package/lib/hooks/useId.js.map +1 -1
  21. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -0
  22. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  23. package/lib/hooks/useMergedEventCallbacks.js +1 -0
  24. package/lib/hooks/useMergedEventCallbacks.js.map +1 -1
  25. package/lib/hooks/useMergedRefs.js +1 -0
  26. package/lib/hooks/useMergedRefs.js.map +1 -1
  27. package/lib/hooks/useOnClickOutside.js +2 -1
  28. package/lib/hooks/useOnClickOutside.js.map +1 -1
  29. package/lib/hooks/useOnScrollOutside.js +1 -0
  30. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  31. package/lib/hooks/usePrevious.js +4 -0
  32. package/lib/hooks/usePrevious.js.map +1 -1
  33. package/lib/hooks/useTimeout.js +2 -2
  34. package/lib/hooks/useTimeout.js.map +1 -1
  35. package/lib/index.js +5 -4
  36. package/lib/index.js.map +1 -1
  37. package/lib/ssr/SSRContext.js.map +1 -1
  38. package/lib/ssr/canUseDOM.js.map +1 -1
  39. package/lib/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  40. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -0
  41. package/lib/{utils → trigger}/getTriggerChild.js +2 -0
  42. package/lib/trigger/getTriggerChild.js.map +1 -0
  43. package/lib/trigger/index.js +5 -0
  44. package/lib/trigger/index.js.map +1 -0
  45. package/lib/{utils → trigger}/isFluentTrigger.js +0 -0
  46. package/lib/trigger/isFluentTrigger.js.map +1 -0
  47. package/lib/trigger/types.js +2 -0
  48. package/lib/trigger/types.js.map +1 -0
  49. package/lib/utils/clamp.js +1 -0
  50. package/lib/utils/clamp.js.map +1 -1
  51. package/lib/utils/getNativeElementProps.js +4 -2
  52. package/lib/utils/getNativeElementProps.js.map +1 -1
  53. package/lib/utils/getRTLSafeKey.js +1 -0
  54. package/lib/utils/getRTLSafeKey.js.map +1 -1
  55. package/lib/utils/getReactCallbackName.js.map +1 -1
  56. package/lib/utils/index.js +0 -3
  57. package/lib/utils/index.js.map +1 -1
  58. package/lib/utils/omit.js.map +1 -1
  59. package/lib/utils/properties.js +18 -6
  60. package/lib/utils/properties.js.map +1 -1
  61. package/lib/utils/shouldPreventDefaultOnKeyDown.js +5 -0
  62. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  63. package/lib-commonjs/compose/getSlots.js.map +1 -1
  64. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  65. package/lib-commonjs/compose/types.js +1 -5
  66. package/lib-commonjs/compose/types.js.map +1 -1
  67. package/lib-commonjs/hooks/index.js +2 -10
  68. package/lib-commonjs/hooks/index.js.map +1 -1
  69. package/lib-commonjs/hooks/useControllableState.js +3 -3
  70. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  71. package/lib-commonjs/hooks/useEventCallback.js +1 -0
  72. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  73. package/lib-commonjs/hooks/useFirstMount.js +1 -0
  74. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  75. package/lib-commonjs/hooks/useForceUpdate.js +1 -0
  76. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  77. package/lib-commonjs/hooks/useId.js +9 -5
  78. package/lib-commonjs/hooks/useId.js.map +1 -1
  79. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -0
  80. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  81. package/lib-commonjs/hooks/useMergedEventCallbacks.js +1 -0
  82. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -1
  83. package/lib-commonjs/hooks/useMergedRefs.js +1 -0
  84. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  85. package/lib-commonjs/hooks/useOnClickOutside.js +2 -1
  86. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  87. package/lib-commonjs/hooks/useOnScrollOutside.js +1 -0
  88. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  89. package/lib-commonjs/hooks/usePrevious.js +4 -0
  90. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  91. package/lib-commonjs/hooks/useTimeout.js +2 -3
  92. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  93. package/lib-commonjs/index.js +161 -5
  94. package/lib-commonjs/index.js.map +1 -1
  95. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  96. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  97. package/lib-commonjs/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  98. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -0
  99. package/lib-commonjs/{utils → trigger}/getTriggerChild.js +2 -0
  100. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -0
  101. package/lib-commonjs/trigger/index.js +16 -0
  102. package/lib-commonjs/trigger/index.js.map +1 -0
  103. package/lib-commonjs/{utils → trigger}/isFluentTrigger.js +0 -0
  104. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -0
  105. package/lib-commonjs/trigger/types.js +6 -0
  106. package/lib-commonjs/trigger/types.js.map +1 -0
  107. package/lib-commonjs/utils/clamp.js +1 -0
  108. package/lib-commonjs/utils/clamp.js.map +1 -1
  109. package/lib-commonjs/utils/getNativeElementProps.js +3 -1
  110. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  111. package/lib-commonjs/utils/getRTLSafeKey.js +1 -0
  112. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  113. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  114. package/lib-commonjs/utils/index.js +0 -6
  115. package/lib-commonjs/utils/index.js.map +1 -1
  116. package/lib-commonjs/utils/omit.js.map +1 -1
  117. package/lib-commonjs/utils/properties.js +19 -7
  118. package/lib-commonjs/utils/properties.js.map +1 -1
  119. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +5 -0
  120. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  121. package/package.json +13 -13
  122. package/lib/compose/getSlots.d.ts +0 -30
  123. package/lib/compose/index.d.ts +0 -3
  124. package/lib/compose/resolveShorthand.d.ts +0 -16
  125. package/lib/compose/types.d.ts +0 -155
  126. package/lib/hooks/index.d.ts +0 -16
  127. package/lib/hooks/useBoolean.d.ts +0 -17
  128. package/lib/hooks/useBoolean.js +0 -28
  129. package/lib/hooks/useBoolean.js.map +0 -1
  130. package/lib/hooks/useConst.d.ts +0 -12
  131. package/lib/hooks/useConst.js +0 -30
  132. package/lib/hooks/useConst.js.map +0 -1
  133. package/lib/hooks/useControllableState.d.ts +0 -31
  134. package/lib/hooks/useEventCallback.d.ts +0 -13
  135. package/lib/hooks/useFirstMount.d.ts +0 -11
  136. package/lib/hooks/useForceUpdate.d.ts +0 -4
  137. package/lib/hooks/useId.d.ts +0 -15
  138. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  139. package/lib/hooks/useMergedEventCallbacks.d.ts +0 -18
  140. package/lib/hooks/useMergedRefs.d.ts +0 -13
  141. package/lib/hooks/useMount.d.ts +0 -6
  142. package/lib/hooks/useMount.js +0 -17
  143. package/lib/hooks/useMount.js.map +0 -1
  144. package/lib/hooks/useOnClickOutside.d.ts +0 -29
  145. package/lib/hooks/useOnScrollOutside.d.ts +0 -5
  146. package/lib/hooks/usePrevious.d.ts +0 -1
  147. package/lib/hooks/useTimeout.d.ts +0 -8
  148. package/lib/hooks/useUnmount.d.ts +0 -6
  149. package/lib/hooks/useUnmount.js +0 -17
  150. package/lib/hooks/useUnmount.js.map +0 -1
  151. package/lib/index.d.ts +0 -4
  152. package/lib/ssr/SSRContext.d.ts +0 -33
  153. package/lib/ssr/canUseDOM.d.ts +0 -4
  154. package/lib/ssr/index.d.ts +0 -2
  155. package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
  156. package/lib/utils/applyTriggerPropsToChildren.js.map +0 -1
  157. package/lib/utils/clamp.d.ts +0 -8
  158. package/lib/utils/getNativeElementProps.d.ts +0 -31
  159. package/lib/utils/getRTLSafeKey.d.ts +0 -4
  160. package/lib/utils/getReactCallbackName.d.ts +0 -25
  161. package/lib/utils/getTriggerChild.d.ts +0 -22
  162. package/lib/utils/getTriggerChild.js.map +0 -1
  163. package/lib/utils/index.d.ts +0 -9
  164. package/lib/utils/isFluentTrigger.d.ts +0 -22
  165. package/lib/utils/isFluentTrigger.js.map +0 -1
  166. package/lib/utils/omit.d.ts +0 -14
  167. package/lib/utils/properties.d.ts +0 -148
  168. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
  169. package/lib-commonjs/compose/getSlots.d.ts +0 -30
  170. package/lib-commonjs/compose/index.d.ts +0 -3
  171. package/lib-commonjs/compose/resolveShorthand.d.ts +0 -16
  172. package/lib-commonjs/compose/types.d.ts +0 -155
  173. package/lib-commonjs/hooks/index.d.ts +0 -16
  174. package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
  175. package/lib-commonjs/hooks/useBoolean.js +0 -39
  176. package/lib-commonjs/hooks/useBoolean.js.map +0 -1
  177. package/lib-commonjs/hooks/useConst.d.ts +0 -12
  178. package/lib-commonjs/hooks/useConst.js +0 -40
  179. package/lib-commonjs/hooks/useConst.js.map +0 -1
  180. package/lib-commonjs/hooks/useControllableState.d.ts +0 -31
  181. package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
  182. package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
  183. package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
  184. package/lib-commonjs/hooks/useId.d.ts +0 -15
  185. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  186. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +0 -18
  187. package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
  188. package/lib-commonjs/hooks/useMount.d.ts +0 -6
  189. package/lib-commonjs/hooks/useMount.js +0 -27
  190. package/lib-commonjs/hooks/useMount.js.map +0 -1
  191. package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
  192. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
  193. package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
  194. package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
  195. package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
  196. package/lib-commonjs/hooks/useUnmount.js +0 -27
  197. package/lib-commonjs/hooks/useUnmount.js.map +0 -1
  198. package/lib-commonjs/index.d.ts +0 -4
  199. package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
  200. package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
  201. package/lib-commonjs/ssr/index.d.ts +0 -2
  202. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
  203. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +0 -1
  204. package/lib-commonjs/utils/clamp.d.ts +0 -8
  205. package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -31
  206. package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
  207. package/lib-commonjs/utils/getReactCallbackName.d.ts +0 -25
  208. package/lib-commonjs/utils/getTriggerChild.d.ts +0 -22
  209. package/lib-commonjs/utils/getTriggerChild.js.map +0 -1
  210. package/lib-commonjs/utils/index.d.ts +0 -9
  211. package/lib-commonjs/utils/isFluentTrigger.d.ts +0 -22
  212. package/lib-commonjs/utils/isFluentTrigger.js.map +0 -1
  213. package/lib-commonjs/utils/omit.d.ts +0 -14
  214. package/lib-commonjs/utils/properties.d.ts +0 -148
  215. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getNativeProps = exports.divProperties = exports.imageProperties = exports.imgProperties = exports.iframeProperties = exports.formProperties = exports.colProperties = exports.colGroupProperties = exports.tdProperties = exports.thProperties = exports.trProperties = exports.tableProperties = exports.optionProperties = exports.selectProperties = exports.textAreaProperties = exports.inputProperties = exports.buttonProperties = exports.anchorProperties = exports.liProperties = exports.olProperties = exports.videoProperties = exports.audioProperties = exports.labelProperties = exports.htmlElementProperties = exports.baseElementProperties = exports.baseElementEvents = void 0;
6
+ exports.getNativeProps = exports.divProperties = exports.imgProperties = exports.iframeProperties = exports.formProperties = exports.fieldsetProperties = exports.colProperties = exports.colGroupProperties = exports.tdProperties = exports.thProperties = exports.trProperties = exports.tableProperties = exports.optionProperties = exports.selectProperties = exports.textAreaProperties = exports.inputProperties = exports.buttonProperties = exports.timeProperties = exports.anchorProperties = exports.liProperties = exports.olProperties = exports.videoProperties = exports.audioProperties = exports.labelProperties = exports.htmlElementProperties = exports.baseElementProperties = exports.baseElementEvents = void 0;
7
7
 
8
8
  const toObjectMap = (...items) => {
9
9
  const result = {};
@@ -89,6 +89,14 @@ exports.liProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, [
89
89
 
90
90
  exports.anchorProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, ['download', 'href', 'hrefLang', 'media', 'rel', 'target', 'type' // a, button, input, link, menu, object, script, source, style
91
91
  ]);
92
+ /**
93
+ * An array of TIME tag properties and events.
94
+ *
95
+ * @public
96
+ */
97
+
98
+ exports.timeProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, ['dateTime' // time
99
+ ]);
92
100
  /**
93
101
  * An array of BUTTON tag properties and events.
94
102
  *
@@ -158,6 +166,14 @@ exports.colGroupProperties = /*#__PURE__*/toObjectMap(exports.htmlElementPropert
158
166
  ]);
159
167
  exports.colProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, ['span' // col, colgroup
160
168
  ]);
169
+ /**
170
+ * An array of FIELDSET tag properties and events.
171
+ *
172
+ * @public
173
+ */
174
+
175
+ exports.fieldsetProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, ['disabled', 'form' // button, fieldset, input, label, meter, object, output, select, textarea
176
+ ]);
161
177
  /**
162
178
  * An array of FORM tag properties and events.
163
179
  *
@@ -182,11 +198,6 @@ exports.iframeProperties = /*#__PURE__*/toObjectMap(exports.htmlElementPropertie
182
198
 
183
199
  exports.imgProperties = /*#__PURE__*/toObjectMap(exports.htmlElementProperties, ['alt', 'crossOrigin', 'height', 'src', 'srcSet', 'useMap', 'width' // canvas, embed, iframe, img, input, object, video
184
200
  ]);
185
- /**
186
- * @deprecated Use imgProperties for img elements.
187
- */
188
-
189
- exports.imageProperties = exports.imgProperties;
190
201
  /**
191
202
  * An array of DIV tag properties and events.
192
203
  *
@@ -205,7 +216,8 @@ exports.divProperties = exports.htmlElementProperties;
205
216
  *
206
217
  * @public
207
218
  * @param props - The unfiltered input props
208
- * @param allowedPropsNames - The array or record of allowed prop names.
219
+ * @param allowedPropNames - The array or record of allowed prop names.
220
+ * @param excludedPropNames
209
221
  * @returns The filtered props
210
222
  */
211
223
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@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A,SAAgB,cAAhB,EACE;AACA,KAFF,EAGE,gBAHF,EAIE,iBAJF,EAI8B;AAE5B;AACA;AACA;AACA;AACA;AAEA,QAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,gBAAd,CAAhB,CAR4B,CAS5B;;AACA,QAAM,MAAM,GAAwB,EAApC;AACA,QAAM,IAAI,GAAG,MAAM,CAAC,IAAP,CAAY,KAAZ,CAAb;;AAEA,OAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;AACtB,UAAM,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;;AA/BD,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * @deprecated Use imgProperties for img elements.\n */\nexport const imageProperties = imgProperties;\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropsNames - The array or record of allowed prop names.\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/properties.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAM,WAAW,GAAG,CAAC,GAAG,KAAJ,KAAoD;EACtE,MAAM,MAAM,GAA2B,EAAvC;;EAEA,KAAK,MAAM,IAAX,IAAmB,KAAnB,EAA0B;IACxB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAN,CAAc,IAAd,IAAsB,IAAtB,GAA6B,MAAM,CA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;EACA;EACA;EACA;EACA;EAEA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,gBAAd,CAAhB,CAR4B,CAS5B;;EACA,MAAM,MAAM,GAAwB,EAApC;EACA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAP,CAAY,KAAZ,CAAb;;EAEA,KAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;IACtB,MAAM,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;;IAMA,IAAI,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;MAClF;MACA,MAAM,CAAC,GAAD,CAAN,GAAc,KAAM,CAAC,GAAD,CAApB;IACD;EACF;;EAED,OAAO,MAAP;AACD;;AA/BD,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of TIME tag properties and events.\n *\n * @public\n */\nexport const timeProperties = toObjectMap(htmlElementProperties, [\n 'dateTime', // time\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FIELDSET tag properties and events.\n *\n * @public\n */\nexport const fieldsetProperties = toObjectMap(htmlElementProperties, [\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropNames - The array or record of allowed prop names.\n * @param excludedPropNames\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"],"sourceRoot":"../src/"}
@@ -7,6 +7,7 @@ exports.shouldPreventDefaultOnKeyDown = void 0;
7
7
 
8
8
  const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
9
9
  /**
10
+ * @internal
10
11
  * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
11
12
  *
12
13
  * Useful for situations where a keydown needs to be transformed to a click event
@@ -14,6 +15,10 @@ const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
14
15
 
15
16
 
16
17
  function shouldPreventDefaultOnKeyDown(e) {
18
+ if (e.defaultPrevented) {
19
+ return false;
20
+ }
21
+
17
22
  const key = e.key;
18
23
  const target = e.target;
19
24
  const matchesByKey = key === keyboard_keys_1.Space || key === keyboard_keys_1.Enter;
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/shouldPreventDefaultOnKeyDown.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAGA;;;;AAIG;;;AACH,SAAgB,6BAAhB,CAA8C,CAA9C,EAAoF;AAClF,QAAM,GAAG,GAAG,CAAC,CAAC,GAAd;AACA,QAAM,MAAM,GAA4B,CAAC,CAAC,MAA1C;AAEA,QAAM,YAAY,GAAG,GAAG,KAAK,eAAA,CAAA,KAAR,IAAiB,GAAG,KAAK,eAAA,CAAA,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,eAAA,CAAA,KAAf;AACD;;AAED,QAAM,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;;AAdD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourcesContent":["import { Space, Enter } from '@fluentui/keyboard-keys';\nimport * as React from 'react';\n\n/**\n * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys\n *\n * Useful for situations where a keydown needs to be transformed to a click event\n */\nexport function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent) {\n const key = e.key;\n const target: HTMLElement | undefined = e.target as HTMLElement;\n\n const matchesByKey = key === Space || key === Enter;\n\n if (target?.tagName === 'A') {\n return key === Space;\n }\n\n const ignoredByTag =\n target?.tagName === 'INPUT' || target?.tagName === 'TEXTAREA' || target?.isContentEditable === true;\n\n return matchesByKey && !ignoredByTag;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/shouldPreventDefaultOnKeyDown.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAGA;;;;;AAKG;;;AACH,SAAgB,6BAAhB,CAA8C,CAA9C,EAAoF;EAClF,IAAI,CAAC,CAAC,gBAAN,EAAwB;IACtB,OAAO,KAAP;EACD;;EAED,MAAM,GAAG,GAAG,CAAC,CAAC,GAAd;EACA,MAAM,MAAM,GAA4B,CAAC,CAAC,MAA1C;EAEA,MAAM,YAAY,GAAG,GAAG,KAAK,eAAA,CAAA,KAAR,IAAiB,GAAG,KAAK,eAAA,CAAA,KAA9C;;EAEA,IAAI,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,GAAxB,EAA6B;IAC3B,OAAO,GAAG,KAAK,eAAA,CAAA,KAAf;EACD;;EAED,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;EAGA,OAAO,YAAY,IAAI,CAAC,YAAxB;AACD;;AAlBD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourcesContent":["import { Space, Enter } from '@fluentui/keyboard-keys';\nimport * as React from 'react';\n\n/**\n * @internal\n * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys\n *\n * Useful for situations where a keydown needs to be transformed to a click event\n */\nexport function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent) {\n if (e.defaultPrevented) {\n return false;\n }\n\n const key = e.key;\n const target: HTMLElement | undefined = e.target as HTMLElement;\n\n const matchesByKey = key === Space || key === Enter;\n\n if (target?.tagName === 'A') {\n return key === Space;\n }\n\n const ignoredByTag =\n target?.tagName === 'INPUT' || target?.tagName === 'TEXTAREA' || target?.isContentEditable === true;\n\n return matchesByKey && !ignoredByTag;\n}\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fluentui/react-utilities",
3
- "version": "0.0.0-nightlyff78d1e27a20220217.1",
3
+ "version": "0.0.0",
4
4
  "description": "A set of general React-specific utilities.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
7
- "typings": "lib/index.d.ts",
7
+ "typings": "dist/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
@@ -20,20 +20,15 @@
20
20
  "lint": "just-scripts lint",
21
21
  "test": "jest --passWithNoTests",
22
22
  "docs": "api-extractor run --config=config/api-extractor.local.json --local",
23
- "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-utilities/src && yarn docs",
24
- "start": "yarn storybook",
23
+ "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-utilities/src && yarn docs",
25
24
  "type-check": "tsc -b tsconfig.json"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@fluentui/eslint-plugin": "*",
29
- "@fluentui/scripts": "^1.0.0",
30
- "@types/react": "16.9.42",
31
- "@types/react-test-renderer": "^16.0.0",
32
- "react": "16.8.6",
33
- "react-test-renderer": "^16.3.0"
28
+ "@fluentui/scripts": "^1.0.0"
34
29
  },
35
30
  "dependencies": {
36
- "@fluentui/keyboard-keys": "0.0.0-nightlyff78d1e27a20220217.1",
31
+ "@fluentui/keyboard-keys": "^0.0.0",
37
32
  "tslib": "^2.1.0"
38
33
  },
39
34
  "peerDependencies": {
@@ -42,9 +37,14 @@
42
37
  },
43
38
  "beachball": {
44
39
  "disallowedChangeTypes": [
45
- "major",
46
- "minor",
47
- "patch"
40
+ "major"
48
41
  ]
42
+ },
43
+ "exports": {
44
+ ".": {
45
+ "types": "./lib/index.d.ts",
46
+ "import": "./lib/index.js",
47
+ "require": "./lib-commonjs/index.js"
48
+ }
49
49
  }
50
50
  }
@@ -1,30 +0,0 @@
1
- import * as React from 'react';
2
- import type { AsIntrinsicElement, ComponentState, ExtractSlotProps, SlotPropsRecord, UnionToIntersection } from './types';
3
- export declare type Slots<S extends SlotPropsRecord> = {
4
- [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? As : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<ExtractSlotProps<S[K]>>;
5
- };
6
- declare type ObjectSlotProps<S extends SlotPropsRecord> = {
7
- [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? P : never;
8
- };
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 to the slot type by the type system.
19
- * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
20
- * anchor props. Note that this is only enforced at build time by Typescript -- there is no
21
- * runtime code filtering props in this function.
22
- *
23
- * @param state - State including slot definitions
24
- * @returns An object containing the `slots` map and `slotProps` map.
25
- */
26
- export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
27
- slots: Slots<R>;
28
- slotProps: ObjectSlotProps<R>;
29
- };
30
- export {};
@@ -1,3 +0,0 @@
1
- export * from './getSlots';
2
- export * from './resolveShorthand';
3
- export * from './types';
@@ -1,16 +0,0 @@
1
- import type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';
2
- export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
3
- required?: Required;
4
- defaultProps?: Props;
5
- };
6
- export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
7
- <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, true>): ReplaceNullWithUndefined<P>;
8
- <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>): ReplaceNullWithUndefined<P> | undefined;
9
- };
10
- /**
11
- * Resolves shorthands into slot props, to ensure normalization of the signature
12
- * being passed down to getSlots method
13
- * @param value - the base shorthand props
14
- * @param options - options to resolve shorthand props
15
- */
16
- export declare const resolveShorthand: ResolveShorthandFunction;
@@ -1,155 +0,0 @@
1
- import * as React from 'react';
2
- export declare type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
3
- /**
4
- * Matches any component's Slots type (such as ButtonSlots).
5
- *
6
- * This should ONLY be used in type templates as in `extends SlotPropsRecord`;
7
- * it shouldn't be used as a component's Slots type.
8
- */
9
- export declare type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
10
- /**
11
- * The shorthand value of a slot allows specifying its child
12
- */
13
- export declare type SlotShorthandValue = React.ReactChild | React.ReactNodeArray | React.ReactPortal;
14
- /**
15
- * Matches any slot props type.
16
- *
17
- * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
18
- * it shouldn't be used as the type of a slot.
19
- */
20
- export declare type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
21
- as?: keyof JSX.IntrinsicElements;
22
- };
23
- /**
24
- * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.
25
- */
26
- declare type WithSlotShorthandValue<Props extends {
27
- children?: unknown;
28
- }> = Props | Extract<SlotShorthandValue, Props['children']>;
29
- /**
30
- * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
31
- * to be a render function that takes those props.
32
- */
33
- declare type WithSlotRenderFunction<Props extends {
34
- children?: unknown;
35
- }> = Props & {
36
- children?: Props['children'] | SlotRenderFunction<Props>;
37
- };
38
- /**
39
- * HTML element types that are not allowed to have children.
40
- *
41
- * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
42
- */
43
- declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
44
- /**
45
- * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
46
- * * Removes legacy string ref.
47
- * * Disallows children for empty tags like 'img'.
48
- */
49
- declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React.PropsWithRef<JSX.IntrinsicElements[Type]> & (Type extends EmptyIntrisicElements ? {
50
- children?: never;
51
- } : {});
52
- /**
53
- * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,
54
- * or a component like `typeof Button`.
55
- *
56
- * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).
57
- *
58
- * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,
59
- * wrap with `NonNullable` (see examples below).
60
- *
61
- * @example
62
- * ```
63
- * // Intrinsic element examples:
64
- * Slot<'div'> // Slot is always div
65
- * Slot<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
66
- * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as="div" or as="pre"
67
- * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)
68
- *
69
- * // Component examples:
70
- * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props
71
- * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
72
- * ```
73
- */
74
- export declare type Slot<Type extends keyof JSX.IntrinsicElements | React.ComponentType | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
75
- as?: Type;
76
- } & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
77
- [As in AlternateAs]: {
78
- as: As;
79
- } & WithSlotRenderFunction<IntrisicElementProps<As>>;
80
- }[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
81
- /**
82
- * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
83
- *
84
- * ```
85
- * IsSingleton<'a'> // true
86
- * IsSingleton<'a' | 'b' | 'c'> // false
87
- * ```
88
- */
89
- export declare type IsSingleton<T extends string> = {
90
- [K in T]: Exclude<T, K> extends never ? true : false;
91
- }[T];
92
- /**
93
- * Helper type for inferring the type of the as prop from a Props type.
94
- *
95
- * For example:
96
- * ```
97
- * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
98
- * ```
99
- */
100
- export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
101
- as?: As;
102
- };
103
- /**
104
- * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)
105
- */
106
- export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
107
- /**
108
- * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
109
- * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
110
- *
111
- * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
112
- * types, to prevent unions from being expanded.
113
- */
114
- export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
115
- /**
116
- * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.
117
- */
118
- export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
119
- /**
120
- * Defines the Props type for a component given its slots and the definition of which one is the primary slot,
121
- * defaulting to root if one is not provided.
122
- */
123
- export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<Slots, Primary & 'root'> & PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;
124
- /**
125
- * If type T includes `null`, remove it and add `undefined` instead.
126
- */
127
- export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
128
- /**
129
- * Defines the State object of a component given its slots.
130
- */
131
- export declare type ComponentState<Slots extends SlotPropsRecord> = {
132
- components: {
133
- [Key in keyof Slots]-?: React.ComponentType<ExtractSlotProps<Slots[Key]>> | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
134
- };
135
- } & {
136
- [Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
137
- };
138
- /**
139
- * This is part of a hack to infer the element type from a native element *props* type.
140
- * The only place the original element is found in a native props type (at least that's workable
141
- * for inference) is in the event handlers, so some of the helper types use this event handler
142
- * name to infer the original element type.
143
- *
144
- * Notes:
145
- * - Using an extremely obscure event handler reduces the likelihood that its signature will be
146
- * modified in any component's props.
147
- * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be
148
- * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.
149
- */
150
- declare type ObscureEventName = 'onLostPointerCaptureCapture';
151
- /**
152
- * Return type for `React.forwardRef`, including inference of the proper typing for the ref.
153
- */
154
- 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;
155
- export {};
@@ -1,16 +0,0 @@
1
- export * from './useControllableState';
2
- export * from './useBoolean';
3
- export * from './useConst';
4
- export * from './useEventCallback';
5
- export * from './useFirstMount';
6
- export * from './useId';
7
- export * from './useIsomorphicLayoutEffect';
8
- export * from './useMergedEventCallbacks';
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,28 +0,0 @@
1
- import * as React from 'react';
2
- import { useConst } from './useConst';
3
- /**
4
- * Hook to store a value and generate callbacks for setting the value to true or false.
5
- * The identity of the callbacks will always stay the same.
6
- *
7
- * @param initialState - Initial value
8
- * @returns Array with the current value and an object containing the updater callbacks.
9
- */
10
-
11
- export function useBoolean(initialState) {
12
- const [value, setValue] = React.useState(initialState);
13
- const setTrue = useConst(() => () => {
14
- setValue(true);
15
- });
16
- const setFalse = useConst(() => () => {
17
- setValue(false);
18
- });
19
- const toggle = useConst(() => () => {
20
- setValue(currentValue => !currentValue);
21
- });
22
- return [value, {
23
- setTrue,
24
- setFalse,
25
- toggle
26
- }];
27
- }
28
- //# sourceMappingURL=useBoolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;AAYA;;;;;;AAMG;;AACH,OAAM,SAAU,UAAV,CAAqB,YAArB,EAA0C;AAC9C,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,QAAN,CAAe,YAAf,CAA1B;AAEA,QAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,MAAK;AAClC,IAAA,QAAQ,CAAC,IAAD,CAAR;AACD,GAFuB,CAAxB;AAGA,QAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,MAAK;AACnC,IAAA,QAAQ,CAAC,KAAD,CAAR;AACD,GAFwB,CAAzB;AAGA,QAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,MAAK;AACjC,IAAA,QAAQ,CAAC,YAAY,IAAI,CAAC,YAAlB,CAAR;AACD,GAFsB,CAAvB;AAIA,SAAO,CAAC,KAAD,EAAQ;AAAE,IAAA,OAAF;AAAW,IAAA,QAAX;AAAqB,IAAA;AAArB,GAAR,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useConst } from './useConst';\n\n/** Updater callbacks returned by `useBoolean`. */\nexport type UseBooleanCallbacks = {\n /** Set the value to true. Always has the same identity. */\n setTrue: () => void;\n /** Set the value to false. Always has the same identity. */\n setFalse: () => void;\n /** Toggle the value. Always has the same identity. */\n toggle: () => void;\n};\n\n/**\n * Hook to store a value and generate callbacks for setting the value to true or false.\n * The identity of the callbacks will always stay the same.\n *\n * @param initialState - Initial value\n * @returns Array with the current value and an object containing the updater callbacks.\n */\nexport function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks] {\n const [value, setValue] = React.useState(initialState);\n\n const setTrue = useConst(() => () => {\n setValue(true);\n });\n const setFalse = useConst(() => () => {\n setValue(false);\n });\n const toggle = useConst(() => () => {\n setValue(currentValue => !currentValue);\n });\n\n return [value, { setTrue, setFalse, toggle }];\n}\n"],"sourceRoot":"../src/"}
@@ -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,30 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
4
- * always return the same value (and if the initializer is a function, only call it once).
5
- * This is similar to setting a private member in a class constructor.
6
- *
7
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
8
- *
9
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
10
- * only the value/function passed in the first time this is called is respected.
11
- * @returns The value. The identity of this value will always be the same.
12
- */
13
-
14
- export function useConst(initialValue) {
15
- // Use useRef to store the value because it's the least expensive built-in hook that works here
16
- // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive
17
- // internally due to reducer handling which we don't need)
18
- const ref = React.useRef();
19
-
20
- if (ref.current === undefined) {
21
- // Box the value in an object so we can tell if it's initialized even if the initializer
22
- // returns/is undefined
23
- ref.current = {
24
- value: typeof initialValue === 'function' ? initialValue() : initialValue
25
- };
26
- }
27
-
28
- return ref.current.value;
29
- }
30
- //# sourceMappingURL=useConst.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useConst.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;;;;;;;AAUG;;AACH,OAAM,SAAU,QAAV,CAAsB,YAAtB,EAAiD;AACrD;AACA;AACA;AACA,QAAM,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","sourcesContent":["import * as React from 'react';\n\n/**\n * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to\n * always return the same value (and if the initializer is a function, only call it once).\n * This is similar to setting a private member in a class constructor.\n *\n * If the value should ever change based on dependencies, use `React.useMemo` instead.\n *\n * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,\n * only the value/function passed in the first time this is called is respected.\n * @returns The value. The identity of this value will always be the same.\n */\nexport function useConst<T>(initialValue: T | (() => T)): T {\n // Use useRef to store the value because it's the least expensive built-in hook that works here\n // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive\n // internally due to reducer handling which we don't need)\n const ref = React.useRef<{ value: T }>();\n if (ref.current === undefined) {\n // Box the value in an object so we can tell if it's initialized even if the initializer\n // returns/is undefined\n ref.current = {\n value: typeof initialValue === 'function' ? (initialValue as Function)() : initialValue,\n };\n }\n return ref.current.value;\n}\n"],"sourceRoot":"../src/"}
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- export declare type UseControllableStateOptions<State> = {
3
- /**
4
- * User-provided default state or initializer, for uncontrolled usage.
5
- */
6
- defaultState?: State | (() => State);
7
- /**
8
- * User-provided controlled state. `undefined` means internal state will be used.
9
- */
10
- state: State | undefined;
11
- /**
12
- * Used as the initial state if `state` and `defaultState` are both `undefined`.
13
- * If `undefined` is the correct initial state, pass that here.
14
- */
15
- initialState: State;
16
- };
17
- /**
18
- * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
19
- * such as a checked state or text input string.
20
- *
21
- * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
22
- * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
23
- *
24
- * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
25
- * of the current value and an updater (dispatch) function. The updater function is referentially
26
- * stable (won't change during the component's lifecycle). It can take either a new value, or a
27
- * function which is passed the previous value and returns the new value. Unlike `setState`, calls
28
- * to the updater function will only be respected if the component is uncontrolled.
29
- * @see https://reactjs.org/docs/uncontrolled-components.html
30
- */
31
- export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React.Dispatch<React.SetStateAction<State>>];
@@ -1,13 +0,0 @@
1
- /**
2
- * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
3
- *
4
- * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
5
- * e.g. user props are dependencies which could change on every render
6
- * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
7
- *
8
- * This should not be used often, but can be a useful re-render optimization since the callback is a ref and
9
- * will not be invalidated between re-renders
10
- *
11
- * @param fn - The callback function that will be used
12
- */
13
- export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return;