@fluentui/react-utilities 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

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 (229) hide show
  1. package/CHANGELOG.json +355 -9
  2. package/CHANGELOG.md +185 -70
  3. package/dist/index.d.ts +517 -0
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/compose/getSlots.js +21 -30
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.js +0 -1
  8. package/lib/compose/index.js.map +1 -1
  9. package/lib/compose/resolveShorthand.js +13 -12
  10. package/lib/compose/resolveShorthand.js.map +1 -1
  11. package/lib/compose/types.js +1 -5
  12. package/lib/compose/types.js.map +1 -1
  13. package/lib/hooks/index.js +2 -6
  14. package/lib/hooks/index.js.map +1 -1
  15. package/lib/hooks/useControllableState.js +26 -26
  16. package/lib/hooks/useControllableState.js.map +1 -1
  17. package/lib/hooks/useEventCallback.js +6 -12
  18. package/lib/hooks/useEventCallback.js.map +1 -1
  19. package/lib/hooks/useFirstMount.js +1 -1
  20. package/lib/hooks/useFirstMount.js.map +1 -1
  21. package/lib/hooks/useForceUpdate.js +1 -3
  22. package/lib/hooks/useForceUpdate.js.map +1 -1
  23. package/lib/hooks/useId.js +9 -5
  24. package/lib/hooks/useId.js.map +1 -1
  25. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -1
  26. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  27. package/lib/hooks/useMergedEventCallbacks.js +26 -0
  28. package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
  29. package/lib/hooks/useMergedRefs.js +5 -13
  30. package/lib/hooks/useMergedRefs.js.map +1 -1
  31. package/lib/hooks/useOnClickOutside.js +30 -36
  32. package/lib/hooks/useOnClickOutside.js.map +1 -1
  33. package/lib/hooks/useOnScrollOutside.js +13 -15
  34. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  35. package/lib/hooks/usePrevious.js +3 -3
  36. package/lib/hooks/usePrevious.js.map +1 -1
  37. package/lib/hooks/useTimeout.js +13 -18
  38. package/lib/hooks/useTimeout.js.map +1 -1
  39. package/lib/index.js +4 -4
  40. package/lib/index.js.map +1 -1
  41. package/lib/ssr/SSRContext.js +9 -15
  42. package/lib/ssr/SSRContext.js.map +1 -1
  43. package/lib/ssr/canUseDOM.js.map +1 -1
  44. package/lib/ssr/index.js.map +1 -1
  45. package/lib/utils/applyTriggerPropsToChildren.js +24 -4
  46. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  47. package/lib/utils/clamp.js +1 -3
  48. package/lib/utils/clamp.js.map +1 -1
  49. package/lib/utils/getNativeElementProps.js +28 -4
  50. package/lib/utils/getNativeElementProps.js.map +1 -1
  51. package/lib/utils/getRTLSafeKey.js +1 -1
  52. package/lib/utils/getRTLSafeKey.js.map +1 -1
  53. package/lib/utils/getReactCallbackName.js +26 -0
  54. package/lib/utils/getReactCallbackName.js.map +1 -0
  55. package/lib/utils/getTriggerChild.js +26 -0
  56. package/lib/utils/getTriggerChild.js.map +1 -0
  57. package/lib/utils/index.js +2 -1
  58. package/lib/utils/index.js.map +1 -1
  59. package/lib/utils/isFluentTrigger.js +8 -0
  60. package/lib/utils/isFluentTrigger.js.map +1 -0
  61. package/lib/utils/omit.js +2 -2
  62. package/lib/utils/omit.js.map +1 -1
  63. package/lib/utils/properties.js +72 -49
  64. package/lib/utils/properties.js.map +1 -1
  65. package/lib/utils/shouldPreventDefaultOnKeyDown.js +8 -4
  66. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  67. package/lib-commonjs/compose/getSlots.js +23 -34
  68. package/lib-commonjs/compose/getSlots.js.map +1 -1
  69. package/lib-commonjs/compose/index.js +1 -3
  70. package/lib-commonjs/compose/index.js.map +1 -1
  71. package/lib-commonjs/compose/resolveShorthand.js +14 -14
  72. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  73. package/lib-commonjs/compose/types.js +1 -5
  74. package/lib-commonjs/compose/types.js.map +1 -1
  75. package/lib-commonjs/hooks/index.js +5 -13
  76. package/lib-commonjs/hooks/index.js.map +1 -1
  77. package/lib-commonjs/hooks/useControllableState.js +27 -28
  78. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  79. package/lib-commonjs/hooks/useEventCallback.js +8 -14
  80. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  81. package/lib-commonjs/hooks/useFirstMount.js +2 -2
  82. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  83. package/lib-commonjs/hooks/useForceUpdate.js +2 -4
  84. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  85. package/lib-commonjs/hooks/useId.js +11 -7
  86. package/lib-commonjs/hooks/useId.js.map +1 -1
  87. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +2 -2
  88. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  89. package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
  90. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
  91. package/lib-commonjs/hooks/useMergedRefs.js +6 -15
  92. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  93. package/lib-commonjs/hooks/useOnClickOutside.js +32 -38
  94. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  95. package/lib-commonjs/hooks/useOnScrollOutside.js +15 -17
  96. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  97. package/lib-commonjs/hooks/usePrevious.js +4 -4
  98. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  99. package/lib-commonjs/hooks/useTimeout.js +14 -20
  100. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  101. package/lib-commonjs/index.js +158 -5
  102. package/lib-commonjs/index.js.map +1 -1
  103. package/lib-commonjs/ssr/SSRContext.js +9 -15
  104. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  105. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  106. package/lib-commonjs/ssr/index.js +1 -1
  107. package/lib-commonjs/ssr/index.js.map +1 -1
  108. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +26 -6
  109. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  110. package/lib-commonjs/utils/clamp.js +1 -3
  111. package/lib-commonjs/utils/clamp.js.map +1 -1
  112. package/lib-commonjs/utils/getNativeElementProps.js +31 -5
  113. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  114. package/lib-commonjs/utils/getRTLSafeKey.js +1 -1
  115. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  116. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  117. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  118. package/lib-commonjs/utils/getTriggerChild.js +37 -0
  119. package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
  120. package/lib-commonjs/utils/index.js +5 -3
  121. package/lib-commonjs/utils/index.js.map +1 -1
  122. package/lib-commonjs/utils/isFluentTrigger.js +17 -0
  123. package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
  124. package/lib-commonjs/utils/omit.js +2 -2
  125. package/lib-commonjs/utils/omit.js.map +1 -1
  126. package/lib-commonjs/utils/properties.js +70 -47
  127. package/lib-commonjs/utils/properties.js.map +1 -1
  128. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +9 -5
  129. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  130. package/package.json +14 -17
  131. package/dist/react-utilities.d.ts +0 -648
  132. package/lib/compose/getSlots.d.ts +0 -29
  133. package/lib/compose/index.d.ts +0 -4
  134. package/lib/compose/nullRender.d.ts +0 -4
  135. package/lib/compose/nullRender.js +0 -7
  136. package/lib/compose/nullRender.js.map +0 -1
  137. package/lib/compose/resolveShorthand.d.ts +0 -12
  138. package/lib/compose/types.d.ts +0 -104
  139. package/lib/hooks/index.d.ts +0 -16
  140. package/lib/hooks/useBoolean.d.ts +0 -17
  141. package/lib/hooks/useBoolean.js +0 -39
  142. package/lib/hooks/useBoolean.js.map +0 -1
  143. package/lib/hooks/useConst.d.ts +0 -12
  144. package/lib/hooks/useConst.js +0 -30
  145. package/lib/hooks/useConst.js.map +0 -1
  146. package/lib/hooks/useControllableState.d.ts +0 -21
  147. package/lib/hooks/useControllableValue.d.ts +0 -20
  148. package/lib/hooks/useControllableValue.js +0 -62
  149. package/lib/hooks/useControllableValue.js.map +0 -1
  150. package/lib/hooks/useEventCallback.d.ts +0 -13
  151. package/lib/hooks/useFirstMount.d.ts +0 -11
  152. package/lib/hooks/useForceUpdate.d.ts +0 -4
  153. package/lib/hooks/useId.d.ts +0 -15
  154. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  155. package/lib/hooks/useMergedRefs.d.ts +0 -13
  156. package/lib/hooks/useMount.d.ts +0 -6
  157. package/lib/hooks/useMount.js +0 -17
  158. package/lib/hooks/useMount.js.map +0 -1
  159. package/lib/hooks/useOnClickOutside.d.ts +0 -29
  160. package/lib/hooks/useOnScrollOutside.d.ts +0 -5
  161. package/lib/hooks/usePrevious.d.ts +0 -1
  162. package/lib/hooks/useTimeout.d.ts +0 -8
  163. package/lib/hooks/useUnmount.d.ts +0 -6
  164. package/lib/hooks/useUnmount.js +0 -19
  165. package/lib/hooks/useUnmount.js.map +0 -1
  166. package/lib/index.d.ts +0 -4
  167. package/lib/ssr/SSRContext.d.ts +0 -33
  168. package/lib/ssr/canUseDOM.d.ts +0 -4
  169. package/lib/ssr/index.d.ts +0 -2
  170. package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
  171. package/lib/utils/clamp.d.ts +0 -8
  172. package/lib/utils/getNativeElementProps.d.ts +0 -9
  173. package/lib/utils/getRTLSafeKey.d.ts +0 -4
  174. package/lib/utils/index.d.ts +0 -8
  175. package/lib/utils/omit.d.ts +0 -14
  176. package/lib/utils/onlyChild.d.ts +0 -5
  177. package/lib/utils/onlyChild.js +0 -13
  178. package/lib/utils/onlyChild.js.map +0 -1
  179. package/lib/utils/properties.d.ts +0 -148
  180. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
  181. package/lib-commonjs/compose/getSlots.d.ts +0 -29
  182. package/lib-commonjs/compose/index.d.ts +0 -4
  183. package/lib-commonjs/compose/nullRender.d.ts +0 -4
  184. package/lib-commonjs/compose/nullRender.js +0 -16
  185. package/lib-commonjs/compose/nullRender.js.map +0 -1
  186. package/lib-commonjs/compose/resolveShorthand.d.ts +0 -12
  187. package/lib-commonjs/compose/types.d.ts +0 -104
  188. package/lib-commonjs/hooks/index.d.ts +0 -16
  189. package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
  190. package/lib-commonjs/hooks/useBoolean.js +0 -50
  191. package/lib-commonjs/hooks/useBoolean.js.map +0 -1
  192. package/lib-commonjs/hooks/useConst.d.ts +0 -12
  193. package/lib-commonjs/hooks/useConst.js +0 -40
  194. package/lib-commonjs/hooks/useConst.js.map +0 -1
  195. package/lib-commonjs/hooks/useControllableState.d.ts +0 -21
  196. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  197. package/lib-commonjs/hooks/useControllableValue.js +0 -73
  198. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
  199. package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
  200. package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
  201. package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
  202. package/lib-commonjs/hooks/useId.d.ts +0 -15
  203. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  204. package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
  205. package/lib-commonjs/hooks/useMount.d.ts +0 -6
  206. package/lib-commonjs/hooks/useMount.js +0 -27
  207. package/lib-commonjs/hooks/useMount.js.map +0 -1
  208. package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
  209. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
  210. package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
  211. package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
  212. package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
  213. package/lib-commonjs/hooks/useUnmount.js +0 -29
  214. package/lib-commonjs/hooks/useUnmount.js.map +0 -1
  215. package/lib-commonjs/index.d.ts +0 -4
  216. package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
  217. package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
  218. package/lib-commonjs/ssr/index.d.ts +0 -2
  219. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
  220. package/lib-commonjs/utils/clamp.d.ts +0 -8
  221. package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -9
  222. package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
  223. package/lib-commonjs/utils/index.d.ts +0 -8
  224. package/lib-commonjs/utils/omit.d.ts +0 -14
  225. package/lib-commonjs/utils/onlyChild.d.ts +0 -5
  226. package/lib-commonjs/utils/onlyChild.js +0 -23
  227. package/lib-commonjs/utils/onlyChild.js.map +0 -1
  228. package/lib-commonjs/utils/properties.d.ts +0 -148
  229. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useControllableValue = void 0;
7
-
8
- var React = /*#__PURE__*/require("react");
9
-
10
- var useConst_1 = /*#__PURE__*/require("./useConst");
11
-
12
- function useControllableValue(controlledValue, defaultUncontrolledValue, onChange) {
13
- var _a = React.useState(defaultUncontrolledValue),
14
- value = _a[0],
15
- setValue = _a[1];
16
-
17
- var isControlled = useIsControlled(controlledValue);
18
- var currentValue = isControlled ? controlledValue : value; // Duplicate the current value and onChange in refs so they're accessible from
19
- // setValueOrCallOnChange without creating a new callback every time
20
-
21
- var valueRef = React.useRef(currentValue);
22
- var onChangeRef = React.useRef(onChange);
23
- React.useEffect(function () {
24
- valueRef.current = currentValue;
25
- onChangeRef.current = onChange;
26
- }); // To match the behavior of the setter returned by React.useState, this callback's identity
27
- // should never change. This means it MUST NOT directly reference variables that can change.
28
-
29
- var setValueOrCallOnChange = useConst_1.useConst(function () {
30
- return function (update, ev) {
31
- // Assuming here that TValue is not a function, because a controllable value will typically
32
- // be something a user can enter as input
33
- var newValue = typeof update === 'function' ? update(valueRef.current) : update;
34
-
35
- if (onChangeRef.current) {
36
- onChangeRef.current(ev, newValue);
37
- }
38
-
39
- if (!isControlled) {
40
- setValue(newValue);
41
- }
42
- };
43
- });
44
- return [currentValue, setValueOrCallOnChange];
45
- }
46
-
47
- exports.useControllableValue = useControllableValue;
48
- /**
49
- * Helper hook to handle previous comparison of controlled/uncontrolled
50
- * Prints an error when isControlled value switches between subsequent renders
51
- */
52
-
53
- var useIsControlled = function (controlledValue) {
54
- var isControlled = useConst_1.useConst(controlledValue !== undefined);
55
-
56
- if (process.env.NODE_ENV !== 'production') {
57
- // We don't want these warnings in production even though it is against native behaviour
58
- // eslint-disable-next-line react-hooks/rules-of-hooks
59
- React.useEffect(function () {
60
- if (isControlled !== (controlledValue !== undefined)) {
61
- var error = new Error();
62
- var controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
63
- var undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined'; // eslint-disable-next-line no-console
64
-
65
- console.error([// Default react error
66
- 'A component is changing ' + controlWarning + '. This is likely caused by the value', 'changing from ' + undefinedWarning + ' value, which should not happen.', 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.', 'More info: https://reactjs.org/link/controlled-components', error.stack].join(' '));
67
- }
68
- }, [isControlled, controlledValue]);
69
- }
70
-
71
- return isControlled;
72
- };
73
- //# sourceMappingURL=useControllableValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useControllableValue.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;;AAqCA,SAAgB,oBAAhB,CAKE,eALF,EAME,wBANF,EAOE,QAPF,EAOqD;AAE7C,MAAA,EAAA,GAAoB,KAAK,CAAC,QAAN,CAAmC,wBAAnC,CAApB;AAAA,MAAC,KAAK,GAAA,EAAA,CAAA,CAAA,CAAN;AAAA,MAAQ,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAhB;;AACN,MAAM,YAAY,GAAG,eAAe,CAAC,eAAD,CAApC;AACA,MAAM,YAAY,GAAG,YAAY,GAAG,eAAH,GAAqB,KAAtD,CAJmD,CAMnD;AACA;;AACA,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,YAAb,CAAjB;AACA,MAAM,WAAW,GAAG,KAAK,CAAC,MAAN,CAAa,QAAb,CAApB;AACA,EAAA,KAAK,CAAC,SAAN,CAAgB,YAAA;AACd,IAAA,QAAQ,CAAC,OAAT,GAAmB,YAAnB;AACA,IAAA,WAAW,CAAC,OAAZ,GAAsB,QAAtB;AACD,GAHD,EAVmD,CAenD;AACA;;AACA,MAAM,sBAAsB,GAAG,UAAA,CAAA,QAAA,CAAS,YAAA;AAAM,WAAA,UAAC,MAAD,EAAmD,EAAnD,EAA8D;AAC1G;AACA;AACA,UAAM,QAAQ,GAAG,OAAO,MAAP,KAAkB,UAAlB,GAAgC,MAAmB,CAAC,QAAQ,CAAC,OAAV,CAAnD,GAAwE,MAAzF;;AAEA,UAAI,WAAW,CAAC,OAAhB,EAAyB;AACvB,QAAA,WAAW,CAAC,OAAZ,CAAoB,EAApB,EAAyB,QAAzB;AACD;;AAED,UAAI,CAAC,YAAL,EAAmB;AACjB,QAAA,QAAQ,CAAC,QAAD,CAAR;AACD;AAX2C,KAAA;AAY7C,GAZ8B,CAA/B;AAcA,SAAO,CAAC,YAAD,EAAe,sBAAf,CAAP;AACD;;AAvCD,OAAA,CAAA,oBAAA,GAAA,oBAAA;AAyCA;;;AAGG;;AACH,IAAM,eAAe,GAAG,UAAS,eAAT,EAAgC;AACtD,MAAM,YAAY,GAAG,UAAA,CAAA,QAAA,CAAkB,eAAe,KAAK,SAAtC,CAArB;;AAEA,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;AACA;AACA,IAAA,KAAK,CAAC,SAAN,CAAgB,YAAA;AACd,UAAI,YAAY,MAAM,eAAe,KAAK,SAA1B,CAAhB,EAAsD;AACpD,YAAM,KAAK,GAAG,IAAI,KAAJ,EAAd;AAEA,YAAM,cAAc,GAAG,YAAY,GAC/B,uCAD+B,GAE/B,wCAFJ;AAIA,YAAM,gBAAgB,GAAG,YAAY,GAAG,yBAAH,GAA+B,wBAApE,CAPoD,CASpD;;AACA,QAAA,OAAO,CAAC,KAAR,CACE,CACE;AACA,qCAA6B,cAA7B,GAA8C,sCAFhD,EAGE,mBAAmB,gBAAnB,GAAsC,kCAHxC,EAIE,oGAJF,EAKE,2DALF,EAME,KAAK,CAAC,KANR,EAOE,IAPF,CAOO,GAPP,CADF;AAUD;AACF,KAtBD,EAsBG,CAAC,YAAD,EAAe,eAAf,CAtBH;AAuBD;;AAED,SAAO,YAAP;AACD,CAhCD","sourceRoot":""}
@@ -1,13 +0,0 @@
1
- /**
2
- * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
3
- *
4
- * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
5
- * e.g. user props are dependencies which could change on every render
6
- * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
7
- *
8
- * This should not be used often, but can be a useful re-render optimization since the callback is a ref and
9
- * will not be invalidated between re-renders
10
- *
11
- * @param fn - The callback function that will be used
12
- */
13
- export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return;
@@ -1,11 +0,0 @@
1
- /**
2
- * Checks if components was mounted the first time.
3
- * Since concurrent mode will be released in the future this needs to be verified
4
- * Currently (React 17) will always render the initial mount once
5
- * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx
6
- * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx
7
- *
8
- * @example
9
- * const isFirstMount = useFirstMount();
10
- */
11
- export declare function useFirstMount(): boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Forces a re-render, similar to `forceUpdate` in class components.
3
- */
4
- export declare function useForceUpdate(): import("react").DispatchWithoutAction;
@@ -1,15 +0,0 @@
1
- /**
2
- * Resets generated IDs, should be used only in tests.
3
- *
4
- * @private
5
- */
6
- export declare function resetIdsForTests(): void;
7
- /**
8
- * Hook to generate a unique ID.
9
- *
10
- * @param prefix - Optional prefix for the ID
11
- * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
12
- * without conditioning the hook call
13
- * @returns The ID
14
- */
15
- export declare function useId(prefix?: string, providedId?: string): string;
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
4
- * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
5
- * ensure we don't get a render flash for certain operations, but we may also need affected components to render on
6
- * the server.
7
- *
8
- * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
9
- * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
10
- */
11
- export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * A Ref function which can be treated like a ref object in that it has an attached
4
- * current property, which will be updated as the ref is evaluated.
5
- */
6
- export declare type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);
7
- /**
8
- * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
9
- * updates all provided refs
10
- * @param refs - Refs to collectively update with one ref value.
11
- * @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
12
- */
13
- export declare function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Hook which asynchronously executes a callback once the component has been mounted.
3
- *
4
- * @param callback - Function to call before mount.
5
- */
6
- export declare const useMount: (callback: () => void) => void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useMount = void 0;
7
-
8
- var React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook which asynchronously executes a callback once the component has been mounted.
11
- *
12
- * @param callback - Function to call before mount.
13
- */
14
-
15
-
16
- var useMount = function (callback) {
17
- var mountRef = React.useRef(callback);
18
- mountRef.current = callback;
19
- React.useEffect(function () {
20
- var _a;
21
-
22
- (_a = mountRef.current) === null || _a === void 0 ? void 0 : _a.call(mountRef);
23
- }, []);
24
- };
25
-
26
- exports.useMount = useMount;
27
- //# sourceMappingURL=useMount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useMount.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;AAIG;;;AACI,IAAM,QAAQ,GAAG,UAAC,QAAD,EAAqB;AAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,QAAb,CAAjB;AACA,EAAA,QAAQ,CAAC,OAAT,GAAmB,QAAnB;AACA,EAAA,KAAK,CAAC,SAAN,CAAgB,YAAA;;;AACd,KAAA,EAAA,GAAA,QAAQ,CAAC,OAAT,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAA,IAAA,CAAhB,QAAgB,CAAhB;AACD,GAFD,EAEG,EAFH;AAGD,CANM;;AAAM,OAAA,CAAA,QAAA,GAAQ,QAAR","sourceRoot":""}
@@ -1,29 +0,0 @@
1
- import * as React from 'react';
2
- export declare type UseOnClickOrScrollOutsideOptions = {
3
- /**
4
- * The element to listen for the click event
5
- */
6
- element: Document | undefined;
7
- /**
8
- * Refs to elements that check if the click is outside
9
- */
10
- refs: React.MutableRefObject<HTMLElement | undefined | null>[];
11
- /**
12
- * By default uses element.contains, but custom contain function can be provided
13
- * @param parentRef - provided parent ref
14
- * @param child - event target element
15
- */
16
- contains?(parent: HTMLElement | null, child: HTMLElement): boolean;
17
- /**
18
- * Disables event listeners
19
- */
20
- disabled?: boolean;
21
- /**
22
- * Called if the click is outside the element refs
23
- */
24
- callback: (ev: MouseEvent | TouchEvent) => void;
25
- };
26
- /**
27
- * Utility to perform checks where a click/touch event was made outside a component
28
- */
29
- export declare const useOnClickOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
@@ -1,5 +0,0 @@
1
- import type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';
2
- /**
3
- * Utility to perform checks where a click/touch event was made outside a component
4
- */
5
- export declare const useOnScrollOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
@@ -1 +0,0 @@
1
- export declare const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
@@ -1,8 +0,0 @@
1
- /**
2
- * Helper to manage a browser timeout.
3
- * Ensures that the timeout isn't set multiple times at once,
4
- * and is cleaned up when the component is unloaded.
5
- *
6
- * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
7
- */
8
- export declare function useTimeout(): readonly [(fn: () => void, delay: number) => void, () => void];
@@ -1,6 +0,0 @@
1
- /**
2
- * Hook which synchronously executes a callback when the component is about to unmount.
3
- *
4
- * @param callback - Function to call during unmount.
5
- */
6
- export declare const useUnmount: (callback: () => void) => void;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useUnmount = void 0;
7
-
8
- var React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook which synchronously executes a callback when the component is about to unmount.
11
- *
12
- * @param callback - Function to call during unmount.
13
- */
14
-
15
-
16
- var useUnmount = function (callback) {
17
- var unmountRef = React.useRef(callback);
18
- unmountRef.current = callback;
19
- React.useEffect(function () {
20
- return function () {
21
- var _a;
22
-
23
- (_a = unmountRef.current) === null || _a === void 0 ? void 0 : _a.call(unmountRef);
24
- };
25
- }, []);
26
- };
27
-
28
- exports.useUnmount = useUnmount;
29
- //# sourceMappingURL=useUnmount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useUnmount.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;AAIG;;;AACI,IAAM,UAAU,GAAG,UAAC,QAAD,EAAqB;AAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAa,QAAb,CAAnB;AACA,EAAA,UAAU,CAAC,OAAX,GAAqB,QAArB;AACA,EAAA,KAAK,CAAC,SAAN,CACE,YAAA;AAAM,WAAA,YAAA;;;AACJ,OAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAA,IAAA,CAAlB,UAAkB,CAAlB;AADI,KAAA;AAEL,GAHH,EAIE,EAJF;AAMD,CATM;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","sourceRoot":""}
@@ -1,4 +0,0 @@
1
- export * from './compose/index';
2
- export * from './hooks/index';
3
- export * from './ssr/index';
4
- export * from './utils/index';
@@ -1,33 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- /**
2
- * Verifies if an application can use DOM.
3
- */
4
- export declare function canUseDOM(): boolean;
@@ -1,2 +0,0 @@
1
- export * from './canUseDOM';
2
- export * from './SSRContext';
@@ -1,5 +0,0 @@
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;
@@ -1,8 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;
@@ -1,4 +0,0 @@
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;
@@ -1,8 +0,0 @@
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';
@@ -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>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
@@ -1,5 +0,0 @@
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>)>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.onlyChild = void 0;
7
-
8
- var 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
- var onlyChild = function (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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;AAEG;;;AACI,IAAM,SAAS,GAAG,UACvB,KADuB,EAC8F;AAErH,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":""}
@@ -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,7 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
4
- *
5
- * Useful for situations where a keydown needs to be transformed to a click event
6
- */
7
- export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent): boolean;