@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,40 +0,0 @@
1
- define(["require", "exports", "./properties"], function (require, exports, properties_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- var nativeElementMap = {
5
- label: properties_1.labelProperties,
6
- audio: properties_1.audioProperties,
7
- video: properties_1.videoProperties,
8
- ol: properties_1.olProperties,
9
- li: properties_1.liProperties,
10
- a: properties_1.anchorProperties,
11
- button: properties_1.buttonProperties,
12
- input: properties_1.inputProperties,
13
- textarea: properties_1.textAreaProperties,
14
- select: properties_1.selectProperties,
15
- option: properties_1.optionProperties,
16
- table: properties_1.tableProperties,
17
- tr: properties_1.trProperties,
18
- th: properties_1.thProperties,
19
- td: properties_1.tdProperties,
20
- colGroup: properties_1.colGroupProperties,
21
- col: properties_1.colProperties,
22
- form: properties_1.formProperties,
23
- iframe: properties_1.iframeProperties,
24
- img: properties_1.imgProperties,
25
- };
26
- /**
27
- * Given an element tagname and user props, filters the props to only allowed props for the given
28
- * element type.
29
- * @param tagName - Tag name (e.g. "div")
30
- * @param props - Props object
31
- * @param excludedPropNames - List of props to disallow
32
- */
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- function getNativeElementProps(tagName, props, excludedPropNames) {
35
- var allowedPropNames = (tagName && nativeElementMap[tagName]) || properties_1.htmlElementProperties;
36
- return properties_1.getNativeProps(props, allowedPropNames, excludedPropNames);
37
- }
38
- exports.getNativeElementProps = getNativeElementProps;
39
- });
40
- //# sourceMappingURL=getNativeElementProps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getNativeElementProps.js","sourceRoot":"../src/","sources":["utils/getNativeElementProps.ts"],"names":[],"mappings":";;;IA0BA,IAAM,gBAAgB,GAA2C;QAC/D,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,CAAC,EAAE,6BAAgB;QACnB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,QAAQ,EAAE,+BAAkB;QAC5B,MAAM,EAAE,6BAAgB;QACxB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,QAAQ,EAAE,+BAAkB;QAC5B,GAAG,EAAE,0BAAa;QAClB,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;QACxB,GAAG,EAAE,0BAAa;KACnB,CAAC;IAEF;;;;;;OAMG;IACH,8DAA8D;IAC9D,SAAgB,qBAAqB,CACnC,OAAe,EACf,KAAS,EACT,iBAA4B;QAE5B,IAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,kCAAqB,CAAC;QAEzF,OAAO,2BAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IARD,sDAQC","sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n"]}
@@ -1,3 +0,0 @@
1
- export * from './getNativeElementProps';
2
- export * from './omit';
3
- export * from './properties';
@@ -1,8 +0,0 @@
1
- define(["require", "exports", "tslib", "./getNativeElementProps", "./omit", "./properties"], function (require, exports, tslib_1, getNativeElementProps_1, omit_1, properties_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(getNativeElementProps_1, exports);
5
- tslib_1.__exportStar(omit_1, exports);
6
- tslib_1.__exportStar(properties_1, exports);
7
- });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":";;;IAAA,uDAAwC;IACxC,sCAAuB;IACvB,4CAA6B","sourcesContent":["export * from './getNativeElementProps';\nexport * from './omit';\nexport * from './properties';\n"]}
@@ -1,14 +0,0 @@
1
- /**
2
- * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
3
- * props. This ends up faster than using object ...rest or reduce to filter.
4
- *
5
- * This behaves very much like filteredAssign, but does not merge many objects together,
6
- * uses an exclusion object map, and avoids spreads all for optimal performance.
7
- *
8
- * See perf test for background:
9
- * https://jsperf.com/omit-vs-rest-vs-reduce/1
10
- *
11
- * @param obj - The object to clone
12
- * @param exclusions - The array of keys to exclude
13
- */
14
- export declare function omit<TObj extends Record<string, any>>(obj: TObj, exclusions: (keyof TObj)[]): TObj;
@@ -1,30 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- /**
5
- * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
6
- * props. This ends up faster than using object ...rest or reduce to filter.
7
- *
8
- * This behaves very much like filteredAssign, but does not merge many objects together,
9
- * uses an exclusion object map, and avoids spreads all for optimal performance.
10
- *
11
- * See perf test for background:
12
- * https://jsperf.com/omit-vs-rest-vs-reduce/1
13
- *
14
- * @param obj - The object to clone
15
- * @param exclusions - The array of keys to exclude
16
- */
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- function omit(obj, exclusions) {
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- var result = {};
21
- for (var key in obj) {
22
- if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
23
- result[key] = obj[key];
24
- }
25
- }
26
- return result;
27
- }
28
- exports.omit = omit;
29
- });
30
- //# sourceMappingURL=omit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"omit.js","sourceRoot":"../src/","sources":["utils/omit.ts"],"names":[],"mappings":";;;IAAA;;;;;;;;;;;;OAYG;IACH,8DAA8D;IAC9D,SAAgB,IAAI,CAAmC,GAAS,EAAE,UAA0B;QAC1F,8DAA8D;QAC9D,IAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;YACrB,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBAC7D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;aACxB;SACF;QAED,OAAO,MAAc,CAAC;IACxB,CAAC;IAXD,oBAWC","sourcesContent":["/**\n * Tiny helper to do the minimal amount of work in duplicating an object but omitting some\n * props. This ends up faster than using object ...rest or reduce to filter.\n *\n * This behaves very much like filteredAssign, but does not merge many objects together,\n * uses an exclusion object map, and avoids spreads all for optimal performance.\n *\n * See perf test for background:\n * https://jsperf.com/omit-vs-rest-vs-reduce/1\n *\n * @param obj - The object to clone\n * @param exclusions - The array of keys to exclude\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function omit<TObj extends Record<string, any>>(obj: TObj, exclusions: (keyof TObj)[]): TObj {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const key in obj) {\n if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {\n result[key] = obj[key];\n }\n }\n\n return result as TObj;\n}\n"]}
@@ -1,148 +0,0 @@
1
- /**
2
- * An array of events that are allowed on every html element type.
3
- *
4
- * @public
5
- */
6
- export declare const baseElementEvents: Record<string, number>;
7
- /**
8
- * An array of element attributes which are allowed on every html element type.
9
- *
10
- * @public
11
- */
12
- export declare const baseElementProperties: Record<string, number>;
13
- /**
14
- * An array of HTML element properties and events.
15
- *
16
- * @public
17
- */
18
- export declare const htmlElementProperties: Record<string, number>;
19
- /**
20
- * An array of LABEL tag properties and events.
21
- *
22
- * @public
23
- */
24
- export declare const labelProperties: Record<string, number>;
25
- /**
26
- * An array of AUDIO tag properties and events.
27
-
28
- * @public
29
- */
30
- export declare const audioProperties: Record<string, number>;
31
- /**
32
- * An array of VIDEO tag properties and events.
33
- *
34
- * @public
35
- */
36
- export declare const videoProperties: Record<string, number>;
37
- /**
38
- * An array of OL tag properties and events.
39
- *
40
- * @public
41
- */
42
- export declare const olProperties: Record<string, number>;
43
- /**
44
- * An array of LI tag properties and events.
45
- *
46
- * @public
47
- */
48
- export declare const liProperties: Record<string, number>;
49
- /**
50
- * An array of A tag properties and events.
51
- *
52
- * @public
53
- */
54
- export declare const anchorProperties: Record<string, number>;
55
- /**
56
- * An array of BUTTON tag properties and events.
57
- *
58
- * @public
59
- */
60
- export declare const buttonProperties: Record<string, number>;
61
- /**
62
- * An array of INPUT tag properties and events.
63
- *
64
- * @public
65
- */
66
- export declare const inputProperties: Record<string, number>;
67
- /**
68
- * An array of TEXTAREA tag properties and events.
69
- *
70
- * @public
71
- */
72
- export declare const textAreaProperties: Record<string, number>;
73
- /**
74
- * An array of SELECT tag properties and events.
75
- *
76
- * @public
77
- */
78
- export declare const selectProperties: Record<string, number>;
79
- export declare const optionProperties: Record<string, number>;
80
- /**
81
- * An array of TABLE tag properties and events.
82
- *
83
- * @public
84
- */
85
- export declare const tableProperties: Record<string, number>;
86
- /**
87
- * An array of TR tag properties and events.
88
- *
89
- * @public
90
- */
91
- export declare const trProperties: Record<string, number>;
92
- /**
93
- * An array of TH tag properties and events.
94
- *
95
- * @public
96
- */
97
- export declare const thProperties: Record<string, number>;
98
- /**
99
- * An array of TD tag properties and events.
100
- *
101
- * @public
102
- */
103
- export declare const tdProperties: Record<string, number>;
104
- export declare const colGroupProperties: Record<string, number>;
105
- export declare const colProperties: Record<string, number>;
106
- /**
107
- * An array of FORM tag properties and events.
108
- *
109
- * @public
110
- */
111
- export declare const formProperties: Record<string, number>;
112
- /**
113
- * An array of IFRAME tag properties and events.
114
- *
115
- * @public
116
- */
117
- export declare const iframeProperties: Record<string, number>;
118
- /**
119
- * An array of IMAGE tag properties and events.
120
- *
121
- * @public
122
- */
123
- export declare const imgProperties: Record<string, number>;
124
- /**
125
- * @deprecated Use imgProperties for img elements.
126
- */
127
- export declare const imageProperties: Record<string, number>;
128
- /**
129
- * An array of DIV tag properties and events.
130
- *
131
- * @public
132
- */
133
- export declare const divProperties: Record<string, number>;
134
- /**
135
- * Gets native supported props for an html element provided the allowance set. Use one of the property
136
- * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
137
- * props set. Note that all data- and aria- prefixed attributes will be allowed.
138
- * NOTE: getNativeProps should always be applied first when adding props to a react component. The
139
- * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
140
- * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
141
- * the component after an onClick function is added, then the getNativeProps onClick will override it.
142
- *
143
- * @public
144
- * @param props - The unfiltered input props
145
- * @param allowedPropsNames - The array or record of allowed prop names.
146
- * @returns The filtered props
147
- */
148
- export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
@@ -1,416 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- var toObjectMap = function () {
5
- var items = [];
6
- for (var _i = 0; _i < arguments.length; _i++) {
7
- items[_i] = arguments[_i];
8
- }
9
- var result = {};
10
- for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
11
- var item = items_1[_a];
12
- var keys = Array.isArray(item) ? item : Object.keys(item);
13
- for (var _b = 0, keys_1 = keys; _b < keys_1.length; _b++) {
14
- var key = keys_1[_b];
15
- result[key] = 1;
16
- }
17
- }
18
- return result;
19
- };
20
- /**
21
- * An array of events that are allowed on every html element type.
22
- *
23
- * @public
24
- */
25
- exports.baseElementEvents = toObjectMap([
26
- 'onCopy',
27
- 'onCut',
28
- 'onPaste',
29
- 'onCompositionEnd',
30
- 'onCompositionStart',
31
- 'onCompositionUpdate',
32
- 'onFocus',
33
- 'onFocusCapture',
34
- 'onBlur',
35
- 'onBlurCapture',
36
- 'onChange',
37
- 'onInput',
38
- 'onSubmit',
39
- 'onLoad',
40
- 'onError',
41
- 'onKeyDown',
42
- 'onKeyDownCapture',
43
- 'onKeyPress',
44
- 'onKeyUp',
45
- 'onAbort',
46
- 'onCanPlay',
47
- 'onCanPlayThrough',
48
- 'onDurationChange',
49
- 'onEmptied',
50
- 'onEncrypted',
51
- 'onEnded',
52
- 'onLoadedData',
53
- 'onLoadedMetadata',
54
- 'onLoadStart',
55
- 'onPause',
56
- 'onPlay',
57
- 'onPlaying',
58
- 'onProgress',
59
- 'onRateChange',
60
- 'onSeeked',
61
- 'onSeeking',
62
- 'onStalled',
63
- 'onSuspend',
64
- 'onTimeUpdate',
65
- 'onVolumeChange',
66
- 'onWaiting',
67
- 'onClick',
68
- 'onClickCapture',
69
- 'onContextMenu',
70
- 'onDoubleClick',
71
- 'onDrag',
72
- 'onDragEnd',
73
- 'onDragEnter',
74
- 'onDragExit',
75
- 'onDragLeave',
76
- 'onDragOver',
77
- 'onDragStart',
78
- 'onDrop',
79
- 'onMouseDown',
80
- 'onMouseDownCapture',
81
- 'onMouseEnter',
82
- 'onMouseLeave',
83
- 'onMouseMove',
84
- 'onMouseOut',
85
- 'onMouseOver',
86
- 'onMouseUp',
87
- 'onMouseUpCapture',
88
- 'onSelect',
89
- 'onTouchCancel',
90
- 'onTouchEnd',
91
- 'onTouchMove',
92
- 'onTouchStart',
93
- 'onScroll',
94
- 'onWheel',
95
- 'onPointerCancel',
96
- 'onPointerDown',
97
- 'onPointerEnter',
98
- 'onPointerLeave',
99
- 'onPointerMove',
100
- 'onPointerOut',
101
- 'onPointerOver',
102
- 'onPointerUp',
103
- 'onGotPointerCapture',
104
- 'onLostPointerCapture',
105
- ]);
106
- /**
107
- * An array of element attributes which are allowed on every html element type.
108
- *
109
- * @public
110
- */
111
- exports.baseElementProperties = toObjectMap([
112
- 'accessKey',
113
- 'children',
114
- 'className',
115
- 'contentEditable',
116
- 'dir',
117
- 'draggable',
118
- 'hidden',
119
- 'htmlFor',
120
- 'id',
121
- 'lang',
122
- 'ref',
123
- 'role',
124
- 'style',
125
- 'tabIndex',
126
- 'title',
127
- 'translate',
128
- 'spellCheck',
129
- 'name',
130
- ]);
131
- /**
132
- * An array of HTML element properties and events.
133
- *
134
- * @public
135
- */
136
- exports.htmlElementProperties = toObjectMap(exports.baseElementProperties, exports.baseElementEvents);
137
- /**
138
- * An array of LABEL tag properties and events.
139
- *
140
- * @public
141
- */
142
- exports.labelProperties = toObjectMap(exports.htmlElementProperties, [
143
- 'form',
144
- ]);
145
- /**
146
- * An array of AUDIO tag properties and events.
147
-
148
- * @public
149
- */
150
- exports.audioProperties = toObjectMap(exports.htmlElementProperties, [
151
- 'height',
152
- 'loop',
153
- 'muted',
154
- 'preload',
155
- 'src',
156
- 'width',
157
- ]);
158
- /**
159
- * An array of VIDEO tag properties and events.
160
- *
161
- * @public
162
- */
163
- exports.videoProperties = toObjectMap(exports.audioProperties, [
164
- 'poster',
165
- ]);
166
- /**
167
- * An array of OL tag properties and events.
168
- *
169
- * @public
170
- */
171
- exports.olProperties = toObjectMap(exports.htmlElementProperties, [
172
- 'start',
173
- ]);
174
- /**
175
- * An array of LI tag properties and events.
176
- *
177
- * @public
178
- */
179
- exports.liProperties = toObjectMap(exports.htmlElementProperties, [
180
- 'value',
181
- ]);
182
- /**
183
- * An array of A tag properties and events.
184
- *
185
- * @public
186
- */
187
- exports.anchorProperties = toObjectMap(exports.htmlElementProperties, [
188
- 'download',
189
- 'href',
190
- 'hrefLang',
191
- 'media',
192
- 'rel',
193
- 'target',
194
- 'type',
195
- ]);
196
- /**
197
- * An array of BUTTON tag properties and events.
198
- *
199
- * @public
200
- */
201
- exports.buttonProperties = toObjectMap(exports.htmlElementProperties, [
202
- 'autoFocus',
203
- 'disabled',
204
- 'form',
205
- 'formAction',
206
- 'formEncType',
207
- 'formMethod',
208
- 'formNoValidate',
209
- 'formTarget',
210
- 'type',
211
- 'value',
212
- ]);
213
- /**
214
- * An array of INPUT tag properties and events.
215
- *
216
- * @public
217
- */
218
- exports.inputProperties = toObjectMap(exports.buttonProperties, [
219
- 'accept',
220
- 'alt',
221
- 'autoCapitalize',
222
- 'autoComplete',
223
- 'checked',
224
- 'dirname',
225
- 'form',
226
- 'height',
227
- 'inputMode',
228
- 'list',
229
- 'max',
230
- 'maxLength',
231
- 'min',
232
- 'multiple',
233
- 'pattern',
234
- 'placeholder',
235
- 'readOnly',
236
- 'required',
237
- 'src',
238
- 'step',
239
- 'size',
240
- 'type',
241
- 'value',
242
- 'width',
243
- ]);
244
- /**
245
- * An array of TEXTAREA tag properties and events.
246
- *
247
- * @public
248
- */
249
- exports.textAreaProperties = toObjectMap(exports.buttonProperties, [
250
- 'autoCapitalize',
251
- 'cols',
252
- 'dirname',
253
- 'form',
254
- 'maxLength',
255
- 'placeholder',
256
- 'readOnly',
257
- 'required',
258
- 'rows',
259
- 'wrap',
260
- ]);
261
- /**
262
- * An array of SELECT tag properties and events.
263
- *
264
- * @public
265
- */
266
- exports.selectProperties = toObjectMap(exports.buttonProperties, [
267
- 'form',
268
- 'multiple',
269
- 'required',
270
- ]);
271
- exports.optionProperties = toObjectMap(exports.htmlElementProperties, [
272
- 'selected',
273
- 'value',
274
- ]);
275
- /**
276
- * An array of TABLE tag properties and events.
277
- *
278
- * @public
279
- */
280
- exports.tableProperties = toObjectMap(exports.htmlElementProperties, [
281
- 'cellPadding',
282
- 'cellSpacing',
283
- ]);
284
- /**
285
- * An array of TR tag properties and events.
286
- *
287
- * @public
288
- */
289
- exports.trProperties = exports.htmlElementProperties;
290
- /**
291
- * An array of TH tag properties and events.
292
- *
293
- * @public
294
- */
295
- exports.thProperties = toObjectMap(exports.htmlElementProperties, [
296
- 'rowSpan',
297
- 'scope',
298
- ]);
299
- /**
300
- * An array of TD tag properties and events.
301
- *
302
- * @public
303
- */
304
- exports.tdProperties = toObjectMap(exports.htmlElementProperties, [
305
- 'colSpan',
306
- 'headers',
307
- 'rowSpan',
308
- 'scope',
309
- ]);
310
- exports.colGroupProperties = toObjectMap(exports.htmlElementProperties, [
311
- 'span',
312
- ]);
313
- exports.colProperties = toObjectMap(exports.htmlElementProperties, [
314
- 'span',
315
- ]);
316
- /**
317
- * An array of FORM tag properties and events.
318
- *
319
- * @public
320
- */
321
- exports.formProperties = toObjectMap(exports.htmlElementProperties, [
322
- 'acceptCharset',
323
- 'action',
324
- 'encType',
325
- 'encType',
326
- 'method',
327
- 'noValidate',
328
- 'target',
329
- ]);
330
- /**
331
- * An array of IFRAME tag properties and events.
332
- *
333
- * @public
334
- */
335
- exports.iframeProperties = toObjectMap(exports.htmlElementProperties, [
336
- 'allow',
337
- 'allowFullScreen',
338
- 'allowPaymentRequest',
339
- 'allowTransparency',
340
- 'csp',
341
- 'height',
342
- 'importance',
343
- 'referrerPolicy',
344
- 'sandbox',
345
- 'src',
346
- 'srcDoc',
347
- 'width',
348
- ]);
349
- /**
350
- * An array of IMAGE tag properties and events.
351
- *
352
- * @public
353
- */
354
- exports.imgProperties = toObjectMap(exports.htmlElementProperties, [
355
- 'alt',
356
- 'crossOrigin',
357
- 'height',
358
- 'src',
359
- 'srcSet',
360
- 'useMap',
361
- 'width',
362
- ]);
363
- /**
364
- * @deprecated Use imgProperties for img elements.
365
- */
366
- exports.imageProperties = exports.imgProperties;
367
- /**
368
- * An array of DIV tag properties and events.
369
- *
370
- * @public
371
- */
372
- exports.divProperties = exports.htmlElementProperties;
373
- /**
374
- * Gets native supported props for an html element provided the allowance set. Use one of the property
375
- * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
376
- * props set. Note that all data- and aria- prefixed attributes will be allowed.
377
- * NOTE: getNativeProps should always be applied first when adding props to a react component. The
378
- * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
379
- * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
380
- * the component after an onClick function is added, then the getNativeProps onClick will override it.
381
- *
382
- * @public
383
- * @param props - The unfiltered input props
384
- * @param allowedPropsNames - The array or record of allowed prop names.
385
- * @returns The filtered props
386
- */
387
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
388
- function getNativeProps(
389
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
390
- props, allowedPropNames, excludedPropNames) {
391
- // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for
392
- // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.
393
- // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then
394
- // return native props.
395
- // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797
396
- var _a;
397
- var isArray = Array.isArray(allowedPropNames);
398
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
399
- var result = {};
400
- var keys = Object.keys(props);
401
- for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
402
- var key = keys_2[_i];
403
- var isNativeProp = (!isArray && allowedPropNames[key]) ||
404
- (isArray && allowedPropNames.indexOf(key) >= 0) ||
405
- key.indexOf('data-') === 0 ||
406
- key.indexOf('aria-') === 0;
407
- if (isNativeProp && (!excludedPropNames || ((_a = excludedPropNames) === null || _a === void 0 ? void 0 : _a.indexOf(key)) === -1)) {
408
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
409
- result[key] = props[key];
410
- }
411
- }
412
- return result;
413
- }
414
- exports.getNativeProps = getNativeProps;
415
- });
416
- //# sourceMappingURL=properties.js.map