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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/CHANGELOG.json +1132 -1
  2. package/CHANGELOG.md +492 -2
  3. package/dist/react-utilities.d.ts +335 -67
  4. package/lib/compose/getSlots.d.ts +13 -4
  5. package/lib/compose/getSlots.js +44 -32
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.d.ts +1 -2
  8. package/lib/compose/index.js +2 -2
  9. package/lib/compose/index.js.map +1 -1
  10. package/lib/compose/nullRender.js +1 -1
  11. package/lib/compose/nullRender.js.map +1 -1
  12. package/lib/compose/resolveShorthand.d.ts +12 -0
  13. package/lib/compose/resolveShorthand.js +31 -0
  14. package/lib/compose/resolveShorthand.js.map +1 -0
  15. package/lib/compose/types.d.ts +95 -21
  16. package/lib/compose/types.js +5 -0
  17. package/lib/compose/types.js.map +1 -1
  18. package/lib/hooks/index.d.ts +9 -1
  19. package/lib/hooks/index.js +9 -1
  20. package/lib/hooks/index.js.map +1 -1
  21. package/lib/hooks/useBoolean.d.ts +2 -2
  22. package/lib/hooks/useBoolean.js +16 -11
  23. package/lib/hooks/useBoolean.js.map +1 -1
  24. package/lib/hooks/useConst.js +15 -12
  25. package/lib/hooks/useConst.js.map +1 -1
  26. package/lib/hooks/useControllableState.d.ts +21 -0
  27. package/lib/hooks/useControllableState.js +68 -0
  28. package/lib/hooks/useControllableState.js.map +1 -0
  29. package/lib/hooks/useControllableValue.js +47 -50
  30. package/lib/hooks/useControllableValue.js.map +1 -1
  31. package/lib/hooks/useEventCallback.d.ts +2 -2
  32. package/lib/hooks/useEventCallback.js +14 -17
  33. package/lib/hooks/useEventCallback.js.map +1 -1
  34. package/lib/hooks/useFirstMount.d.ts +11 -0
  35. package/lib/hooks/useFirstMount.js +23 -0
  36. package/lib/hooks/useFirstMount.js.map +1 -0
  37. package/lib/hooks/useForceUpdate.d.ts +4 -0
  38. package/lib/hooks/useForceUpdate.js +9 -0
  39. package/lib/hooks/useForceUpdate.js.map +1 -0
  40. package/lib/hooks/useId.d.ts +7 -3
  41. package/lib/hooks/useId.js +13 -17
  42. package/lib/hooks/useId.js.map +1 -1
  43. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +9 -0
  44. package/lib/hooks/useIsomorphicLayoutEffect.js +13 -4
  45. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  46. package/lib/hooks/useMergedRefs.js +16 -20
  47. package/lib/hooks/useMergedRefs.js.map +1 -1
  48. package/lib/hooks/useMount.d.ts +6 -0
  49. package/lib/hooks/useMount.js +17 -0
  50. package/lib/hooks/useMount.js.map +1 -0
  51. package/lib/hooks/useOnClickOutside.d.ts +14 -4
  52. package/lib/hooks/useOnClickOutside.js +129 -18
  53. package/lib/hooks/useOnClickOutside.js.map +1 -1
  54. package/lib/hooks/useOnScrollOutside.d.ts +5 -0
  55. package/lib/hooks/useOnScrollOutside.js +36 -0
  56. package/lib/hooks/useOnScrollOutside.js.map +1 -0
  57. package/lib/hooks/usePrevious.d.ts +1 -0
  58. package/lib/hooks/usePrevious.js +9 -0
  59. package/lib/hooks/usePrevious.js.map +1 -0
  60. package/lib/hooks/useTimeout.d.ts +8 -0
  61. package/lib/hooks/useTimeout.js +29 -0
  62. package/lib/hooks/useTimeout.js.map +1 -0
  63. package/lib/hooks/useUnmount.d.ts +6 -0
  64. package/lib/hooks/useUnmount.js +17 -0
  65. package/lib/hooks/useUnmount.js.map +1 -0
  66. package/lib/index.d.ts +1 -0
  67. package/lib/index.js +1 -0
  68. package/lib/index.js.map +1 -1
  69. package/lib/ssr/SSRContext.d.ts +33 -0
  70. package/lib/ssr/SSRContext.js +65 -0
  71. package/lib/ssr/SSRContext.js.map +1 -0
  72. package/lib/ssr/canUseDOM.d.ts +4 -0
  73. package/lib/ssr/canUseDOM.js +8 -0
  74. package/lib/ssr/canUseDOM.js.map +1 -0
  75. package/lib/ssr/index.d.ts +2 -0
  76. package/lib/ssr/index.js +3 -0
  77. package/lib/ssr/index.js.map +1 -0
  78. package/lib/tsdoc-metadata.json +1 -1
  79. package/lib/utils/applyTriggerPropsToChildren.d.ts +5 -0
  80. package/lib/utils/applyTriggerPropsToChildren.js +16 -0
  81. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -0
  82. package/lib/utils/clamp.d.ts +8 -0
  83. package/lib/utils/clamp.js +9 -0
  84. package/lib/utils/clamp.js.map +1 -0
  85. package/lib/utils/getNativeElementProps.d.ts +22 -0
  86. package/lib/utils/getNativeElementProps.js +48 -24
  87. package/lib/utils/getNativeElementProps.js.map +1 -1
  88. package/lib/utils/getRTLSafeKey.d.ts +4 -0
  89. package/lib/utils/getRTLSafeKey.js +21 -0
  90. package/lib/utils/getRTLSafeKey.js.map +1 -0
  91. package/lib/utils/index.d.ts +5 -0
  92. package/lib/utils/index.js +5 -0
  93. package/lib/utils/index.js.map +1 -1
  94. package/lib/utils/omit.d.ts +1 -1
  95. package/lib/utils/omit.js +9 -7
  96. package/lib/utils/omit.js.map +1 -1
  97. package/lib/utils/onlyChild.d.ts +5 -0
  98. package/lib/utils/onlyChild.js +13 -0
  99. package/lib/utils/onlyChild.js.map +1 -0
  100. package/lib/utils/properties.js +80 -282
  101. package/lib/utils/properties.js.map +1 -1
  102. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  103. package/lib/utils/shouldPreventDefaultOnKeyDown.js +20 -0
  104. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  105. package/lib-commonjs/compose/getSlots.d.ts +13 -4
  106. package/lib-commonjs/compose/getSlots.js +57 -35
  107. package/lib-commonjs/compose/getSlots.js.map +1 -1
  108. package/lib-commonjs/compose/index.d.ts +1 -2
  109. package/lib-commonjs/compose/index.js +12 -4
  110. package/lib-commonjs/compose/index.js.map +1 -1
  111. package/lib-commonjs/compose/nullRender.js +9 -2
  112. package/lib-commonjs/compose/nullRender.js.map +1 -1
  113. package/lib-commonjs/compose/resolveShorthand.d.ts +12 -0
  114. package/lib-commonjs/compose/resolveShorthand.js +41 -0
  115. package/lib-commonjs/compose/resolveShorthand.js.map +1 -0
  116. package/lib-commonjs/compose/types.d.ts +95 -21
  117. package/lib-commonjs/compose/types.js +8 -1
  118. package/lib-commonjs/compose/types.js.map +1 -1
  119. package/lib-commonjs/hooks/index.d.ts +9 -1
  120. package/lib-commonjs/hooks/index.js +31 -4
  121. package/lib-commonjs/hooks/index.js.map +1 -1
  122. package/lib-commonjs/hooks/useBoolean.d.ts +2 -2
  123. package/lib-commonjs/hooks/useBoolean.js +27 -14
  124. package/lib-commonjs/hooks/useBoolean.js.map +1 -1
  125. package/lib-commonjs/hooks/useConst.js +24 -14
  126. package/lib-commonjs/hooks/useConst.js.map +1 -1
  127. package/lib-commonjs/hooks/useControllableState.d.ts +21 -0
  128. package/lib-commonjs/hooks/useControllableState.js +78 -0
  129. package/lib-commonjs/hooks/useControllableState.js.map +1 -0
  130. package/lib-commonjs/hooks/useControllableValue.js +58 -53
  131. package/lib-commonjs/hooks/useControllableValue.js.map +1 -1
  132. package/lib-commonjs/hooks/useEventCallback.d.ts +2 -2
  133. package/lib-commonjs/hooks/useEventCallback.js +26 -20
  134. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  135. package/lib-commonjs/hooks/useFirstMount.d.ts +11 -0
  136. package/lib-commonjs/hooks/useFirstMount.js +33 -0
  137. package/lib-commonjs/hooks/useFirstMount.js.map +1 -0
  138. package/lib-commonjs/hooks/useForceUpdate.d.ts +4 -0
  139. package/lib-commonjs/hooks/useForceUpdate.js +19 -0
  140. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -0
  141. package/lib-commonjs/hooks/useId.d.ts +7 -3
  142. package/lib-commonjs/hooks/useId.js +25 -21
  143. package/lib-commonjs/hooks/useId.js.map +1 -1
  144. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +9 -0
  145. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +22 -6
  146. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  147. package/lib-commonjs/hooks/useMergedRefs.js +25 -22
  148. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  149. package/lib-commonjs/hooks/useMount.d.ts +6 -0
  150. package/lib-commonjs/hooks/useMount.js +27 -0
  151. package/lib-commonjs/hooks/useMount.js.map +1 -0
  152. package/lib-commonjs/hooks/useOnClickOutside.d.ts +14 -4
  153. package/lib-commonjs/hooks/useOnClickOutside.js +141 -21
  154. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  155. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +5 -0
  156. package/lib-commonjs/hooks/useOnScrollOutside.js +47 -0
  157. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -0
  158. package/lib-commonjs/hooks/usePrevious.d.ts +1 -0
  159. package/lib-commonjs/hooks/usePrevious.js +19 -0
  160. package/lib-commonjs/hooks/usePrevious.js.map +1 -0
  161. package/lib-commonjs/hooks/useTimeout.d.ts +8 -0
  162. package/lib-commonjs/hooks/useTimeout.js +40 -0
  163. package/lib-commonjs/hooks/useTimeout.js.map +1 -0
  164. package/lib-commonjs/hooks/useUnmount.d.ts +6 -0
  165. package/lib-commonjs/hooks/useUnmount.js +27 -0
  166. package/lib-commonjs/hooks/useUnmount.js.map +1 -0
  167. package/lib-commonjs/index.d.ts +1 -0
  168. package/lib-commonjs/index.js +11 -2
  169. package/lib-commonjs/index.js.map +1 -1
  170. package/lib-commonjs/ssr/SSRContext.d.ts +33 -0
  171. package/lib-commonjs/ssr/SSRContext.js +80 -0
  172. package/lib-commonjs/ssr/SSRContext.js.map +1 -0
  173. package/lib-commonjs/ssr/canUseDOM.d.ts +4 -0
  174. package/lib-commonjs/ssr/canUseDOM.js +17 -0
  175. package/lib-commonjs/ssr/canUseDOM.js.map +1 -0
  176. package/lib-commonjs/ssr/index.d.ts +2 -0
  177. package/lib-commonjs/ssr/index.js +12 -0
  178. package/lib-commonjs/ssr/index.js.map +1 -0
  179. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +5 -0
  180. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +27 -0
  181. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -0
  182. package/lib-commonjs/utils/clamp.d.ts +8 -0
  183. package/lib-commonjs/utils/clamp.js +18 -0
  184. package/lib-commonjs/utils/clamp.js.map +1 -0
  185. package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
  186. package/lib-commonjs/utils/getNativeElementProps.js +58 -25
  187. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  188. package/lib-commonjs/utils/getRTLSafeKey.d.ts +4 -0
  189. package/lib-commonjs/utils/getRTLSafeKey.js +30 -0
  190. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -0
  191. package/lib-commonjs/utils/index.d.ts +5 -0
  192. package/lib-commonjs/utils/index.js +19 -2
  193. package/lib-commonjs/utils/index.js.map +1 -1
  194. package/lib-commonjs/utils/omit.d.ts +1 -1
  195. package/lib-commonjs/utils/omit.js +16 -8
  196. package/lib-commonjs/utils/omit.js.map +1 -1
  197. package/lib-commonjs/utils/onlyChild.d.ts +5 -0
  198. package/lib-commonjs/utils/onlyChild.js +23 -0
  199. package/lib-commonjs/utils/onlyChild.js.map +1 -0
  200. package/lib-commonjs/utils/properties.js +84 -280
  201. package/lib-commonjs/utils/properties.js.map +1 -1
  202. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  203. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +30 -0
  204. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  205. package/package.json +11 -9
  206. package/NOTICE.txt +0 -0
  207. package/config/api-extractor.json +0 -3
  208. package/config/tests.js +0 -7
  209. package/etc/react-utilities.api.md +0 -207
  210. package/just.config.ts +0 -3
  211. package/lib/compose/makeMergeProps.d.ts +0 -15
  212. package/lib/compose/makeMergeProps.js +0 -96
  213. package/lib/compose/makeMergeProps.js.map +0 -1
  214. package/lib/compose/resolveShorthandProps.d.ts +0 -7
  215. package/lib/compose/resolveShorthandProps.js +0 -27
  216. package/lib/compose/resolveShorthandProps.js.map +0 -1
  217. package/lib-amd/compose/getSlots.d.ts +0 -20
  218. package/lib-amd/compose/getSlots.js +0 -51
  219. package/lib-amd/compose/getSlots.js.map +0 -1
  220. package/lib-amd/compose/index.d.ts +0 -5
  221. package/lib-amd/compose/index.js +0 -9
  222. package/lib-amd/compose/index.js.map +0 -1
  223. package/lib-amd/compose/makeMergeProps.d.ts +0 -15
  224. package/lib-amd/compose/makeMergeProps.js +0 -98
  225. package/lib-amd/compose/makeMergeProps.js.map +0 -1
  226. package/lib-amd/compose/nullRender.d.ts +0 -4
  227. package/lib-amd/compose/nullRender.js +0 -9
  228. package/lib-amd/compose/nullRender.js.map +0 -1
  229. package/lib-amd/compose/resolveShorthandProps.d.ts +0 -7
  230. package/lib-amd/compose/resolveShorthandProps.js +0 -29
  231. package/lib-amd/compose/resolveShorthandProps.js.map +0 -1
  232. package/lib-amd/compose/types.d.ts +0 -29
  233. package/lib-amd/compose/types.js +0 -5
  234. package/lib-amd/compose/types.js.map +0 -1
  235. package/lib-amd/hooks/index.d.ts +0 -8
  236. package/lib-amd/hooks/index.js +0 -13
  237. package/lib-amd/hooks/index.js.map +0 -1
  238. package/lib-amd/hooks/useBoolean.d.ts +0 -17
  239. package/lib-amd/hooks/useBoolean.js +0 -26
  240. package/lib-amd/hooks/useBoolean.js.map +0 -1
  241. package/lib-amd/hooks/useConst.d.ts +0 -12
  242. package/lib-amd/hooks/useConst.js +0 -31
  243. package/lib-amd/hooks/useConst.js.map +0 -1
  244. package/lib-amd/hooks/useControllableValue.d.ts +0 -20
  245. package/lib-amd/hooks/useControllableValue.js +0 -42
  246. package/lib-amd/hooks/useControllableValue.js.map +0 -1
  247. package/lib-amd/hooks/useEventCallback.d.ts +0 -13
  248. package/lib-amd/hooks/useEventCallback.js +0 -33
  249. package/lib-amd/hooks/useEventCallback.js.map +0 -1
  250. package/lib-amd/hooks/useId.d.ts +0 -11
  251. package/lib-amd/hooks/useId.js +0 -35
  252. package/lib-amd/hooks/useId.js.map +0 -1
  253. package/lib-amd/hooks/useIsomorphicLayoutEffect.d.ts +0 -2
  254. package/lib-amd/hooks/useIsomorphicLayoutEffect.js +0 -9
  255. package/lib-amd/hooks/useIsomorphicLayoutEffect.js.map +0 -1
  256. package/lib-amd/hooks/useMergedRefs.d.ts +0 -13
  257. package/lib-amd/hooks/useMergedRefs.js +0 -33
  258. package/lib-amd/hooks/useMergedRefs.js.map +0 -1
  259. package/lib-amd/hooks/useOnClickOutside.d.ts +0 -19
  260. package/lib-amd/hooks/useOnClickOutside.js +0 -27
  261. package/lib-amd/hooks/useOnClickOutside.js.map +0 -1
  262. package/lib-amd/index.d.ts +0 -3
  263. package/lib-amd/index.js +0 -8
  264. package/lib-amd/index.js.map +0 -1
  265. package/lib-amd/utils/getNativeElementProps.d.ts +0 -9
  266. package/lib-amd/utils/getNativeElementProps.js +0 -40
  267. package/lib-amd/utils/getNativeElementProps.js.map +0 -1
  268. package/lib-amd/utils/index.d.ts +0 -3
  269. package/lib-amd/utils/index.js +0 -8
  270. package/lib-amd/utils/index.js.map +0 -1
  271. package/lib-amd/utils/omit.d.ts +0 -14
  272. package/lib-amd/utils/omit.js +0 -30
  273. package/lib-amd/utils/omit.js.map +0 -1
  274. package/lib-amd/utils/properties.d.ts +0 -148
  275. package/lib-amd/utils/properties.js +0 -416
  276. package/lib-amd/utils/properties.js.map +0 -1
  277. package/lib-commonjs/compose/makeMergeProps.d.ts +0 -15
  278. package/lib-commonjs/compose/makeMergeProps.js +0 -98
  279. package/lib-commonjs/compose/makeMergeProps.js.map +0 -1
  280. package/lib-commonjs/compose/resolveShorthandProps.d.ts +0 -7
  281. package/lib-commonjs/compose/resolveShorthandProps.js +0 -29
  282. package/lib-commonjs/compose/resolveShorthandProps.js.map +0 -1
  283. package/src/compose/README.md +0 -279
@@ -1 +0,0 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"../src/","sources":["utils/properties.ts"],"names":[],"mappings":";;;IAAA,IAAM,WAAW,GAAG;QAAC,eAA+C;aAA/C,UAA+C,EAA/C,qBAA+C,EAA/C,IAA+C;YAA/C,0BAA+C;;QAClE,IAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,KAAmB,UAAK,EAAL,eAAK,EAAL,mBAAK,EAAL,IAAK,EAAE;YAArB,IAAM,IAAI,cAAA;YACb,IAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE5D,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;gBAAnB,IAAM,GAAG,aAAA;gBACZ,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aACjB;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF;;;;OAIG;IACU,QAAA,iBAAiB,GAAG,WAAW,CAAC;QAC3C,QAAQ;QACR,OAAO;QACP,SAAS;QACT,kBAAkB;QAClB,oBAAoB;QACpB,qBAAqB;QACrB,SAAS;QACT,gBAAgB;QAChB,QAAQ;QACR,eAAe;QACf,UAAU;QACV,SAAS;QACT,UAAU;QACV,QAAQ;QACR,SAAS;QACT,WAAW;QACX,kBAAkB;QAClB,YAAY;QACZ,SAAS;QACT,SAAS;QACT,WAAW;QACX,kBAAkB;QAClB,kBAAkB;QAClB,WAAW;QACX,aAAa;QACb,SAAS;QACT,cAAc;QACd,kBAAkB;QAClB,aAAa;QACb,SAAS;QACT,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,cAAc;QACd,UAAU;QACV,WAAW;QACX,WAAW;QACX,WAAW;QACX,cAAc;QACd,gBAAgB;QAChB,WAAW;QACX,SAAS;QACT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;;;;;;;;OAaG;IACH,8DAA8D;IAC9D,SAAgB,cAAc;IAC5B,8DAA8D;IAC9D,KAA0B,EAC1B,gBAAmD,EACnD,iBAA4B;QAE5B,6GAA6G;QAC7G,2GAA2G;QAC3G,2GAA2G;QAC3G,uBAAuB;QACvB,0GAA0G;;QAE1G,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAChD,8DAA8D;QAC9D,IAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;YAAnB,IAAM,GAAG,aAAA;YACZ,IAAM,YAAY,GAChB,CAAC,CAAC,OAAO,IAAK,gBAA2C,CAAC,GAAG,CAAC,CAAC;gBAC/D,CAAC,OAAO,IAAK,gBAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC7D,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC1B,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAE7B,IAAI,YAAY,IAAI,CAAC,CAAC,iBAAiB,IAAI,OAAA,iBAAiB,0CAAE,OAAO,CAAC,GAAG,OAAM,CAAC,CAAC,CAAC,EAAE;gBAClF,8DAA8D;gBAC9D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAM,CAAC,GAAG,CAAQ,CAAC;aAClC;SACF;QAED,OAAO,MAAW,CAAC;IACrB,CAAC;IA/BD,wCA+BC","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 '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"]}
@@ -1,15 +0,0 @@
1
- export declare type MergePropsOptions = {
2
- /**
3
- * A list of props to deep merge. By default, `style` will
4
- * always be deep merged so it's not required to be provided.
5
- */
6
- deepMerge?: string[];
7
- };
8
- /**
9
- * Helper which deep clones props, but respectively assigns JSX, object refs, and class names
10
- * appropriately.
11
- *
12
- * @param target - the target object to merge onto.
13
- * @param propSets - one or more prop sets to deep merge onto the target.
14
- */
15
- export declare const makeMergeProps: <TState = Record<string, any>>(options?: MergePropsOptions) => (target: Record<string, any>, ...propSets: (Record<string, any> | undefined)[]) => TState;
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var React = require("react");
5
- /**
6
- * Concatination helper, which can merge class names together. Skips over falsey values.
7
- *
8
- * @public
9
- */
10
- function css() {
11
- var args = [];
12
- for (var _i = 0; _i < arguments.length; _i++) {
13
- args[_i] = arguments[_i];
14
- }
15
- var classes = [];
16
- for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
17
- var arg = args_1[_a];
18
- if (arg) {
19
- if (typeof arg === 'string') {
20
- classes.push(arg);
21
- }
22
- else if (arg.hasOwnProperty('toString') && typeof arg.toString === 'function') {
23
- classes.push(arg.toString());
24
- }
25
- else {
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- for (var key in arg) {
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- if (arg[key]) {
30
- classes.push(key);
31
- }
32
- }
33
- }
34
- }
35
- }
36
- return classes.join(' ');
37
- }
38
- /**
39
- * Helper which deep clones props, but respectively assigns JSX, object refs, and class names
40
- * appropriately.
41
- *
42
- * @param target - the target object to merge onto.
43
- * @param propSets - one or more prop sets to deep merge onto the target.
44
- */
45
- exports.makeMergeProps = function (options) {
46
- if (options === void 0) { options = {}; }
47
- var deepMerge = tslib_1.__spreadArrays((options.deepMerge || []), ['style']);
48
- var mergeProps = function (target) {
49
- var propSets = [];
50
- for (var _i = 1; _i < arguments.length; _i++) {
51
- propSets[_i - 1] = arguments[_i];
52
- }
53
- for (var _a = 0, propSets_1 = propSets; _a < propSets_1.length; _a++) {
54
- var props = propSets_1[_a];
55
- if (props) {
56
- for (var _b = 0, _c = Object.keys(props); _b < _c.length; _b++) {
57
- var propName = _c[_b];
58
- var propValue = props[propName];
59
- var propValueType = typeof propValue;
60
- if (propValue !== undefined) {
61
- if (propValue && propValueType === 'object') {
62
- if (Array.isArray(propValue)) {
63
- // for arrays, replace.
64
- target[propName] = propValue;
65
- }
66
- else {
67
- target[propName] = target[propName] || {};
68
- if (typeof target[propName] !== 'object' ||
69
- React.isValidElement(propValue) ||
70
- (propValue && typeof propValue === 'object' && propValue.hasOwnProperty('current')) ||
71
- deepMerge.indexOf(propName) === -1) {
72
- // if target is not an object, or value is JSX, or a ref object, replace
73
- target[propName] = propValue;
74
- }
75
- else {
76
- // else deep merge.
77
- mergeProps(target[propName], propValue);
78
- }
79
- }
80
- }
81
- else if (propName === 'className') {
82
- if (propValue) {
83
- // for classnames, append
84
- target[propName] = css(target[propName], propValue);
85
- }
86
- }
87
- else {
88
- target[propName] = propValue;
89
- }
90
- }
91
- }
92
- }
93
- }
94
- return target;
95
- };
96
- return mergeProps;
97
- };
98
- //# sourceMappingURL=makeMergeProps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeMergeProps.js","sourceRoot":"../src/","sources":["compose/makeMergeProps.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAiC/B;;;;GAIG;AACH,SAAS,GAAG;IAAC,cAAmB;SAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;QAAnB,yBAAmB;;IAC9B,IAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;QAAnB,IAAM,GAAG,aAAA;QACZ,IAAI,GAAG,EAAE;YACP,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;gBAC3B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACnB;iBAAM,IAAI,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,UAAU,EAAE;gBAC/E,OAAO,CAAC,IAAI,CAAC,GAAG,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Q,CAAC,IAAI,EAAE,CAAC;gCAE1C,IACE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,QAAQ;oCACpC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC;oCAC/B,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;oCACnF,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAClC;oCACA,yEAAyE;oCACzE,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;iCAC9B;qCAAM;oCACL,mBAAmB;oCACnB,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;iCACzC;6BACF;yBACF;6BAAM,IAAI,QAAQ,KAAK,WAAW,EAAE;4BACnC,IAAI,SAAS,EAAE;gCACb,yBAAyB;gCACzB,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;6BACrD;yBACF;6BAAM;4BACL,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;yBAC9B;qBACF;iBACF;aACF;SACF;QACD,OAAO,MAAgB,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { GenericDictionary } from './types';\n\n// TODO\n// css() function is temporary there, ax() should be used instead, but it's not possible now due possible\n// circular dependencies\n\n/**\n * Dictionary of booleans.\n *\n * @internal\n */\ninterface Dictionary {\n [className: string]: boolean;\n}\n\n/**\n * Serializable object.\n *\n * @internal\n */\ninterface SerializableObject {\n toString?: () => string;\n}\n\n/**\n * css input type.\n *\n * @internal\n */\ntype CssInput = string | SerializableObject | Dictionary | null | undefined | boolean;\n\n/**\n * Concatination helper, which can merge class names together. Skips over falsey values.\n *\n * @public\n */\nfunction css(...args: CssInput[]): string {\n const classes = [];\n\n for (const arg of args) {\n if (arg) {\n if (typeof arg === 'string') {\n classes.push(arg);\n } else if (arg.hasOwnProperty('toString') && typeof arg.toString === 'function') {\n classes.push(arg.toString());\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const key in arg as any) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((arg as any)[key]) {\n classes.push(key);\n }\n }\n }\n }\n }\n\n return classes.join(' ');\n}\n\nexport type MergePropsOptions = {\n /**\n * A list of props to deep merge. By default, `style` will\n * always be deep merged so it's not required to be provided.\n */\n deepMerge?: string[];\n};\n\n/**\n * Helper which deep clones props, but respectively assigns JSX, object refs, and class names\n * appropriately.\n *\n * @param target - the target object to merge onto.\n * @param propSets - one or more prop sets to deep merge onto the target.\n */\nexport const makeMergeProps = <TState = GenericDictionary>(options: MergePropsOptions = {}) => {\n const deepMerge = [...(options.deepMerge || []), 'style'];\n\n const mergeProps = (target: GenericDictionary, ...propSets: (GenericDictionary | undefined)[]): TState => {\n for (const props of propSets) {\n if (props) {\n for (const propName of Object.keys(props)) {\n const propValue = props[propName];\n const propValueType = typeof propValue;\n\n if (propValue !== undefined) {\n if (propValue && propValueType === 'object') {\n if (Array.isArray(propValue)) {\n // for arrays, replace.\n target[propName] = propValue;\n } else {\n target[propName] = target[propName] || {};\n\n if (\n typeof target[propName] !== 'object' ||\n React.isValidElement(propValue) ||\n (propValue && typeof propValue === 'object' && propValue.hasOwnProperty('current')) ||\n deepMerge.indexOf(propName) === -1\n ) {\n // if target is not an object, or value is JSX, or a ref object, replace\n target[propName] = propValue;\n } else {\n // else deep merge.\n mergeProps(target[propName], propValue);\n }\n }\n } else if (propName === 'className') {\n if (propValue) {\n // for classnames, append\n target[propName] = css(target[propName], propValue);\n }\n } else {\n target[propName] = propValue;\n }\n }\n }\n }\n }\n return target as TState;\n };\n\n return mergeProps;\n};\n"]}
@@ -1,7 +0,0 @@
1
- /**
2
- * Ensures that the given slots are represented using object syntax. This ensures that
3
- * the object can be merged along with other objects.
4
- * @param props - The incoming props
5
- * @param shorthandPropNames - An array of prop names to apply simplification to
6
- */
7
- export declare const resolveShorthandProps: <TProps>(props: TProps, shorthandPropNames: string[]) => TProps;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var React = require("react");
5
- /**
6
- * Ensures that the given slots are represented using object syntax. This ensures that
7
- * the object can be merged along with other objects.
8
- * @param props - The incoming props
9
- * @param shorthandPropNames - An array of prop names to apply simplification to
10
- */
11
- exports.resolveShorthandProps = function (props, shorthandPropNames) {
12
- var newProps = props;
13
- if (shorthandPropNames && shorthandPropNames.length) {
14
- newProps = tslib_1.__assign({}, props);
15
- for (var _i = 0, shorthandPropNames_1 = shorthandPropNames; _i < shorthandPropNames_1.length; _i++) {
16
- var propName = shorthandPropNames_1[_i];
17
- // TODO find clean way of guaranteeing only shorthand props are typechecked
18
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
- // @ts-ignore
20
- var propValue = props[propName];
21
- if (propValue !== undefined && (typeof propValue !== 'object' || React.isValidElement(propValue))) {
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- newProps[propName] = { children: propValue };
24
- }
25
- }
26
- }
27
- return newProps;
28
- };
29
- //# sourceMappingURL=resolveShorthandProps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveShorthandProps.js","sourceRoot":"../src/","sources":["compose/resolveShorthandProps.tsx"],"names":[],"mappings":";;;AAAA,6BAA+B;AAE/B;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,UAAU,KAAa,EAAE,kBAA4B;IACxF,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,EAAE;QACnD,QAAQ,wBACH,KAAK,CACT,CAAC;QACF,KAAuB,UAAkB,EAAlB,yCAAkB,EAAlB,gCAAkB,EAAlB,IAAkB,EAAE;YAAtC,IAAM,QAAQ,2BAAA;YACjB,2EAA2E;YAC3E,6DAA6D;YAC7D,aAAa;YACb,IAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;YAElC,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE;gBACjG,8DAA8D;gBAC7D,QAAgB,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;aACvD;SACF;KACF;IAED,OAAO,QAAkB,CAAC;AAC5B,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\n/**\n * Ensures that the given slots are represented using object syntax. This ensures that\n * the object can be merged along with other objects.\n * @param props - The incoming props\n * @param shorthandPropNames - An array of prop names to apply simplification to\n */\nexport const resolveShorthandProps = <TProps,>(props: TProps, shorthandPropNames: string[]) => {\n let newProps = props;\n\n if (shorthandPropNames && shorthandPropNames.length) {\n newProps = {\n ...props,\n };\n for (const propName of shorthandPropNames) {\n // TODO find clean way of guaranteeing only shorthand props are typechecked\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const propValue = props[propName];\n\n if (propValue !== undefined && (typeof propValue !== 'object' || React.isValidElement(propValue))) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (newProps as any)[propName] = { children: propValue };\n }\n }\n }\n\n return newProps as TProps;\n};\n"]}
@@ -1,279 +0,0 @@
1
- A library of utilities for composing Fluent UI components.
2
-
3
- ## A basic component walkthrough
4
-
5
- Building a re-composable component requires that we create building blocks; we put them together, but we can reconfigure
6
- and add to parts as needed.
7
-
8
- Here's what's needed:
9
-
10
- - **State hook** - A hook which takes in props/ref for the component and returns a mutable state object.
11
- - **Style hook** - hooks which can mix the appropriate classnames on the mutable state.
12
- - **Render function** - a function which takes in state of the component and returns JSX. (e.g. `renderButton`)
13
-
14
- With these building blocks, you can compose or recompose the component in numerous ways.
15
-
16
- ### Simple example
17
-
18
- A hook which can produce mutable state of the component (defining accessibility and behaviors):
19
-
20
- ```jsx
21
- const useButton = (userProps, ref, defaultProps) => {
22
- const state = _.merge({}, defaultProps, userProps);
23
-
24
- // Apply button behaviors.
25
- if (state.as !== 'button' && state.as !== 'a') {
26
- state.tabIndex = 0;
27
- }
28
-
29
- return state;
30
- };
31
- ```
32
-
33
- The Button is designed using `React.forwardRef` to ensure the ref is forwarded to the root element:
34
-
35
- ```jsx
36
- const Button = React.forwardRef((props, ref) => {
37
- const state = useButton(props, ref);
38
-
39
- // Apply styling here. (e.g. add className to state.)
40
-
41
- return renderButton(state);
42
- });
43
- ```
44
-
45
- A button can now be easily scaffolded, along with your choice of styling system:
46
-
47
- ```jsx
48
- import { renderButton, useButton, useButtonClasses } from '@fluentui/react-button';
49
-
50
- const Button = React.forwardRef((props, ref) => {
51
- const state = useButton(props, ref);
52
-
53
- // Inject classNames as needed.
54
- useButtonClasses(state);
55
-
56
- // Return the rendered result.
57
- return renderButton(state);
58
- });
59
- ```
60
-
61
- We can now use these building blocks to scaffold other types of buttons. For example, building a toggle button simply
62
- means we start with base and handle the additional input:
63
-
64
- ```jsx
65
- const useToggleButton = (props, ref) => {
66
- const state = useButton(props, ref);
67
-
68
- // Hand a "checked" and "defaultChecked" state, onClicks to toggle the value,
69
- // and appropriate a11y attributes.
70
- useChecked(state);
71
- };
72
-
73
- const ToggleButton = React.forwardRef((props, ref) => {
74
- const state = useToggleButton(props, ref);
75
-
76
- // Inject classNames as needed.
77
- state.className = css(
78
- state.className,
79
- styles.root,
80
- state.checked && styles.checked
81
- );
82
-
83
- return renderButton(state);
84
- ```
85
-
86
- ### Details
87
-
88
- #### Creating mutable state with `mergeProps`
89
-
90
- In the previous example, `_.merge` was used to deep clone the props into a state object. Creating a single clone and
91
- using that to construct state simplifies hook development and usage; rather than trying to re-clone objects
92
- unnecessarily on every small mutation, hooks can assume operating against a draft state. This creates more self
93
- contained hooks, which can ensure they apply state updates correctly, avoiding accidents like stomping on existing event
94
- handlers by blind object assigning the results.
95
-
96
- However, deep merge overlooks many edge cases for component props:
97
-
98
- - Deep merging classnames should append them, not replace
99
- - Deep merging JSX, ref objects, or arrays should replace, not recurse/clone
100
- - Deep merging an object on a string should replace
101
-
102
- ...which introduces the first utility: `mergeProps`. Merge props works like a deep merge, but takes care of classnames,
103
- JSX, arrays, and object edge cases.
104
-
105
- #### Supporting the `as` prop with `getSlots`
106
-
107
- Fluent UI components take a common `as` prop. This allows the root element to be rendered with something other than the
108
- default.
109
-
110
- To support the `as` prop, the render function might look like this:
111
-
112
- ```jsx
113
- const renderButton = state => {
114
- const root = state.as;
115
-
116
- return <root {...state} />;
117
- };
118
- ```
119
-
120
- Additionally, you will need to filter out native properties which apply to the root; otherwise you will end up mixing
121
- any unexpected props into the element. To do this, we have a `getNativeElementProps` helper, which can be used for this
122
- purpose:
123
-
124
- ```jsx
125
- const renderButton = state => {
126
- const root = state.as;
127
- const rootProps = getNativeElementProps(root, state);
128
-
129
- return <root {...rootProps} />;
130
- };
131
- ```
132
-
133
- These steps have been abstracted in the `getSlots` helper:
134
-
135
- ```jsx
136
- const renderButton = state => {
137
- const { slots, slotProps } = getSlots(state);
138
-
139
- return <slots.root {...slotProps.root} />;
140
- };
141
- ```
142
-
143
- #### Supporting shorthand props
144
-
145
- Fluent UI components almost always contain sub parts, and these sub parts should be configurable. We allow them to be
146
- configured through "shorthand props", which lets the caller pass in a variety of inputs for a given slot. Take a
147
- Button's "icon" slot:
148
-
149
- ```jsx
150
- // The icon can be a string
151
- <Button icon="X" />
152
-
153
- // The icon can be JSX
154
- <Button icon={ <FooIcon/> }/>
155
-
156
- // The icon can be an object
157
- <Button icon={{ as: 'i', children: getCode('Add') } } />
158
-
159
- // The icon can be a children function (which receives the original slot and props)
160
- <Button icon={{
161
- children: (Component, props) =>
162
- <>
163
- <Component {...props} />
164
- // other things
165
- </>
166
- }}
167
- />
168
- ```
169
-
170
- Supporting this dynamic props input requires some helpers:
171
-
172
- 1. A helper `resolveShorthandProps` to simplify the user's input into an object for props merging
173
- 2. The `getSlots` helper to parse the slots out
174
-
175
- Here's how this looks:
176
-
177
- The factory function, which deep clones the props, would need to simplify the shorthand first:
178
-
179
- ```jsx
180
- const useButton = (userProps, ref, defaultProps) => {
181
- const state = mergeProps(
182
- {
183
- // default props
184
- as: 'button',
185
- ref,
186
- icon: { as: 'span' },
187
- },
188
- defaultProps, // optional default props from the caller
189
- resolveShorthandProps(userProps, ['icon']), // simplify the user's props
190
- );
191
-
192
- // Apply button behaviors.
193
- useButton(state);
194
-
195
- return { state, render };
196
- };
197
- ```
198
-
199
- ...and the render function now can manage rendering the slot using getSlots:
200
-
201
- ```jsx
202
- const renderButton = state => {
203
- const { slots, slotProps } = getSlots(state, ['icon']);
204
-
205
- return (
206
- <slots.root {...slotProps.root}>
207
- <slots.icon {...slotProps.icon} />
208
- {state.children}
209
- </slots.root>
210
- );
211
- };
212
- ```
213
-
214
- ## API reference
215
-
216
- ### mergeProps(target, ...rest)
217
-
218
- The `mergeProps` function takes in state and compose options, and resolves slots and slotProps.
219
- It's expected that the component will call `mergeProps(state, options)` from within
220
- render; after resolving state and before rendering slots and slotProps.
221
-
222
- Example:
223
-
224
- ```jsx
225
- mergeProps(props, { ...etc }, { ...etc });
226
- ```
227
-
228
- ### getSlots(state: Record<string, any>, slotNames: string[])
229
-
230
- The `getSlots` function takes in a state object and a list of slot keys with the state, and returns
231
- `slots` and `slotProps` to be used in rendering the component.
232
-
233
- In cases where the `as` prop of the slot represents a primitive element tag name, there are some additional behaviors:
234
-
235
- - Props will be automatically filtered based on the element type. E.g. `href` will be passed to `a` tag slots, but not
236
- `button` slots.
237
- - The slot will avoid rendering completely if children are undefined. This is to avoid requiring nearly every slot to be
238
- wrapped in a conditional to avoid rendering the parent. You can force rendering primitives without children by passing
239
- `null` in for the children. (E.g. `{ as: 'input', children: null }`).
240
-
241
- Example:
242
-
243
- ```jsx
244
- const Button = props => {
245
- const { slots, slotProps } = getSlots(props, ['foo', 'bar']);
246
-
247
- return (
248
- <slots.root { slotProps.root}>
249
- <slots.foo { slotProps.foo } />
250
- <slots.bar { slotProps.foo } />
251
- </slots.root>
252
- );
253
- };
254
- ```
255
-
256
- ### resolveShorthandProps<TState>(state: TState, slotNames: (keyof TState)[]): TState
257
-
258
- Ensures that the given slots are represented using object syntax. This ensures that
259
- the object can be merged along with other objects.
260
-
261
- Example:
262
-
263
- ```jsx
264
- const foo = resolveShorthandProps(
265
- { a: <JSX/>, b: 'string', c: { ... }, d: 'unchanged' },
266
- [ 'a', 'b', 'c' ]
267
- );
268
- ```
269
-
270
- Results in objects which can be merged correctly:
271
-
272
- ```jsx
273
- {
274
- a: { children: <JSX/> },
275
- b: { children: 'string' },
276
- c: { ... },
277
- d: 'unchanged'
278
- }
279
- ```