@prom-ui/core 1.3.1 → 1.4.0

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 (233) hide show
  1. package/Avatar/cjs/index.development.js +99 -67
  2. package/Avatar/cjs/index.development.v2.js +99 -67
  3. package/Avatar/cjs/index.production.js +1 -1
  4. package/Avatar/cjs/index.production.v2.js +1 -1
  5. package/Avatar/index.d.ts +14 -14
  6. package/Avatar/package.json +1 -1
  7. package/Avatar/utils.d.ts +2 -2
  8. package/Backdrop/cjs/index.development.js +131 -77
  9. package/Backdrop/cjs/index.development.v2.js +131 -77
  10. package/Backdrop/cjs/index.production.js +1 -1
  11. package/Backdrop/cjs/index.production.v2.js +1 -1
  12. package/Backdrop/index.d.ts +25 -25
  13. package/Backdrop/package.json +1 -1
  14. package/Body/cjs/index.development.js +2 -0
  15. package/Body/cjs/index.development.v2.js +2 -0
  16. package/Body/index.d.ts +36 -36
  17. package/Body/package.json +1 -1
  18. package/BodyContext/cjs/index.development.js +6 -7
  19. package/BodyContext/cjs/index.development.v2.js +6 -7
  20. package/BodyContext/cjs/index.production.js +1 -1
  21. package/BodyContext/cjs/index.production.v2.js +1 -1
  22. package/BodyContext/index.d.ts +12 -12
  23. package/BodyContext/package.json +1 -1
  24. package/BodyProvider/cjs/index.development.js +7 -6
  25. package/BodyProvider/cjs/index.development.v2.js +7 -6
  26. package/BodyProvider/index.d.ts +10 -10
  27. package/BodyProvider/package.json +1 -1
  28. package/Box/cjs/index.development.js +4 -4
  29. package/Box/cjs/index.development.v2.js +4 -4
  30. package/Box/index.d.ts +106 -106
  31. package/Box/package.json +1 -1
  32. package/Button/cjs/index.development.js +67 -62
  33. package/Button/cjs/index.development.v2.js +67 -62
  34. package/Button/cjs/index.production.js +1 -1
  35. package/Button/cjs/index.production.v2.js +1 -1
  36. package/Button/index.d.ts +45 -45
  37. package/Button/package.json +1 -1
  38. package/ButtonPageUp/cjs/index.development.js +195 -85
  39. package/ButtonPageUp/cjs/index.development.v2.js +195 -85
  40. package/ButtonPageUp/cjs/index.production.js +1 -1
  41. package/ButtonPageUp/cjs/index.production.v2.js +1 -1
  42. package/ButtonPageUp/index.d.ts +18 -18
  43. package/ButtonPageUp/package.json +1 -1
  44. package/Checkbox/cjs/index.development.js +99 -67
  45. package/Checkbox/cjs/index.development.v2.js +99 -67
  46. package/Checkbox/cjs/index.production.js +1 -1
  47. package/Checkbox/cjs/index.production.v2.js +1 -1
  48. package/Checkbox/index.d.ts +8 -8
  49. package/Checkbox/package.json +1 -1
  50. package/Flex/index.d.ts +34 -34
  51. package/Flex/package.json +1 -1
  52. package/Grid/index.d.ts +46 -46
  53. package/Grid/package.json +1 -1
  54. package/Icon/index.d.ts +9 -9
  55. package/Icon/package.json +1 -1
  56. package/Image/index.d.ts +42 -42
  57. package/Image/package.json +1 -1
  58. package/ImageEmoji/cjs/index.development.js +70 -63
  59. package/ImageEmoji/cjs/index.development.v2.js +70 -63
  60. package/ImageEmoji/cjs/index.production.js +1 -1
  61. package/ImageEmoji/cjs/index.production.v2.js +1 -1
  62. package/ImageEmoji/index.d.ts +9 -9
  63. package/ImageEmoji/package.json +1 -1
  64. package/Input/index.d.ts +18 -18
  65. package/Input/package.json +1 -1
  66. package/InputField/addons/AfterClearValue.d.ts +3 -3
  67. package/InputField/addons/AfterCorrectValue.d.ts +2 -2
  68. package/InputField/addons/AfterLoading.d.ts +2 -2
  69. package/InputField/addons/AfterTogglePassword.d.ts +6 -6
  70. package/InputField/addons/ErrorText.d.ts +6 -6
  71. package/InputField/cjs/index.development.js +237 -173
  72. package/InputField/cjs/index.development.v2.js +237 -173
  73. package/InputField/cjs/index.production.js +1 -1
  74. package/InputField/cjs/index.production.v2.js +1 -1
  75. package/InputField/index.d.ts +18 -18
  76. package/InputField/package.json +1 -1
  77. package/InputField/utils.d.ts +10 -10
  78. package/KeyPress/cjs/index.development.js +13 -13
  79. package/KeyPress/cjs/index.development.v2.js +13 -13
  80. package/KeyPress/index.d.ts +14 -14
  81. package/KeyPress/package.json +1 -1
  82. package/Line/index.d.ts +13 -13
  83. package/Line/package.json +1 -1
  84. package/Link/cjs/index.development.js +5 -5
  85. package/Link/cjs/index.development.v2.js +5 -5
  86. package/Link/index.d.ts +28 -28
  87. package/Link/package.json +1 -1
  88. package/List/index.d.ts +23 -23
  89. package/List/package.json +1 -1
  90. package/Media/MediaProvider.d.ts +8 -8
  91. package/Media/cjs/index.development.js +70 -19
  92. package/Media/cjs/index.development.v2.js +70 -19
  93. package/Media/cjs/index.production.js +1 -1
  94. package/Media/cjs/index.production.v2.js +1 -1
  95. package/Media/index.d.ts +20 -20
  96. package/Media/package.json +1 -1
  97. package/OutsideClick/cjs/index.development.js +117 -61
  98. package/OutsideClick/cjs/index.development.v2.js +117 -61
  99. package/OutsideClick/cjs/index.production.js +1 -1
  100. package/OutsideClick/cjs/index.production.v2.js +1 -1
  101. package/OutsideClick/index.d.ts +12 -12
  102. package/OutsideClick/package.json +1 -1
  103. package/Overlay/cjs/index.development.js +197 -183
  104. package/Overlay/cjs/index.development.v2.js +197 -183
  105. package/Overlay/cjs/index.production.js +1 -1
  106. package/Overlay/cjs/index.production.v2.js +1 -1
  107. package/Overlay/components/OverlayHeader.d.ts +11 -11
  108. package/Overlay/components/SwipeClose.d.ts +11 -11
  109. package/Overlay/components/TouchScrollable.d.ts +8 -8
  110. package/Overlay/index.d.ts +76 -76
  111. package/Overlay/package.json +1 -1
  112. package/Overlay/utils.d.ts +10 -10
  113. package/Picture/index.d.ts +70 -70
  114. package/Picture/package.json +1 -1
  115. package/Portal/cjs/index.development.js +11 -11
  116. package/Portal/cjs/index.development.v2.js +11 -11
  117. package/Portal/index.d.ts +10 -10
  118. package/Portal/package.json +1 -1
  119. package/QRCode/cjs/index.development.js +11 -11
  120. package/QRCode/cjs/index.development.v2.js +11 -11
  121. package/QRCode/index.d.ts +17 -17
  122. package/QRCode/package.json +1 -1
  123. package/Rating/cjs/index.development.js +75 -69
  124. package/Rating/cjs/index.development.v2.js +75 -69
  125. package/Rating/cjs/index.production.js +1 -1
  126. package/Rating/cjs/index.production.v2.js +1 -1
  127. package/Rating/index.d.ts +17 -17
  128. package/Rating/package.json +1 -1
  129. package/RatingSelect/cjs/index.development.js +148 -68
  130. package/RatingSelect/cjs/index.development.v2.js +148 -68
  131. package/RatingSelect/cjs/index.production.js +1 -1
  132. package/RatingSelect/cjs/index.production.v2.js +1 -1
  133. package/RatingSelect/index.d.ts +22 -18
  134. package/RatingSelect/package.json +1 -1
  135. package/SafeQuery/cjs/index.development.js +158 -110
  136. package/SafeQuery/cjs/index.development.v2.js +158 -110
  137. package/SafeQuery/cjs/index.production.js +1 -1
  138. package/SafeQuery/cjs/index.production.v2.js +1 -1
  139. package/SafeQuery/components/Error.d.ts +7 -7
  140. package/SafeQuery/index.d.ts +10 -10
  141. package/SafeQuery/package.json +1 -1
  142. package/Scroll/index.d.ts +25 -25
  143. package/Scroll/package.json +1 -1
  144. package/ScrollControls/ScrollControlsButton.d.ts +11 -11
  145. package/ScrollControls/cjs/index.development.js +201 -113
  146. package/ScrollControls/cjs/index.development.v2.js +201 -113
  147. package/ScrollControls/cjs/index.production.js +1 -1
  148. package/ScrollControls/cjs/index.production.v2.js +1 -1
  149. package/ScrollControls/index.d.ts +16 -16
  150. package/ScrollControls/package.json +1 -1
  151. package/SimpleSlider/cjs/index.development.js +270 -158
  152. package/SimpleSlider/cjs/index.development.v2.js +270 -158
  153. package/SimpleSlider/cjs/index.production.js +1 -1
  154. package/SimpleSlider/cjs/index.production.v2.js +1 -1
  155. package/SimpleSlider/index.d.ts +41 -41
  156. package/SimpleSlider/package.json +1 -1
  157. package/SimpleSlider/useAutoPlay.d.ts +3 -3
  158. package/SimpleSlider/utils.d.ts +19 -19
  159. package/Skeleton/cjs/index.development.js +118 -64
  160. package/Skeleton/cjs/index.development.v2.js +118 -64
  161. package/Skeleton/cjs/index.production.js +1 -1
  162. package/Skeleton/cjs/index.production.v2.js +1 -1
  163. package/Skeleton/index.d.ts +37 -37
  164. package/Skeleton/package.json +1 -1
  165. package/Spinner/cjs/index.development.js +66 -61
  166. package/Spinner/cjs/index.development.v2.js +66 -61
  167. package/Spinner/cjs/index.production.js +1 -1
  168. package/Spinner/cjs/index.production.v2.js +1 -1
  169. package/Spinner/index.d.ts +29 -29
  170. package/Spinner/package.json +1 -1
  171. package/Text/index.d.ts +25 -25
  172. package/Text/package.json +1 -1
  173. package/TextEmoji/cjs/index.development.js +65 -60
  174. package/TextEmoji/cjs/index.development.v2.js +65 -60
  175. package/TextEmoji/cjs/index.production.js +1 -1
  176. package/TextEmoji/cjs/index.production.v2.js +1 -1
  177. package/TextEmoji/index.d.ts +9 -9
  178. package/TextEmoji/package.json +1 -1
  179. package/Tooltip/cjs/index.development.js +80 -91
  180. package/Tooltip/cjs/index.development.v2.js +80 -91
  181. package/Tooltip/cjs/index.production.js +1 -1
  182. package/Tooltip/cjs/index.production.v2.js +1 -1
  183. package/Tooltip/index.d.ts +87 -87
  184. package/Tooltip/package.json +1 -1
  185. package/Tumbler/cjs/index.development.js +98 -66
  186. package/Tumbler/cjs/index.development.v2.js +98 -66
  187. package/Tumbler/cjs/index.production.js +1 -1
  188. package/Tumbler/cjs/index.production.v2.js +1 -1
  189. package/Tumbler/index.d.ts +8 -8
  190. package/Tumbler/package.json +1 -1
  191. package/package.json +7 -5
  192. package/useBodyTTag/cjs/index.development.js +1 -1
  193. package/useBodyTTag/cjs/index.development.v2.js +1 -1
  194. package/useBodyTTag/index.d.ts +2 -2
  195. package/useBodyTTag/package.json +1 -1
  196. package/useDebounce/cjs/index.development.js +58 -6
  197. package/useDebounce/cjs/index.development.v2.js +58 -6
  198. package/useDebounce/cjs/index.production.js +1 -1
  199. package/useDebounce/cjs/index.production.v2.js +1 -1
  200. package/useDebounce/index.d.ts +4 -4
  201. package/useDebounce/package.json +1 -1
  202. package/useId/cjs/index.development.js +6 -7
  203. package/useId/cjs/index.development.v2.js +6 -7
  204. package/useId/cjs/index.production.js +1 -1
  205. package/useId/cjs/index.production.v2.js +1 -1
  206. package/useId/index.d.ts +4 -4
  207. package/useId/package.json +1 -1
  208. package/useIsMounted/cjs/index.development.js +3 -3
  209. package/useIsMounted/cjs/index.development.v2.js +3 -3
  210. package/useIsMounted/index.d.ts +4 -4
  211. package/useIsMounted/package.json +1 -1
  212. package/useKeyPress/cjs/index.development.js +76 -22
  213. package/useKeyPress/cjs/index.development.v2.js +76 -22
  214. package/useKeyPress/cjs/index.production.js +1 -1
  215. package/useKeyPress/cjs/index.production.v2.js +1 -1
  216. package/useKeyPress/index.d.ts +6 -6
  217. package/useKeyPress/package.json +1 -1
  218. package/useMedia/cjs/index.development.js +5 -5
  219. package/useMedia/cjs/index.development.v2.js +5 -5
  220. package/useMedia/index.d.ts +21 -21
  221. package/useMedia/package.json +1 -1
  222. package/useOutsideClick/cjs/index.development.js +2 -2
  223. package/useOutsideClick/cjs/index.development.v2.js +2 -2
  224. package/useOutsideClick/index.d.ts +5 -5
  225. package/useOutsideClick/package.json +1 -1
  226. package/usePortal/cjs/index.development.js +32 -27
  227. package/usePortal/cjs/index.development.v2.js +32 -27
  228. package/usePortal/index.d.ts +12 -12
  229. package/usePortal/package.json +1 -1
  230. package/useScrollPosition/cjs/index.development.js +2 -2
  231. package/useScrollPosition/cjs/index.development.v2.js +2 -2
  232. package/useScrollPosition/index.d.ts +5 -5
  233. package/useScrollPosition/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";function e(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react"));exports.useKeyPress=function(e,n,r){var u=t.useState(!1),o=u[0],i=u[1],c=function(t){t.key===e&&(n?n(t):i(!0))},f=function(t){t.key===e&&(r?r(t):i(!1))};return t.useEffect((function(){return window.addEventListener("keydown",c),window.addEventListener("keyup",f),function(){window.removeEventListener("keydown",c),window.removeEventListener("keyup",f)}}),[e,n,r]),o};
1
+ "use strict";function e(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react"));function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,i,a=[],c=!0,f=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=u.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(l){f=!0,o=l}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw o}}return a}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}exports.useKeyPress=function(e,n,o){var u=r(t.useState(!1),2),i=u[0],a=u[1],c=function(t){t.key===e&&(n?n(t):a(!0))},f=function(t){t.key===e&&(o?o(t):a(!1))};return t.useEffect((function(){return window.addEventListener("keydown",c),window.addEventListener("keyup",f),function(){window.removeEventListener("keydown",c),window.removeEventListener("keyup",f)}}),[e,n,o]),i};
@@ -1,6 +1,6 @@
1
- type handleFn = (e: KeyboardEvent) => void;
2
- /**
3
- * Reack hook
4
- */
5
- export declare const useKeyPress: (targetKey: string, handleKeyDown?: handleFn, handleKeyUp?: handleFn) => boolean;
6
- export {};
1
+ type handleFn = (e: KeyboardEvent) => void;
2
+ /**
3
+ * Reack hook
4
+ */
5
+ export declare const useKeyPress: (targetKey: string, handleKeyDown?: handleFn, handleKeyUp?: handleFn) => boolean;
6
+ export {};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/useKeyPress",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -11,12 +11,12 @@ var SCREEN_BREAKPOINTS = {
11
11
  wide: 1200,
12
12
  huge: 1400
13
13
  };
14
- /**
15
- * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
14
+ /**
15
+ * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
16
16
  */
17
- var useMedia = function (_a) {
18
- var minWidth = _a.minWidth,
19
- maxWidth = _a.maxWidth;
17
+ var useMedia = function useMedia(_ref) {
18
+ var minWidth = _ref.minWidth,
19
+ maxWidth = _ref.maxWidth;
20
20
  return reactResponsive.useMediaQuery({
21
21
  minWidth: minWidth ? SCREEN_BREAKPOINTS[minWidth] : 1,
22
22
  maxWidth: maxWidth ? SCREEN_BREAKPOINTS[maxWidth] - 1 : undefined
@@ -11,12 +11,12 @@ var SCREEN_BREAKPOINTS = {
11
11
  wide: 1200,
12
12
  huge: 1400
13
13
  };
14
- /**
15
- * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
14
+ /**
15
+ * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
16
16
  */
17
- var useMedia = function (_a) {
18
- var minWidth = _a.minWidth,
19
- maxWidth = _a.maxWidth;
17
+ var useMedia = function useMedia(_ref) {
18
+ var minWidth = _ref.minWidth,
19
+ maxWidth = _ref.maxWidth;
20
20
  return reactResponsive.useMediaQuery({
21
21
  minWidth: minWidth ? SCREEN_BREAKPOINTS[minWidth] : 1,
22
22
  maxWidth: maxWidth ? SCREEN_BREAKPOINTS[maxWidth] - 1 : undefined
@@ -1,21 +1,21 @@
1
- export declare const SCREEN_BREAKPOINTS: {
2
- readonly small: 480;
3
- readonly medium: 768;
4
- readonly large: 960;
5
- readonly wide: 1200;
6
- readonly huge: 1400;
7
- };
8
- export type useMedia = (arg: {
9
- /**
10
- * Аналог CSS медиа правила `@media (min-width: ...)`
11
- */
12
- minWidth?: keyof typeof SCREEN_BREAKPOINTS;
13
- /**
14
- * Аналог CSS медиа правила `@media (max-width: ...)`
15
- */
16
- maxWidth?: keyof typeof SCREEN_BREAKPOINTS;
17
- }) => boolean;
18
- /**
19
- * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
20
- */
21
- export declare const useMedia: useMedia;
1
+ export declare const SCREEN_BREAKPOINTS: {
2
+ readonly small: 480;
3
+ readonly medium: 768;
4
+ readonly large: 960;
5
+ readonly wide: 1200;
6
+ readonly huge: 1400;
7
+ };
8
+ export type useMedia = (arg: {
9
+ /**
10
+ * Аналог CSS медиа правила `@media (min-width: ...)`
11
+ */
12
+ minWidth?: keyof typeof SCREEN_BREAKPOINTS;
13
+ /**
14
+ * Аналог CSS медиа правила `@media (max-width: ...)`
15
+ */
16
+ maxWidth?: keyof typeof SCREEN_BREAKPOINTS;
17
+ }) => boolean;
18
+ /**
19
+ * Хук позволяет определять текущее состояние медиа-запроса и обновлять его при изменении размера окна браузера.
20
+ */
21
+ export declare const useMedia: useMedia;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/useMedia",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -8,8 +8,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var useOutsideClickRef__default = /*#__PURE__*/_interopDefaultCompat(useOutsideClickRef);
10
10
 
11
- /**
12
- * Reack hook
11
+ /**
12
+ * Reack hook
13
13
  */
14
14
  var useOutsideClick = useOutsideClickRef__default.default;
15
15
 
@@ -8,8 +8,8 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var useOutsideClickRef__default = /*#__PURE__*/_interopDefaultCompat(useOutsideClickRef);
10
10
 
11
- /**
12
- * Reack hook
11
+ /**
12
+ * Reack hook
13
13
  */
14
14
  var useOutsideClick = useOutsideClickRef__default.default;
15
15
 
@@ -1,5 +1,5 @@
1
- import useOutsideClickRef from '@rooks/use-outside-click-ref';
2
- /**
3
- * Reack hook
4
- */
5
- export declare const useOutsideClick: typeof useOutsideClickRef;
1
+ import useOutsideClickRef from '@rooks/use-outside-click-ref';
2
+ /**
3
+ * Reack hook
4
+ */
5
+ export declare const useOutsideClick: typeof useOutsideClickRef;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/useOutsideClick",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -4,18 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var react = require('react');
6
6
 
7
- /**
8
- * Creates DOM element to be used as React root.
9
- * @returns {HTMLElement}
7
+ /**
8
+ * Creates DOM element to be used as React root.
9
+ * @returns {HTMLElement}
10
10
  */
11
11
  function createRootElement(id) {
12
12
  var rootContainer = document.createElement('div');
13
13
  rootContainer.setAttribute('id', id);
14
14
  return rootContainer;
15
15
  }
16
- /**
17
- * Appends element as last child of body.
18
- * @param {HTMLElement} rootElem
16
+
17
+ /**
18
+ * Appends element as last child of body.
19
+ * @param {HTMLElement} rootElem
19
20
  */
20
21
  function addRootElement(rootElem) {
21
22
  try {
@@ -28,28 +29,31 @@ function addRootElement(rootElem) {
28
29
  console.warn('Failed to add root element');
29
30
  }
30
31
  }
31
- /**
32
- * Hook to create a React Portal.
33
- * Automatically handles creating and tearing-down the root elements (no SRR
34
- * makes this trivial), so there is no need to ensure the parent target already
35
- * exists.
36
- * @example
37
- * const target = usePortal(id, [id]);
38
- * return createPortal(children, target);
39
- * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
40
- * @returns {HTMLElement} The DOM node to use as the Portal target.
32
+
33
+ /**
34
+ * Hook to create a React Portal.
35
+ * Automatically handles creating and tearing-down the root elements (no SRR
36
+ * makes this trivial), so there is no need to ensure the parent target already
37
+ * exists.
38
+ * @example
39
+ * const target = usePortal(id, [id]);
40
+ * return createPortal(children, target);
41
+ * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
42
+ * @returns {HTMLElement} The DOM node to use as the Portal target.
41
43
  */
42
- var usePortal = function (id) {
44
+ var usePortal = function usePortal(id) {
43
45
  var rootElemRef = react.useRef(null);
44
46
  react.useEffect(function () {
45
47
  // Look for existing target dom element to append to
46
48
  var existingParent = document.querySelector("#".concat(id));
47
49
  // Parent is either a new root or the existing dom element
48
50
  var parentElem = existingParent || createRootElement(id);
51
+
49
52
  // If there is no existing DOM element, add a new one.
50
53
  if (!existingParent) {
51
54
  addRootElement(parentElem);
52
55
  }
56
+
53
57
  // Add the detached element to the parent
54
58
  if (rootElemRef.current) {
55
59
  parentElem.appendChild(rootElemRef.current);
@@ -63,17 +67,18 @@ var usePortal = function (id) {
63
67
  }
64
68
  };
65
69
  }, []);
66
- /**
67
- * It's important we evaluate this lazily:
68
- * - We need first render to contain the DOM element, so it shouldn't happen
69
- * in useEffect. We would normally put this in the constructor().
70
- * - We can't do 'const rootElemRef = useRef(document.createElement('div))',
71
- * since this will run every single render (that's a lot).
72
- * - We want the ref to consistently point to the same DOM element and only
73
- * ever run once.
74
- * @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
70
+
71
+ /**
72
+ * It's important we evaluate this lazily:
73
+ * - We need first render to contain the DOM element, so it shouldn't happen
74
+ * in useEffect. We would normally put this in the constructor().
75
+ * - We can't do 'const rootElemRef = useRef(document.createElement('div))',
76
+ * since this will run every single render (that's a lot).
77
+ * - We want the ref to consistently point to the same DOM element and only
78
+ * ever run once.
79
+ * @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
75
80
  */
76
- var getRootElem = function () {
81
+ var getRootElem = function getRootElem() {
77
82
  if (!rootElemRef.current && typeof document !== 'undefined') {
78
83
  rootElemRef.current = document.createElement('div');
79
84
  }
@@ -4,18 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var react = require('react');
6
6
 
7
- /**
8
- * Creates DOM element to be used as React root.
9
- * @returns {HTMLElement}
7
+ /**
8
+ * Creates DOM element to be used as React root.
9
+ * @returns {HTMLElement}
10
10
  */
11
11
  function createRootElement(id) {
12
12
  var rootContainer = document.createElement('div');
13
13
  rootContainer.setAttribute('id', id);
14
14
  return rootContainer;
15
15
  }
16
- /**
17
- * Appends element as last child of body.
18
- * @param {HTMLElement} rootElem
16
+
17
+ /**
18
+ * Appends element as last child of body.
19
+ * @param {HTMLElement} rootElem
19
20
  */
20
21
  function addRootElement(rootElem) {
21
22
  try {
@@ -28,28 +29,31 @@ function addRootElement(rootElem) {
28
29
  console.warn('Failed to add root element');
29
30
  }
30
31
  }
31
- /**
32
- * Hook to create a React Portal.
33
- * Automatically handles creating and tearing-down the root elements (no SRR
34
- * makes this trivial), so there is no need to ensure the parent target already
35
- * exists.
36
- * @example
37
- * const target = usePortal(id, [id]);
38
- * return createPortal(children, target);
39
- * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
40
- * @returns {HTMLElement} The DOM node to use as the Portal target.
32
+
33
+ /**
34
+ * Hook to create a React Portal.
35
+ * Automatically handles creating and tearing-down the root elements (no SRR
36
+ * makes this trivial), so there is no need to ensure the parent target already
37
+ * exists.
38
+ * @example
39
+ * const target = usePortal(id, [id]);
40
+ * return createPortal(children, target);
41
+ * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
42
+ * @returns {HTMLElement} The DOM node to use as the Portal target.
41
43
  */
42
- var usePortal = function (id) {
44
+ var usePortal = function usePortal(id) {
43
45
  var rootElemRef = react.useRef(null);
44
46
  react.useEffect(function () {
45
47
  // Look for existing target dom element to append to
46
48
  var existingParent = document.querySelector("#".concat(id));
47
49
  // Parent is either a new root or the existing dom element
48
50
  var parentElem = existingParent || createRootElement(id);
51
+
49
52
  // If there is no existing DOM element, add a new one.
50
53
  if (!existingParent) {
51
54
  addRootElement(parentElem);
52
55
  }
56
+
53
57
  // Add the detached element to the parent
54
58
  if (rootElemRef.current) {
55
59
  parentElem.appendChild(rootElemRef.current);
@@ -63,17 +67,18 @@ var usePortal = function (id) {
63
67
  }
64
68
  };
65
69
  }, []);
66
- /**
67
- * It's important we evaluate this lazily:
68
- * - We need first render to contain the DOM element, so it shouldn't happen
69
- * in useEffect. We would normally put this in the constructor().
70
- * - We can't do 'const rootElemRef = useRef(document.createElement('div))',
71
- * since this will run every single render (that's a lot).
72
- * - We want the ref to consistently point to the same DOM element and only
73
- * ever run once.
74
- * @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
70
+
71
+ /**
72
+ * It's important we evaluate this lazily:
73
+ * - We need first render to contain the DOM element, so it shouldn't happen
74
+ * in useEffect. We would normally put this in the constructor().
75
+ * - We can't do 'const rootElemRef = useRef(document.createElement('div))',
76
+ * since this will run every single render (that's a lot).
77
+ * - We want the ref to consistently point to the same DOM element and only
78
+ * ever run once.
79
+ * @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
75
80
  */
76
- var getRootElem = function () {
81
+ var getRootElem = function getRootElem() {
77
82
  if (!rootElemRef.current && typeof document !== 'undefined') {
78
83
  rootElemRef.current = document.createElement('div');
79
84
  }
@@ -1,12 +1,12 @@
1
- /**
2
- * Hook to create a React Portal.
3
- * Automatically handles creating and tearing-down the root elements (no SRR
4
- * makes this trivial), so there is no need to ensure the parent target already
5
- * exists.
6
- * @example
7
- * const target = usePortal(id, [id]);
8
- * return createPortal(children, target);
9
- * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
10
- * @returns {HTMLElement} The DOM node to use as the Portal target.
11
- */
12
- export declare const usePortal: (id: string) => HTMLElement | null;
1
+ /**
2
+ * Hook to create a React Portal.
3
+ * Automatically handles creating and tearing-down the root elements (no SRR
4
+ * makes this trivial), so there is no need to ensure the parent target already
5
+ * exists.
6
+ * @example
7
+ * const target = usePortal(id, [id]);
8
+ * return createPortal(children, target);
9
+ * @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
10
+ * @returns {HTMLElement} The DOM node to use as the Portal target.
11
+ */
12
+ export declare const usePortal: (id: string) => HTMLElement | null;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/usePortal",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var useScrollPosition$1 = require('@n8tb1t/use-scroll-position');
6
6
 
7
- /**
8
- * Reack hook
7
+ /**
8
+ * Reack hook
9
9
  */
10
10
  var useScrollPosition = useScrollPosition$1.useScrollPosition;
11
11
 
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var useScrollPosition$1 = require('@n8tb1t/use-scroll-position');
6
6
 
7
- /**
8
- * Reack hook
7
+ /**
8
+ * Reack hook
9
9
  */
10
10
  var useScrollPosition = useScrollPosition$1.useScrollPosition;
11
11
 
@@ -1,5 +1,5 @@
1
- import { useScrollPosition as useScrollPositionPackage } from '@n8tb1t/use-scroll-position';
2
- /**
3
- * Reack hook
4
- */
5
- export declare const useScrollPosition: typeof useScrollPositionPackage;
1
+ import { useScrollPosition as useScrollPositionPackage } from '@n8tb1t/use-scroll-position';
2
+ /**
3
+ * Reack hook
4
+ */
5
+ export declare const useScrollPosition: typeof useScrollPositionPackage;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/useScrollPosition",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [