@fluentui/react-utilities 0.0.0-nightly050f89bf0020211102.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/CHANGELOG.json +1637 -0
  2. package/CHANGELOG.md +677 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/dist/react-utilities.d.ts +648 -0
  6. package/lib/compose/getSlots.d.ts +29 -0
  7. package/lib/compose/getSlots.js +72 -0
  8. package/lib/compose/getSlots.js.map +1 -0
  9. package/lib/compose/index.d.ts +4 -0
  10. package/lib/compose/index.js +5 -0
  11. package/lib/compose/index.js.map +1 -0
  12. package/lib/compose/nullRender.d.ts +4 -0
  13. package/lib/compose/nullRender.js +7 -0
  14. package/lib/compose/nullRender.js.map +1 -0
  15. package/lib/compose/resolveShorthand.d.ts +12 -0
  16. package/lib/compose/resolveShorthand.js +30 -0
  17. package/lib/compose/resolveShorthand.js.map +1 -0
  18. package/lib/compose/types.d.ts +104 -0
  19. package/lib/compose/types.js +6 -0
  20. package/lib/compose/types.js.map +1 -0
  21. package/lib/hooks/index.d.ts +16 -0
  22. package/lib/hooks/index.js +17 -0
  23. package/lib/hooks/index.js.map +1 -0
  24. package/lib/hooks/useBoolean.d.ts +17 -0
  25. package/lib/hooks/useBoolean.js +39 -0
  26. package/lib/hooks/useBoolean.js.map +1 -0
  27. package/lib/hooks/useConst.d.ts +12 -0
  28. package/lib/hooks/useConst.js +30 -0
  29. package/lib/hooks/useConst.js.map +1 -0
  30. package/lib/hooks/useControllableState.d.ts +21 -0
  31. package/lib/hooks/useControllableState.js +72 -0
  32. package/lib/hooks/useControllableState.js.map +1 -0
  33. package/lib/hooks/useControllableValue.d.ts +20 -0
  34. package/lib/hooks/useControllableValue.js +62 -0
  35. package/lib/hooks/useControllableValue.js.map +1 -0
  36. package/lib/hooks/useEventCallback.d.ts +13 -0
  37. package/lib/hooks/useEventCallback.js +34 -0
  38. package/lib/hooks/useEventCallback.js.map +1 -0
  39. package/lib/hooks/useFirstMount.d.ts +11 -0
  40. package/lib/hooks/useFirstMount.js +23 -0
  41. package/lib/hooks/useFirstMount.js.map +1 -0
  42. package/lib/hooks/useForceUpdate.d.ts +4 -0
  43. package/lib/hooks/useForceUpdate.js +11 -0
  44. package/lib/hooks/useForceUpdate.js.map +1 -0
  45. package/lib/hooks/useId.d.ts +15 -0
  46. package/lib/hooks/useId.js +27 -0
  47. package/lib/hooks/useId.js.map +1 -0
  48. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  49. package/lib/hooks/useIsomorphicLayoutEffect.js +15 -0
  50. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  51. package/lib/hooks/useMergedRefs.d.ts +13 -0
  52. package/lib/hooks/useMergedRefs.js +34 -0
  53. package/lib/hooks/useMergedRefs.js.map +1 -0
  54. package/lib/hooks/useMount.d.ts +6 -0
  55. package/lib/hooks/useMount.js +17 -0
  56. package/lib/hooks/useMount.js.map +1 -0
  57. package/lib/hooks/useOnClickOutside.d.ts +29 -0
  58. package/lib/hooks/useOnClickOutside.js +142 -0
  59. package/lib/hooks/useOnClickOutside.js.map +1 -0
  60. package/lib/hooks/useOnScrollOutside.d.ts +5 -0
  61. package/lib/hooks/useOnScrollOutside.js +38 -0
  62. package/lib/hooks/useOnScrollOutside.js.map +1 -0
  63. package/lib/hooks/usePrevious.d.ts +1 -0
  64. package/lib/hooks/usePrevious.js +9 -0
  65. package/lib/hooks/usePrevious.js.map +1 -0
  66. package/lib/hooks/useTimeout.d.ts +8 -0
  67. package/lib/hooks/useTimeout.js +33 -0
  68. package/lib/hooks/useTimeout.js.map +1 -0
  69. package/lib/hooks/useUnmount.d.ts +6 -0
  70. package/lib/hooks/useUnmount.js +19 -0
  71. package/lib/hooks/useUnmount.js.map +1 -0
  72. package/lib/index.d.ts +4 -0
  73. package/lib/index.js +5 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/ssr/SSRContext.d.ts +33 -0
  76. package/lib/ssr/SSRContext.js +71 -0
  77. package/lib/ssr/SSRContext.js.map +1 -0
  78. package/lib/ssr/canUseDOM.d.ts +4 -0
  79. package/lib/ssr/canUseDOM.js +8 -0
  80. package/lib/ssr/canUseDOM.js.map +1 -0
  81. package/lib/ssr/index.d.ts +2 -0
  82. package/lib/ssr/index.js +3 -0
  83. package/lib/ssr/index.js.map +1 -0
  84. package/lib/tsdoc-metadata.json +11 -0
  85. package/lib/utils/applyTriggerPropsToChildren.d.ts +5 -0
  86. package/lib/utils/applyTriggerPropsToChildren.js +16 -0
  87. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -0
  88. package/lib/utils/clamp.d.ts +8 -0
  89. package/lib/utils/clamp.js +11 -0
  90. package/lib/utils/clamp.js.map +1 -0
  91. package/lib/utils/getNativeElementProps.d.ts +9 -0
  92. package/lib/utils/getNativeElementProps.js +38 -0
  93. package/lib/utils/getNativeElementProps.js.map +1 -0
  94. package/lib/utils/getRTLSafeKey.d.ts +4 -0
  95. package/lib/utils/getRTLSafeKey.js +21 -0
  96. package/lib/utils/getRTLSafeKey.js.map +1 -0
  97. package/lib/utils/index.d.ts +8 -0
  98. package/lib/utils/index.js +9 -0
  99. package/lib/utils/index.js.map +1 -0
  100. package/lib/utils/omit.d.ts +14 -0
  101. package/lib/utils/omit.js +27 -0
  102. package/lib/utils/omit.js.map +1 -0
  103. package/lib/utils/onlyChild.d.ts +5 -0
  104. package/lib/utils/onlyChild.js +13 -0
  105. package/lib/utils/onlyChild.js.map +1 -0
  106. package/lib/utils/properties.d.ts +148 -0
  107. package/lib/utils/properties.js +218 -0
  108. package/lib/utils/properties.js.map +1 -0
  109. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  110. package/lib/utils/shouldPreventDefaultOnKeyDown.js +20 -0
  111. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  112. package/lib-commonjs/compose/getSlots.d.ts +29 -0
  113. package/lib-commonjs/compose/getSlots.js +85 -0
  114. package/lib-commonjs/compose/getSlots.js.map +1 -0
  115. package/lib-commonjs/compose/index.d.ts +4 -0
  116. package/lib-commonjs/compose/index.js +16 -0
  117. package/lib-commonjs/compose/index.js.map +1 -0
  118. package/lib-commonjs/compose/nullRender.d.ts +4 -0
  119. package/lib-commonjs/compose/nullRender.js +16 -0
  120. package/lib-commonjs/compose/nullRender.js.map +1 -0
  121. package/lib-commonjs/compose/resolveShorthand.d.ts +12 -0
  122. package/lib-commonjs/compose/resolveShorthand.js +41 -0
  123. package/lib-commonjs/compose/resolveShorthand.js.map +1 -0
  124. package/lib-commonjs/compose/types.d.ts +104 -0
  125. package/lib-commonjs/compose/types.js +10 -0
  126. package/lib-commonjs/compose/types.js.map +1 -0
  127. package/lib-commonjs/hooks/index.d.ts +16 -0
  128. package/lib-commonjs/hooks/index.js +40 -0
  129. package/lib-commonjs/hooks/index.js.map +1 -0
  130. package/lib-commonjs/hooks/useBoolean.d.ts +17 -0
  131. package/lib-commonjs/hooks/useBoolean.js +50 -0
  132. package/lib-commonjs/hooks/useBoolean.js.map +1 -0
  133. package/lib-commonjs/hooks/useConst.d.ts +12 -0
  134. package/lib-commonjs/hooks/useConst.js +40 -0
  135. package/lib-commonjs/hooks/useConst.js.map +1 -0
  136. package/lib-commonjs/hooks/useControllableState.d.ts +21 -0
  137. package/lib-commonjs/hooks/useControllableState.js +82 -0
  138. package/lib-commonjs/hooks/useControllableState.js.map +1 -0
  139. package/lib-commonjs/hooks/useControllableValue.d.ts +20 -0
  140. package/lib-commonjs/hooks/useControllableValue.js +73 -0
  141. package/lib-commonjs/hooks/useControllableValue.js.map +1 -0
  142. package/lib-commonjs/hooks/useEventCallback.d.ts +13 -0
  143. package/lib-commonjs/hooks/useEventCallback.js +45 -0
  144. package/lib-commonjs/hooks/useEventCallback.js.map +1 -0
  145. package/lib-commonjs/hooks/useFirstMount.d.ts +11 -0
  146. package/lib-commonjs/hooks/useFirstMount.js +33 -0
  147. package/lib-commonjs/hooks/useFirstMount.js.map +1 -0
  148. package/lib-commonjs/hooks/useForceUpdate.d.ts +4 -0
  149. package/lib-commonjs/hooks/useForceUpdate.js +21 -0
  150. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -0
  151. package/lib-commonjs/hooks/useId.d.ts +15 -0
  152. package/lib-commonjs/hooks/useId.js +40 -0
  153. package/lib-commonjs/hooks/useId.js.map +1 -0
  154. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  155. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +24 -0
  156. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  157. package/lib-commonjs/hooks/useMergedRefs.d.ts +13 -0
  158. package/lib-commonjs/hooks/useMergedRefs.js +45 -0
  159. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -0
  160. package/lib-commonjs/hooks/useMount.d.ts +6 -0
  161. package/lib-commonjs/hooks/useMount.js +27 -0
  162. package/lib-commonjs/hooks/useMount.js.map +1 -0
  163. package/lib-commonjs/hooks/useOnClickOutside.d.ts +29 -0
  164. package/lib-commonjs/hooks/useOnClickOutside.js +153 -0
  165. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -0
  166. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +5 -0
  167. package/lib-commonjs/hooks/useOnScrollOutside.js +49 -0
  168. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -0
  169. package/lib-commonjs/hooks/usePrevious.d.ts +1 -0
  170. package/lib-commonjs/hooks/usePrevious.js +19 -0
  171. package/lib-commonjs/hooks/usePrevious.js.map +1 -0
  172. package/lib-commonjs/hooks/useTimeout.d.ts +8 -0
  173. package/lib-commonjs/hooks/useTimeout.js +44 -0
  174. package/lib-commonjs/hooks/useTimeout.js.map +1 -0
  175. package/lib-commonjs/hooks/useUnmount.d.ts +6 -0
  176. package/lib-commonjs/hooks/useUnmount.js +29 -0
  177. package/lib-commonjs/hooks/useUnmount.js.map +1 -0
  178. package/lib-commonjs/index.d.ts +4 -0
  179. package/lib-commonjs/index.js +16 -0
  180. package/lib-commonjs/index.js.map +1 -0
  181. package/lib-commonjs/ssr/SSRContext.d.ts +33 -0
  182. package/lib-commonjs/ssr/SSRContext.js +86 -0
  183. package/lib-commonjs/ssr/SSRContext.js.map +1 -0
  184. package/lib-commonjs/ssr/canUseDOM.d.ts +4 -0
  185. package/lib-commonjs/ssr/canUseDOM.js +17 -0
  186. package/lib-commonjs/ssr/canUseDOM.js.map +1 -0
  187. package/lib-commonjs/ssr/index.d.ts +2 -0
  188. package/lib-commonjs/ssr/index.js +12 -0
  189. package/lib-commonjs/ssr/index.js.map +1 -0
  190. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +5 -0
  191. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +27 -0
  192. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -0
  193. package/lib-commonjs/utils/clamp.d.ts +8 -0
  194. package/lib-commonjs/utils/clamp.js +20 -0
  195. package/lib-commonjs/utils/clamp.js.map +1 -0
  196. package/lib-commonjs/utils/getNativeElementProps.d.ts +9 -0
  197. package/lib-commonjs/utils/getNativeElementProps.js +48 -0
  198. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -0
  199. package/lib-commonjs/utils/getRTLSafeKey.d.ts +4 -0
  200. package/lib-commonjs/utils/getRTLSafeKey.js +30 -0
  201. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -0
  202. package/lib-commonjs/utils/index.d.ts +8 -0
  203. package/lib-commonjs/utils/index.js +24 -0
  204. package/lib-commonjs/utils/index.js.map +1 -0
  205. package/lib-commonjs/utils/omit.d.ts +14 -0
  206. package/lib-commonjs/utils/omit.js +36 -0
  207. package/lib-commonjs/utils/omit.js.map +1 -0
  208. package/lib-commonjs/utils/onlyChild.d.ts +5 -0
  209. package/lib-commonjs/utils/onlyChild.js +23 -0
  210. package/lib-commonjs/utils/onlyChild.js.map +1 -0
  211. package/lib-commonjs/utils/properties.d.ts +148 -0
  212. package/lib-commonjs/utils/properties.js +227 -0
  213. package/lib-commonjs/utils/properties.js.map +1 -0
  214. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
  215. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +30 -0
  216. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
  217. package/package.json +55 -0
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request
4
+ * to ensure the client and server are consistent.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare type SSRContextValue = {
9
+ current: number;
10
+ };
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
+ export declare const defaultSSRContextValue: SSRContextValue;
17
+ export declare const SSRContext: React.Context<SSRContextValue>;
18
+ /**
19
+ * @internal
20
+ */
21
+ export declare function useSSRContext(): SSRContextValue;
22
+ /**
23
+ * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
24
+ * are consistent between the client and server.
25
+ *
26
+ * @public
27
+ */
28
+ export declare const SSRProvider: React.FC;
29
+ /**
30
+ * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
31
+ * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
32
+ */
33
+ export declare function useIsSSR(): boolean;
@@ -0,0 +1,71 @@
1
+ import * as React from 'react';
2
+ import { canUseDOM } from './canUseDOM';
3
+ /**
4
+ * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
5
+ *
6
+ * @internal
7
+ */
8
+
9
+ export var defaultSSRContextValue = {
10
+ current: 0
11
+ };
12
+ export var SSRContext = /*#__PURE__*/React.createContext(defaultSSRContextValue);
13
+ /**
14
+ * @internal
15
+ */
16
+
17
+ export function useSSRContext() {
18
+ return React.useContext(SSRContext);
19
+ }
20
+ /**
21
+ * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
22
+ * are consistent between the client and server.
23
+ *
24
+ * @public
25
+ */
26
+
27
+ export var SSRProvider = function (props) {
28
+ var value = React.useState(function () {
29
+ return {
30
+ current: 0
31
+ };
32
+ })[0];
33
+ return /*#__PURE__*/React.createElement(SSRContext.Provider, {
34
+ value: value
35
+ }, props.children);
36
+ };
37
+ /**
38
+ * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
39
+ * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
40
+ */
41
+
42
+ export function useIsSSR() {
43
+ var isInSSRContext = useSSRContext() !== defaultSSRContextValue;
44
+
45
+ var _a = React.useState(isInSSRContext),
46
+ isSSR = _a[0],
47
+ setIsSSR = _a[1]; // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
48
+ // developer to add one.
49
+
50
+
51
+ if (process.env.NODE_ENV !== 'production') {
52
+ if (!isInSSRContext && !canUseDOM()) {
53
+ // eslint-disable-next-line no-console
54
+ console.error('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.');
55
+ }
56
+ } // If on the client, and the component was initially server rendered, then schedule a layout effect to update the
57
+ // component after hydration.
58
+
59
+
60
+ if (canUseDOM() && isInSSRContext) {
61
+ // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
62
+ // mounting.
63
+ // eslint-disable-next-line
64
+ React.useLayoutEffect(function () {
65
+ setIsSSR(false);
66
+ }, []);
67
+ }
68
+
69
+ return isSSR;
70
+ }
71
+ //# sourceMappingURL=SSRContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ssr/SSRContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,aAA1B;AAYA;;;;AAIG;;AACH,OAAO,IAAM,sBAAsB,GAAoB;AACrD,EAAA,OAAO,EAAE;AAD4C,CAAhD;AAIP,OAAO,IAAM,UAAU,gBAAG,KAAK,CAAC,aAAN,CAAqC,sBAArC,CAAnB;AAEP;;AAEG;;AACH,OAAM,SAAU,aAAV,GAAuB;AAC3B,SAAO,KAAK,CAAC,UAAN,CAAiB,UAAjB,CAAP;AACD;AAED;;;;;AAKG;;AACH,OAAO,IAAM,WAAW,GAAa,UAAA,KAAA,EAAK;AACjC,MAAA,KAAK,GAAI,KAAK,CAAC,QAAN,CAAgC,YAAA;AAAM,WAAC;AAAE,MAAA,OAAO,EAAV;AAAC,KAAD;AAAgB,GAAtD,EAAJ,CAAI,CAAT;AAEP,sBAAO,KAAA,CAAA,aAAA,CAAC,UAAU,CAAC,QAAZ,EAAoB;AAAC,IAAA,KAAK,EAAE;AAAR,GAApB,EAAoC,KAAK,CAAC,QAA1C,CAAP;AACD,CAJM;AAMP;;;AAGG;;AACH,OAAM,SAAU,QAAV,GAAkB;AACtB,MAAM,cAAc,GAAG,aAAa,OAAO,sBAA3C;;AACM,MAAA,EAAA,GAAoB,KAAK,CAAC,QAAN,CAAe,cAAf,CAApB;AAAA,MAAC,KAAK,GAAA,EAAA,CAAA,CAAA,CAAN;AAAA,MAAQ,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAhB,CAFgB,CAItB;AACA;;;AACA,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,QAAI,CAAC,cAAD,IAAmB,CAAC,SAAS,EAAjC,EAAqC;AACnC;AACA,MAAA,OAAO,CAAC,KAAR,CACE,4GACE,0CAFJ;AAID;AACF,GAdqB,CAgBtB;AACA;;;AACA,MAAI,SAAS,MAAM,cAAnB,EAAmC;AACjC;AACA;AACA;AACA,IAAA,KAAK,CAAC,eAAN,CAAsB,YAAA;AACpB,MAAA,QAAQ,CAAC,KAAD,CAAR;AACD,KAFD,EAEG,EAFH;AAGD;;AAED,SAAO,KAAP;AACD","sourceRoot":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Verifies if an application can use DOM.
3
+ */
4
+ export declare function canUseDOM(): boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Verifies if an application can use DOM.
3
+ */
4
+ export function canUseDOM() {
5
+ return typeof window !== 'undefined' && !!(window.document && // eslint-disable-next-line deprecation/deprecation
6
+ window.document.createElement);
7
+ }
8
+ //# sourceMappingURL=canUseDOM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ssr/canUseDOM.ts"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAM,SAAU,SAAV,GAAmB;AACvB,SACE,OAAO,MAAP,KAAkB,WAAlB,IACA,CAAC,EACC,MAAM,CAAC,QAAP,IACA;AACA,EAAA,MAAM,CAAC,QAAP,CAAgB,aAHjB,CAFH;AAQD","sourceRoot":""}
@@ -0,0 +1,2 @@
1
+ export * from './canUseDOM';
2
+ export * from './SSRContext';
@@ -0,0 +1,3 @@
1
+ export * from './canUseDOM';
2
+ export * from './SSRContext';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.18.1"
9
+ }
10
+ ]
11
+ }
@@ -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,16 @@
1
+ import * as React from 'react';
2
+ import { onlyChild } from './onlyChild';
3
+ /**
4
+ * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
5
+ */
6
+
7
+ export var applyTriggerPropsToChildren = function (children, triggerProps) {
8
+ if (typeof children === 'function') {
9
+ return children(triggerProps);
10
+ } else if (children) {
11
+ return /*#__PURE__*/React.cloneElement(onlyChild(children), triggerProps);
12
+ }
13
+
14
+ return children;
15
+ };
16
+ //# sourceMappingURL=applyTriggerPropsToChildren.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/applyTriggerPropsToChildren.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,aAA1B;AAEA;;AAEG;;AACH,OAAO,IAAM,2BAA2B,GAAG,UACzC,QADyC,EAEzC,YAFyC,EAEd;AAE3B,MAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;AAClC,WAAO,QAAQ,CAAC,YAAD,CAAf;AACD,GAFD,MAEO,IAAI,QAAJ,EAAc;AACnB,wBAAO,KAAK,CAAC,YAAN,CAAmB,SAAS,CAAC,QAAD,CAA5B,EAAwC,YAAxC,CAAP;AACD;;AAED,SAAO,QAAP;AACD,CAXM","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,11 @@
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 var clamp = function (value, min, max) {
9
+ return Math.max(min, Math.min(max, value || 0));
10
+ };
11
+ //# sourceMappingURL=clamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACH,OAAO,IAAM,KAAK,GAAG,UAAC,KAAD,EAAgB,GAAhB,EAA6B,GAA7B,EAAwC;AAAa,SAAA,IAAI,CAAC,GAAL,CAAS,GAAT,EAAc,IAAI,CAAC,GAAL,CAAS,GAAT,EAAc,KAAK,IAAjC,CAAc,CAAd,CAAA;AAAwC,CAA3G","sourceRoot":""}
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Given an element tagname and user props, filters the props to only allowed props for the given
4
+ * element type.
5
+ * @param tagName - Tag name (e.g. "div")
6
+ * @param props - Props object
7
+ * @param excludedPropNames - List of props to disallow
8
+ */
9
+ export declare function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
@@ -0,0 +1,38 @@
1
+ import { labelProperties, audioProperties, videoProperties, olProperties, liProperties, anchorProperties, buttonProperties, inputProperties, textAreaProperties, selectProperties, optionProperties, tableProperties, trProperties, thProperties, tdProperties, colGroupProperties, colProperties, formProperties, iframeProperties, imgProperties, htmlElementProperties, getNativeProps } from './properties';
2
+ var nativeElementMap = {
3
+ label: labelProperties,
4
+ audio: audioProperties,
5
+ video: videoProperties,
6
+ ol: olProperties,
7
+ li: liProperties,
8
+ a: anchorProperties,
9
+ button: buttonProperties,
10
+ input: inputProperties,
11
+ textarea: textAreaProperties,
12
+ select: selectProperties,
13
+ option: optionProperties,
14
+ table: tableProperties,
15
+ tr: trProperties,
16
+ th: thProperties,
17
+ td: tdProperties,
18
+ colGroup: colGroupProperties,
19
+ col: colProperties,
20
+ form: formProperties,
21
+ iframe: iframeProperties,
22
+ img: imgProperties
23
+ };
24
+ /**
25
+ * Given an element tagname and user props, filters the props to only allowed props for the given
26
+ * element type.
27
+ * @param tagName - Tag name (e.g. "div")
28
+ * @param props - Props object
29
+ * @param excludedPropNames - List of props to disallow
30
+ */
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+
33
+ export function getNativeElementProps(tagName, props, excludedPropNames) {
34
+ var allowedPropNames = tagName && nativeElementMap[tagName] || htmlElementProperties;
35
+ allowedPropNames.as = 1;
36
+ return getNativeProps(props, allowedPropNames, excludedPropNames);
37
+ }
38
+ //# sourceMappingURL=getNativeElementProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/getNativeElementProps.ts"],"names":[],"mappings":"AACA,SACE,eADF,EAEE,eAFF,EAGE,eAHF,EAIE,YAJF,EAKE,YALF,EAME,gBANF,EAOE,gBAPF,EAQE,eARF,EASE,kBATF,EAUE,gBAVF,EAWE,gBAXF,EAYE,eAZF,EAaE,YAbF,EAcE,YAdF,EAeE,YAfF,EAgBE,kBAhBF,EAiBE,aAjBF,EAkBE,cAlBF,EAmBE,gBAnBF,EAoBE,aApBF,EAqBE,qBArBF,EAsBE,cAtBF,QAuBO,cAvBP;AAyBA,IAAM,gBAAgB,GAA2C;AAC/D,EAAA,KAAK,EAAE,eADwD;AAE/D,EAAA,KAAK,EAAE,eAFwD;AAG/D,EAAA,KAAK,EAAE,eAHwD;AAI/D,EAAA,EAAE,EAAE,YAJ2D;AAK/D,EAAA,EAAE,EAAE,YAL2D;AAM/D,EAAA,CAAC,EAAE,gBAN4D;AAO/D,EAAA,MAAM,EAAE,gBAPuD;AAQ/D,EAAA,KAAK,EAAE,eARwD;AAS/D,EAAA,QAAQ,EAAE,kBATqD;AAU/D,EAAA,MAAM,EAAE,gBAVuD;AAW/D,EAAA,MAAM,EAAE,gBAXuD;AAY/D,EAAA,KAAK,EAAE,eAZwD;AAa/D,EAAA,EAAE,EAAE,YAb2D;AAc/D,EAAA,EAAE,EAAE,YAd2D;AAe/D,EAAA,EAAE,EAAE,YAf2D;AAgB/D,EAAA,QAAQ,EAAE,kBAhBqD;AAiB/D,EAAA,GAAG,EAAE,aAjB0D;AAkB/D,EAAA,IAAI,EAAE,cAlByD;AAmB/D,EAAA,MAAM,EAAE,gBAnBuD;AAoB/D,EAAA,GAAG,EAAE;AApB0D,CAAjE;AAuBA;;;;;;AAMG;AACH;;AACA,OAAM,SAAU,qBAAV,CACJ,OADI,EAEJ,KAFI,EAGJ,iBAHI,EAGwB;AAE5B,MAAM,gBAAgB,GAAI,OAAO,IAAI,gBAAgB,CAAC,OAAD,CAA5B,IAA0C,qBAAnE;AACA,EAAA,gBAAgB,CAAC,EAAjB,GAAsB,CAAtB;AAEA,SAAO,cAAc,CAAC,KAAD,EAAQ,gBAAR,EAA0B,iBAA1B,CAArB;AACD","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,21 @@
1
+ /**
2
+ * Finds and swaps a provided key for it's right to left format.
3
+ */
4
+ export var getRTLSafeKey = function (key, dir) {
5
+ if (dir === 'rtl') {
6
+ switch (key) {
7
+ case 'ArrowLeft':
8
+ {
9
+ return 'ArrowRight';
10
+ }
11
+
12
+ case 'ArrowRight':
13
+ {
14
+ return 'ArrowLeft';
15
+ }
16
+ }
17
+ }
18
+
19
+ return key;
20
+ };
21
+ //# sourceMappingURL=getRTLSafeKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/getRTLSafeKey.ts"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAO,IAAM,aAAa,GAAG,UAAC,GAAD,EAAc,GAAd,EAAgC;AAC3D,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","sourceRoot":""}
@@ -0,0 +1,8 @@
1
+ export * from './applyTriggerPropsToChildren';
2
+ export * from './clamp';
3
+ export * from './getNativeElementProps';
4
+ export * from './getRTLSafeKey';
5
+ export * from './omit';
6
+ export * from './onlyChild';
7
+ export * from './properties';
8
+ export * from './shouldPreventDefaultOnKeyDown';
@@ -0,0 +1,9 @@
1
+ export * from './applyTriggerPropsToChildren';
2
+ export * from './clamp';
3
+ export * from './getNativeElementProps';
4
+ export * from './getRTLSafeKey';
5
+ export * from './omit';
6
+ export * from './onlyChild';
7
+ export * from './properties';
8
+ export * from './shouldPreventDefaultOnKeyDown';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,14 @@
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>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
@@ -0,0 +1,27 @@
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
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ export function omit(obj, exclusions) {
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ var result = {};
18
+
19
+ for (var key in obj) {
20
+ if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
21
+ result[key] = obj[key];
22
+ }
23
+ }
24
+
25
+ return result;
26
+ }
27
+ //# sourceMappingURL=omit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;AAYG;AACH;AACA,OAAM,SAAU,IAAV,CACJ,GADI,EAEJ,UAFI,EAEkB;AAEtB;AACA,MAAM,MAAM,GAAwB,EAApC;;AAEA,OAAK,IAAM,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","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,13 @@
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
+
6
+ export var onlyChild = function (child) {
7
+ if (! /*#__PURE__*/React.isValidElement(child)) {
8
+ throw new Error("Component's child must be a single element");
9
+ }
10
+
11
+ return child.type === React.Fragment ? onlyChild(child.props.children) : child;
12
+ };
13
+ //# sourceMappingURL=onlyChild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;AAEG;;AACH,OAAO,IAAM,SAAS,GAAG,UACvB,KADuB,EAC8F;AAErH,MAAI,eAAC,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,SAAS,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,CAAzC,GAAkE,KAAzE;AACD,CARM","sourceRoot":""}
@@ -0,0 +1,148 @@
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;