@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
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsSSR = exports.SSRProvider = exports.useSSRContext = exports.SSRContext = exports.defaultSSRContextValue = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const canUseDOM_1 = /*#__PURE__*/require("./canUseDOM");
11
+ /**
12
+ * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
13
+ *
14
+ * @internal
15
+ */
16
+
17
+
18
+ exports.defaultSSRContextValue = {
19
+ current: 0
20
+ };
21
+ exports.SSRContext = /*#__PURE__*/React.createContext(exports.defaultSSRContextValue);
22
+ /**
23
+ * @internal
24
+ */
25
+
26
+ function useSSRContext() {
27
+ return React.useContext(exports.SSRContext);
28
+ }
29
+
30
+ exports.useSSRContext = useSSRContext;
31
+ /**
32
+ * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
33
+ * are consistent between the client and server.
34
+ *
35
+ * @public
36
+ */
37
+
38
+ const SSRProvider = props => {
39
+ const [value] = React.useState(() => ({
40
+ current: 0
41
+ }));
42
+ return React.createElement(exports.SSRContext.Provider, {
43
+ value: value
44
+ }, props.children);
45
+ };
46
+
47
+ exports.SSRProvider = SSRProvider;
48
+ /**
49
+ * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
50
+ * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
51
+ */
52
+
53
+ function useIsSSR() {
54
+ const isInSSRContext = useSSRContext() !== exports.defaultSSRContextValue;
55
+ const [isSSR, setIsSSR] = React.useState(isInSSRContext); // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
56
+ // developer to add one.
57
+
58
+ if (process.env.NODE_ENV !== 'production') {
59
+ if (!isInSSRContext && !canUseDOM_1.canUseDOM()) {
60
+ // eslint-disable-next-line no-console
61
+ console.error('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.');
62
+ }
63
+ } // If on the client, and the component was initially server rendered, then schedule a layout effect to update the
64
+ // component after hydration.
65
+
66
+
67
+ if (canUseDOM_1.canUseDOM() && isInSSRContext) {
68
+ // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
69
+ // mounting.
70
+ // eslint-disable-next-line
71
+ React.useLayoutEffect(() => {
72
+ setIsSSR(false);
73
+ }, []);
74
+ }
75
+
76
+ return isSSR;
77
+ }
78
+
79
+ exports.useIsSSR = useIsSSR;
80
+ //# sourceMappingURL=SSRContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ssr/SSRContext.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAYA;;;;AAIG;;;AACU,OAAA,CAAA,sBAAA,GAA0C;AACrD,EAAA,OAAO,EAAE;AAD4C,CAA1C;AAIA,OAAA,CAAA,UAAA,gBAAa,KAAK,CAAC,aAAN,CAAqC,OAAA,CAAA,sBAArC,CAAb;AAEb;;AAEG;;AACH,SAAgB,aAAhB,GAA6B;AAC3B,SAAO,KAAK,CAAC,UAAN,CAAiB,OAAA,CAAA,UAAjB,CAAP;AACD;;AAFD,OAAA,CAAA,aAAA,GAAA,aAAA;AAIA;;;;;AAKG;;AACI,MAAM,WAAW,GAAa,KAAK,IAAG;AAC3C,QAAM,CAAC,KAAD,IAAU,KAAK,CAAC,QAAN,CAAgC,OAAO;AAAE,IAAA,OAAO,EAAE;AAAX,GAAP,CAAhC,CAAhB;AAEA,SAAO,KAAA,CAAA,aAAA,CAAC,OAAA,CAAA,UAAA,CAAW,QAAZ,EAAoB;AAAC,IAAA,KAAK,EAAE;AAAR,GAApB,EAAoC,KAAK,CAAC,QAA1C,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,WAAA,GAAW,WAAX;AAMb;;;AAGG;;AACH,SAAgB,QAAhB,GAAwB;AACtB,QAAM,cAAc,GAAG,aAAa,OAAO,OAAA,CAAA,sBAA3C;AACA,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,QAAN,CAAe,cAAf,CAA1B,CAFsB,CAItB;AACA;;AACA,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,QAAI,CAAC,cAAD,IAAmB,CAAC,WAAA,CAAA,SAAA,EAAxB,EAAqC;AACnC;AACA,MAAA,OAAO,CAAC,KAAR,CACE,4GACE,0CAFJ;AAID;AACF,GAdqB,CAgBtB;AACA;;;AACA,MAAI,WAAA,CAAA,SAAA,MAAe,cAAnB,EAAmC;AACjC;AACA;AACA;AACA,IAAA,KAAK,CAAC,eAAN,CAAsB,MAAK;AACzB,MAAA,QAAQ,CAAC,KAAD,CAAR;AACD,KAFD,EAEG,EAFH;AAGD;;AAED,SAAO,KAAP;AACD;;AA5BD,OAAA,CAAA,QAAA,GAAA,QAAA","sourceRoot":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Verifies if an application can use DOM.
3
+ */
4
+ export declare function canUseDOM(): boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.canUseDOM = void 0;
7
+ /**
8
+ * Verifies if an application can use DOM.
9
+ */
10
+
11
+ function canUseDOM() {
12
+ return typeof window !== 'undefined' && !!(window.document && // eslint-disable-next-line deprecation/deprecation
13
+ window.document.createElement);
14
+ }
15
+
16
+ exports.canUseDOM = canUseDOM;
17
+ //# sourceMappingURL=canUseDOM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ssr/canUseDOM.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACH,SAAgB,SAAhB,GAAyB;AACvB,SACE,OAAO,MAAP,KAAkB,WAAlB,IACA,CAAC,EACC,MAAM,CAAC,QAAP,IACA;AACA,EAAA,MAAM,CAAC,QAAP,CAAgB,aAHjB,CAFH;AAQD;;AATD,OAAA,CAAA,SAAA,GAAA,SAAA","sourceRoot":""}
@@ -0,0 +1,2 @@
1
+ export * from './canUseDOM';
2
+ export * from './SSRContext';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./canUseDOM"), exports);
10
+
11
+ tslib_1.__exportStar(require("./SSRContext"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ssr/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
4
+ */
5
+ export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | ((props: TTriggerProps) => React.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React.ReactNode;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyTriggerPropsToChildren = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const onlyChild_1 = /*#__PURE__*/require("./onlyChild");
11
+ /**
12
+ * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
13
+ */
14
+
15
+
16
+ const applyTriggerPropsToChildren = (children, triggerProps) => {
17
+ if (typeof children === 'function') {
18
+ return children(triggerProps);
19
+ } else if (children) {
20
+ return React.cloneElement(onlyChild_1.onlyChild(children), triggerProps);
21
+ }
22
+
23
+ return children;
24
+ };
25
+
26
+ exports.applyTriggerPropsToChildren = applyTriggerPropsToChildren;
27
+ //# sourceMappingURL=applyTriggerPropsToChildren.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/applyTriggerPropsToChildren.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,2BAA2B,GAAG,CACzC,QADyC,EAEzC,YAFyC,KAGtB;AACnB,MAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;AAClC,WAAO,QAAQ,CAAC,YAAD,CAAf;AACD,GAFD,MAEO,IAAI,QAAJ,EAAc;AACnB,WAAO,KAAK,CAAC,YAAN,CAAmB,WAAA,CAAA,SAAA,CAAU,QAAV,CAAnB,EAAwC,YAAxC,CAAP;AACD;;AAED,SAAO,QAAP;AACD,CAXM;;AAAM,OAAA,CAAA,2BAAA,GAA2B,2BAA3B","sourceRoot":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Clamps `value` to a number between the min and max.
3
+ *
4
+ * @param value - the value to be clamped
5
+ * @param min - the lowest valid value
6
+ * @param max - the highest valid value
7
+ */
8
+ export declare const clamp: (value: number, min: number, max: number) => number;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clamp = void 0;
7
+ /**
8
+ * Clamps `value` to a number between the min and max.
9
+ *
10
+ * @param value - the value to be clamped
11
+ * @param min - the lowest valid value
12
+ * @param max - the highest valid value
13
+ */
14
+
15
+ const clamp = (value, min, max) => Math.max(min, Math.min(max, value || 0));
16
+
17
+ exports.clamp = clamp;
18
+ //# sourceMappingURL=clamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/clamp.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;;AACI,MAAM,KAAK,GAAG,CAAC,KAAD,EAAgB,GAAhB,EAA6B,GAA7B,KAAqD,IAAI,CAAC,GAAL,CAAS,GAAT,EAAc,IAAI,CAAC,GAAL,CAAS,GAAT,EAAc,KAAK,IAAI,CAAvB,CAAd,CAAnE;;AAAM,OAAA,CAAA,KAAA,GAAK,KAAL","sourceRoot":""}
@@ -7,3 +7,25 @@ import * as React from 'react';
7
7
  * @param excludedPropNames - List of props to disallow
8
8
  */
9
9
  export declare function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
10
+ /**
11
+ * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
12
+ *
13
+ * This function is only for use with components that have a primary slot other than `root`.
14
+ * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
15
+ *
16
+ * @returns An object containing the native props for the `root` and primary slots.
17
+ */
18
+ export declare const getPartitionedNativeProps: ({ primarySlotTagName, props, excludedPropNames, }: {
19
+ /** The primary slot's element type (e.g. 'div') */
20
+ primarySlotTagName: keyof JSX.IntrinsicElements;
21
+ /** The component's props object */
22
+ props: Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>;
23
+ /** List of native props to exclude from the returned value */
24
+ excludedPropNames?: string[] | undefined;
25
+ }) => {
26
+ root: {
27
+ style: React.CSSProperties | undefined;
28
+ className: string | undefined;
29
+ };
30
+ primary: React.HTMLAttributes<any>;
31
+ };
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var properties_1 = require("./properties");
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,
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPartitionedNativeProps = exports.getNativeElementProps = void 0;
7
+
8
+ const properties_1 = /*#__PURE__*/require("./properties");
9
+
10
+ const nativeElementMap = {
11
+ label: properties_1.labelProperties,
12
+ audio: properties_1.audioProperties,
13
+ video: properties_1.videoProperties,
14
+ ol: properties_1.olProperties,
15
+ li: properties_1.liProperties,
16
+ a: properties_1.anchorProperties,
17
+ button: properties_1.buttonProperties,
18
+ input: properties_1.inputProperties,
19
+ textarea: properties_1.textAreaProperties,
20
+ select: properties_1.selectProperties,
21
+ option: properties_1.optionProperties,
22
+ table: properties_1.tableProperties,
23
+ tr: properties_1.trProperties,
24
+ th: properties_1.thProperties,
25
+ td: properties_1.tdProperties,
26
+ colGroup: properties_1.colGroupProperties,
27
+ col: properties_1.colProperties,
28
+ form: properties_1.formProperties,
29
+ iframe: properties_1.iframeProperties,
30
+ img: properties_1.imgProperties
25
31
  };
26
32
  /**
27
33
  * Given an element tagname and user props, filters the props to only allowed props for the given
@@ -31,9 +37,36 @@ var nativeElementMap = {
31
37
  * @param excludedPropNames - List of props to disallow
32
38
  */
33
39
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+
34
41
  function getNativeElementProps(tagName, props, excludedPropNames) {
35
- var allowedPropNames = (tagName && nativeElementMap[tagName]) || properties_1.htmlElementProperties;
36
- return properties_1.getNativeProps(props, allowedPropNames, excludedPropNames);
42
+ const allowedPropNames = tagName && nativeElementMap[tagName] || properties_1.htmlElementProperties;
43
+ allowedPropNames.as = 1;
44
+ return properties_1.getNativeProps(props, allowedPropNames, excludedPropNames);
37
45
  }
46
+
38
47
  exports.getNativeElementProps = getNativeElementProps;
48
+ /**
49
+ * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
50
+ *
51
+ * This function is only for use with components that have a primary slot other than `root`.
52
+ * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
53
+ *
54
+ * @returns An object containing the native props for the `root` and primary slots.
55
+ */
56
+
57
+ const getPartitionedNativeProps = ({
58
+ primarySlotTagName,
59
+ props,
60
+ excludedPropNames
61
+ }) => {
62
+ return {
63
+ root: {
64
+ style: props.style,
65
+ className: props.className
66
+ },
67
+ primary: getNativeElementProps(primarySlotTagName, props, [...(excludedPropNames || []), 'style', 'className'])
68
+ };
69
+ };
70
+
71
+ exports.getPartitionedNativeProps = getPartitionedNativeProps;
39
72
  //# sourceMappingURL=getNativeElementProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNativeElementProps.js","sourceRoot":"../src/","sources":["utils/getNativeElementProps.ts"],"names":[],"mappings":";;AACA,2CAuBsB;AAEtB,IAAM,gBAAgB,GAA2C;IAC/D,KAAK,EAAE,4BAAe;IACtB,KAAK,EAAE,4BAAe;IACtB,KAAK,EAAE,4BAAe;IACtB,EAAE,EAAE,yBAAY;IAChB,EAAE,EAAE,yBAAY;IAChB,CAAC,EAAE,6BAAgB;IACnB,MAAM,EAAE,6BAAgB;IACxB,KAAK,EAAE,4BAAe;IACtB,QAAQ,EAAE,+BAAkB;IAC5B,MAAM,EAAE,6BAAgB;IACxB,MAAM,EAAE,6BAAgB;IACxB,KAAK,EAAE,4BAAe;IACtB,EAAE,EAAE,yBAAY;IAChB,EAAE,EAAE,yBAAY;IAChB,EAAE,EAAE,yBAAY;IAChB,QAAQ,EAAE,+BAAkB;IAC5B,GAAG,EAAE,0BAAa;IAClB,IAAI,EAAE,2BAAc;IACpB,MAAM,EAAE,6BAAgB;IACxB,GAAG,EAAE,0BAAa;CACnB,CAAC;AAEF;;;;;;GAMG;AACH,8DAA8D;AAC9D,SAAgB,qBAAqB,CACnC,OAAe,EACf,KAAS,EACT,iBAA4B;IAE5B,IAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,kCAAqB,CAAC;IAEzF,OAAO,2BAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AACpE,CAAC;AARD,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
+ {"version":3,"sources":["../../src/utils/getNativeElementProps.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AAyBA,MAAM,gBAAgB,GAA2C;AAC/D,EAAA,KAAK,EAAE,YAAA,CAAA,eADwD;AAE/D,EAAA,KAAK,EAAE,YAAA,CAAA,eAFwD;AAG/D,EAAA,KAAK,EAAE,YAAA,CAAA,eAHwD;AAI/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAJ2D;AAK/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAL2D;AAM/D,EAAA,CAAC,EAAE,YAAA,CAAA,gBAN4D;AAO/D,EAAA,MAAM,EAAE,YAAA,CAAA,gBAPuD;AAQ/D,EAAA,KAAK,EAAE,YAAA,CAAA,eARwD;AAS/D,EAAA,QAAQ,EAAE,YAAA,CAAA,kBATqD;AAU/D,EAAA,MAAM,EAAE,YAAA,CAAA,gBAVuD;AAW/D,EAAA,MAAM,EAAE,YAAA,CAAA,gBAXuD;AAY/D,EAAA,KAAK,EAAE,YAAA,CAAA,eAZwD;AAa/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAb2D;AAc/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAd2D;AAe/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAf2D;AAgB/D,EAAA,QAAQ,EAAE,YAAA,CAAA,kBAhBqD;AAiB/D,EAAA,GAAG,EAAE,YAAA,CAAA,aAjB0D;AAkB/D,EAAA,IAAI,EAAE,YAAA,CAAA,cAlByD;AAmB/D,EAAA,MAAM,EAAE,YAAA,CAAA,gBAnBuD;AAoB/D,EAAA,GAAG,EAAE,YAAA,CAAA;AApB0D,CAAjE;AAuBA;;;;;;AAMG;AACH;;AACA,SAAgB,qBAAhB,CACE,OADF,EAEE,KAFF,EAGE,iBAHF,EAG8B;AAE5B,QAAM,gBAAgB,GAAI,OAAO,IAAI,gBAAgB,CAAC,OAAD,CAA5B,IAA0C,YAAA,CAAA,qBAAnE;AACA,EAAA,gBAAgB,CAAC,EAAjB,GAAsB,CAAtB;AAEA,SAAO,YAAA,CAAA,cAAA,CAAe,KAAf,EAAsB,gBAAtB,EAAwC,iBAAxC,CAAP;AACD;;AATD,OAAA,CAAA,qBAAA,GAAA,qBAAA;AAWA;;;;;;;AAOG;;AACI,MAAM,yBAAyB,GAAG,CAAC;AACxC,EAAA,kBADwC;AAExC,EAAA,KAFwC;AAGxC,EAAA;AAHwC,CAAD,KAapC;AACH,SAAO;AACL,IAAA,IAAI,EAAE;AAAE,MAAA,KAAK,EAAE,KAAK,CAAC,KAAf;AAAsB,MAAA,SAAS,EAAE,KAAK,CAAC;AAAvC,KADD;AAEL,IAAA,OAAO,EAAE,qBAAqB,CAAC,kBAAD,EAAqB,KAArB,EAA4B,CAAC,IAAI,iBAAiB,IAAI,EAAzB,CAAD,EAA+B,OAA/B,EAAwC,WAAxC,CAA5B;AAFzB,GAAP;AAID,CAlBM;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","sourceRoot":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Finds and swaps a provided key for it's right to left format.
3
+ */
4
+ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRTLSafeKey = void 0;
7
+ /**
8
+ * Finds and swaps a provided key for it's right to left format.
9
+ */
10
+
11
+ const getRTLSafeKey = (key, dir) => {
12
+ if (dir === 'rtl') {
13
+ switch (key) {
14
+ case 'ArrowLeft':
15
+ {
16
+ return 'ArrowRight';
17
+ }
18
+
19
+ case 'ArrowRight':
20
+ {
21
+ return 'ArrowLeft';
22
+ }
23
+ }
24
+ }
25
+
26
+ return key;
27
+ };
28
+
29
+ exports.getRTLSafeKey = getRTLSafeKey;
30
+ //# sourceMappingURL=getRTLSafeKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/getRTLSafeKey.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACI,MAAM,aAAa,GAAG,CAAC,GAAD,EAAc,GAAd,KAAoC;AAC/D,MAAI,GAAG,KAAK,KAAZ,EAAmB;AACjB,YAAQ,GAAR;AACE,WAAK,WAAL;AAAkB;AAChB,iBAAO,YAAP;AACD;;AAED,WAAK,YAAL;AAAmB;AACjB,iBAAO,WAAP;AACD;AAPH;AASD;;AAED,SAAO,GAAP;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourceRoot":""}
@@ -1,3 +1,8 @@
1
+ export * from './applyTriggerPropsToChildren';
2
+ export * from './clamp';
1
3
  export * from './getNativeElementProps';
4
+ export * from './getRTLSafeKey';
2
5
  export * from './omit';
6
+ export * from './onlyChild';
3
7
  export * from './properties';
8
+ export * from './shouldPreventDefaultOnKeyDown';
@@ -1,7 +1,24 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./applyTriggerPropsToChildren"), exports);
10
+
11
+ tslib_1.__exportStar(require("./clamp"), exports);
12
+
4
13
  tslib_1.__exportStar(require("./getNativeElementProps"), exports);
14
+
15
+ tslib_1.__exportStar(require("./getRTLSafeKey"), exports);
16
+
5
17
  tslib_1.__exportStar(require("./omit"), exports);
18
+
19
+ tslib_1.__exportStar(require("./onlyChild"), exports);
20
+
6
21
  tslib_1.__exportStar(require("./properties"), exports);
22
+
23
+ tslib_1.__exportStar(require("./shouldPreventDefaultOnKeyDown"), exports);
7
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC;AACxC,iDAAuB;AACvB,uDAA6B","sourcesContent":["export * from './getNativeElementProps';\nexport * from './omit';\nexport * from './properties';\n"]}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -11,4 +11,4 @@
11
11
  * @param obj - The object to clone
12
12
  * @param exclusions - The array of keys to exclude
13
13
  */
14
- export declare function omit<TObj extends Record<string, any>>(obj: TObj, exclusions: (keyof TObj)[]): TObj;
14
+ export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.omit = void 0;
3
7
  /**
4
8
  * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
5
9
  * props. This ends up faster than using object ...rest or reduce to filter.
@@ -14,15 +18,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
18
  * @param exclusions - The array of keys to exclude
15
19
  */
16
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+
17
22
  function omit(obj, exclusions) {
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- var result = {};
20
- for (var key in obj) {
21
- if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
22
- result[key] = obj[key];
23
- }
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ const result = {};
25
+
26
+ for (const key in obj) {
27
+ if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
28
+ result[key] = obj[key];
24
29
  }
25
- return result;
30
+ }
31
+
32
+ return result;
26
33
  }
34
+
27
35
  exports.omit = omit;
28
36
  //# sourceMappingURL=omit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"omit.js","sourceRoot":"../src/","sources":["utils/omit.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,8DAA8D;AAC9D,SAAgB,IAAI,CAAmC,GAAS,EAAE,UAA0B;IAC1F,8DAA8D;IAC9D,IAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YAC7D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;SACxB;KACF;IAED,OAAO,MAAc,CAAC;AACxB,CAAC;AAXD,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
+ {"version":3,"sources":["../../src/utils/omit.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;AAYG;AACH;;AACA,SAAgB,IAAhB,CACE,GADF,EAEE,UAFF,EAEwB;AAEtB;AACA,QAAM,MAAM,GAAwB,EAApC;;AAEA,OAAK,MAAM,GAAX,IAAkB,GAAlB,EAAuB;AACrB,QAAI,UAAU,CAAC,OAAX,CAAmB,GAAnB,MAA4B,CAAC,CAA7B,IAAkC,GAAG,CAAC,cAAJ,CAAmB,GAAnB,CAAtC,EAA+D;AAC7D,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,GAAG,CAAC,GAAD,CAAjB;AACD;AACF;;AAED,SAAO,MAAP;AACD;;AAdD,OAAA,CAAA,IAAA,GAAA,IAAA","sourceRoot":""}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
+ */
5
+ export declare const onlyChild: <P>(child: string | number | boolean | {} | React.ReactNodeArray | React.ReactPortal | React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined) => React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.onlyChild = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+ /**
10
+ * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
11
+ */
12
+
13
+
14
+ const onlyChild = child => {
15
+ if (!React.isValidElement(child)) {
16
+ throw new Error(`Component's child must be a single element`);
17
+ }
18
+
19
+ return child.type === React.Fragment ? exports.onlyChild(child.props.children) : child;
20
+ };
21
+
22
+ exports.onlyChild = onlyChild;
23
+ //# sourceMappingURL=onlyChild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,SAAS,GACpB,KADuB,IAEE;AACzB,MAAI,CAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,OAAA,CAAA,SAAA,CAAU,KAAK,CAAC,KAAN,CAAY,QAAtB,CAAhC,GAAkE,KAAzE;AACD,CARM;;AAAM,OAAA,CAAA,SAAA,GAAS,SAAT","sourceRoot":""}