@koine/react 1.0.9 → 1.0.12

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 (359) hide show
  1. package/Alert/Alert.js +7 -13
  2. package/Animations/Reveal.js +12 -10
  3. package/Animations/Underline.js +3 -13
  4. package/Animations/useReveal.js +18 -17
  5. package/Autocomplete/AutocompleteDownshift.js +1 -1
  6. package/Autocomplete/AutocompleteDownshiftMultiselect.js +1 -1
  7. package/Autocomplete/AutocompleteMui.js +61 -56
  8. package/Autocomplete/AutocompleteReach.js +1 -1
  9. package/Autocomplete/components.js +17 -72
  10. package/Autocomplete/helpers.js +1 -1
  11. package/Bg/BgColor.js +14 -24
  12. package/Bg/BgPhoto.js +11 -54
  13. package/Bg/BgSvg.js +6 -9
  14. package/Breadcrumbs/Breadcrumbs.js +14 -54
  15. package/Buttons/Button.js +8 -73
  16. package/Buttons/ButtonComposite.js +20 -41
  17. package/Buttons/ButtonFab.js +4 -6
  18. package/Buttons/ButtonLink.js +7 -6
  19. package/Buttons/IconButton.js +5 -17
  20. package/Calendar/CalendarDaygridCell.js +20 -14
  21. package/Calendar/CalendarDaygridNav.js +10 -9
  22. package/Calendar/CalendarDaygridTable.js +32 -30
  23. package/Calendar/CalendarLegend.js +7 -2
  24. package/Calendar/calendar-api-google.js +101 -68
  25. package/Calendar/useCalendar.js +114 -113
  26. package/Calendar/utils.js +73 -74
  27. package/Carousel/Carousel.js +1 -1
  28. package/Carousel/CarouselCss.js +14 -27
  29. package/Collapsable/Collapsable.d.ts +1 -1
  30. package/Collapsable/Collapsable.js +1 -1
  31. package/Collapsable/CollapsableReach.d.ts +4 -64
  32. package/Collapsable/CollapsableReach.js +247 -129
  33. package/Collapsable/index.d.ts +1 -1
  34. package/Collapsable/index.js +2 -1
  35. package/Debug/Debug.js +5 -17
  36. package/Details/Details.d.ts +114 -0
  37. package/Details/Details.js +65 -0
  38. package/Details/index.d.ts +1 -0
  39. package/Details/index.js +1 -0
  40. package/{Forms/Form → Details}/package.json +1 -1
  41. package/Dialog/DialogMui.d.ts +1 -1
  42. package/Dialog/DialogMui.js +22 -20
  43. package/Dialog/css/bare.js +17 -15
  44. package/Dialog/m/bare.js +17 -13
  45. package/Dialog/m/basic.js +2 -2
  46. package/Dialog/m/index.js +4 -4
  47. package/Dialog/sc/bare.js +25 -43
  48. package/Dialog/sc/framer.js +6 -6
  49. package/Dialog/sc/framerMaterial.js +6 -6
  50. package/Dialog/sc/material.js +17 -37
  51. package/Dialog/tw/bare.js +25 -19
  52. package/Dialog/tw/elegant.js +17 -15
  53. package/Dialog/tw/framer.js +6 -6
  54. package/Dialog/tw/framerMaterial.js +6 -6
  55. package/Dialog/tw/material.js +17 -15
  56. package/Editor/Editor--tiptap.js +14 -11
  57. package/Editor/components.js +6 -24
  58. package/Favicon/FaviconTags.js +2 -1
  59. package/Form/Form.d.ts +111 -0
  60. package/Form/Form.js +61 -0
  61. package/{Forms/Form → Form}/index.d.ts +0 -0
  62. package/{Forms/Form → Form}/index.js +0 -0
  63. package/Form/package.json +6 -0
  64. package/Form/sc/bare.d.ts +33 -0
  65. package/Form/sc/bare.js +20 -0
  66. package/Forms/Checkbox/Checkbox.js +9 -15
  67. package/Forms/Feedback/Feedback.js +6 -7
  68. package/Forms/Field/Field.js +15 -26
  69. package/Forms/Field/FieldControl.js +19 -15
  70. package/Forms/Field/FieldHint.js +3 -5
  71. package/Forms/Input/Input.js +10 -16
  72. package/Forms/InputGroup/InputGroup.js +9 -36
  73. package/Forms/Label/Label.js +5 -23
  74. package/Forms/Password/Password.js +10 -23
  75. package/Forms/Radio/Radio.js +15 -18
  76. package/Forms/Switch/Switch.js +9 -39
  77. package/Forms/Textarea/Textarea.js +6 -7
  78. package/Forms/Textarea/TextareaRich.js +10 -24
  79. package/Forms/Toggle/Toggle.js +21 -68
  80. package/Forms/Toggle/useToggle.js +29 -29
  81. package/Forms/antispam.js +12 -12
  82. package/Forms/helpers.js +8 -7
  83. package/Forms/index.d.ts +0 -1
  84. package/Forms/index.js +0 -1
  85. package/Forms/styles.js +12 -43
  86. package/Gauge/Gauge.js +1 -1
  87. package/Grid/Grid.js +25 -51
  88. package/Hamburger/Hamburger.js +35 -47
  89. package/Header/useHeader.js +12 -12
  90. package/Hidden/Hidden.js +9 -13
  91. package/Img/sc/bare.js +3 -1
  92. package/Link/Link.js +3 -1
  93. package/Link/LinkBlank.js +8 -17
  94. package/Menu/Menu.js +3 -10
  95. package/MenuItem/MenuItem.js +3 -19
  96. package/Meta/Meta.js +3 -2
  97. package/NoJs/NoJs.js +2 -2
  98. package/Pagination/PaginationNav.js +26 -48
  99. package/Pagination/PaginationResults.js +7 -6
  100. package/Pill/Pill.js +6 -36
  101. package/Progress/ProgressCircular.js +9 -30
  102. package/Progress/ProgressLinear.js +8 -16
  103. package/Progress/ProgressOverlay.js +11 -27
  104. package/Rating/Rating.js +26 -45
  105. package/Rating/index.js +19 -15
  106. package/Select/SelectDownshift.js +1 -1
  107. package/Select/components.js +6 -12
  108. package/Sidebar/Sidebar.js +13 -38
  109. package/Spacing/Spacing.js +12 -12
  110. package/Sticky/Sticky.js +1 -1
  111. package/Sticky/StickyCss.js +4 -2
  112. package/Tabs/TabsMui.d.ts +244 -0
  113. package/Tabs/TabsMui.js +46 -0
  114. package/Tabs/index.d.ts +1 -1
  115. package/Tabs/index.js +1 -1
  116. package/Tabs/sc/bare.d.ts +5 -0
  117. package/Tabs/sc/bare.js +87 -0
  118. package/Tabs/tw/bare.d.ts +248 -0
  119. package/Tabs/tw/bare.js +17 -0
  120. package/Tabs/tw/material.d.ts +472 -0
  121. package/Tabs/tw/material.js +18 -0
  122. package/Tabs/useTabs.d.ts +43 -0
  123. package/Tabs/useTabs.js +44 -0
  124. package/Typography/CopyPasteVisible.js +3 -5
  125. package/Typography/Native.js +12 -45
  126. package/Typography/ReadMore.js +26 -52
  127. package/Typography/TextLoop.js +19 -22
  128. package/Typography/TypeStairs.js +20 -16
  129. package/css/index.js +1 -0
  130. package/helpers/classed.js +22 -18
  131. package/helpers/extend-component.js +6 -6
  132. package/hooks/index.d.ts +8 -0
  133. package/hooks/index.js +8 -0
  134. package/hooks/types.d.ts +8 -0
  135. package/hooks/types.js +1 -0
  136. package/hooks/useAsyncFn.d.ts +26 -0
  137. package/hooks/useAsyncFn.js +36 -0
  138. package/hooks/useDateLocale.js +22 -13
  139. package/hooks/useEffectOnce.d.ts +5 -0
  140. package/hooks/useEffectOnce.js +8 -0
  141. package/hooks/useFirstMountState.d.ts +4 -0
  142. package/hooks/useFirstMountState.js +12 -0
  143. package/hooks/useFocus.js +3 -3
  144. package/hooks/useId.d.ts +4 -0
  145. package/hooks/useId.js +8 -0
  146. package/hooks/useIsomorphicLayoutEffect.d.ts +5 -0
  147. package/hooks/useIsomorphicLayoutEffect.js +8 -0
  148. package/hooks/useMount.d.ts +4 -0
  149. package/hooks/useMount.js +9 -0
  150. package/hooks/useMountedState.d.ts +4 -0
  151. package/hooks/useMountedState.js +15 -0
  152. package/hooks/usePrevious.js +2 -2
  153. package/hooks/useScrollPosition.js +21 -16
  154. package/hooks/useScrollTo.js +7 -5
  155. package/hooks/useTraceUpdate.js +4 -3
  156. package/hooks/useUpdateEffect.d.ts +5 -0
  157. package/hooks/useUpdateEffect.js +14 -0
  158. package/hooks/useWindowSize.js +3 -3
  159. package/m/MotionProvider.js +4 -2
  160. package/node/Alert/Alert.js +9 -16
  161. package/node/Alert/index.js +1 -1
  162. package/node/Animations/Reveal.js +15 -13
  163. package/node/Animations/Underline.js +5 -16
  164. package/node/Animations/index.js +1 -1
  165. package/node/Animations/useReveal.js +19 -18
  166. package/node/Autocomplete/AutocompleteMui.js +69 -64
  167. package/node/Autocomplete/components.js +26 -82
  168. package/node/Autocomplete/helpers.js +2 -2
  169. package/node/Bg/BgColor.js +18 -29
  170. package/node/Bg/BgPhoto.js +15 -59
  171. package/node/Bg/BgSvg.js +8 -12
  172. package/node/Bg/index.js +1 -1
  173. package/node/Breadcrumbs/Breadcrumbs.js +20 -61
  174. package/node/Breadcrumbs/index.js +1 -1
  175. package/node/Buttons/Button.js +10 -76
  176. package/node/Buttons/ButtonComposite.js +23 -45
  177. package/node/Buttons/ButtonFab.js +6 -9
  178. package/node/Buttons/ButtonLink.js +10 -10
  179. package/node/Buttons/IconButton.js +7 -20
  180. package/node/Buttons/index.js +1 -1
  181. package/node/Calendar/CalendarDaygridCell.js +24 -18
  182. package/node/Calendar/CalendarDaygridNav.js +14 -13
  183. package/node/Calendar/CalendarDaygridTable.js +39 -38
  184. package/node/Calendar/CalendarLegend.js +8 -3
  185. package/node/Calendar/calendar-api-google.js +105 -73
  186. package/node/Calendar/index.js +1 -1
  187. package/node/Calendar/useCalendar.js +117 -116
  188. package/node/Calendar/utils.js +82 -84
  189. package/node/Carousel/CarouselCss.js +17 -31
  190. package/node/Carousel/index.js +1 -1
  191. package/node/Collapsable/Collapsable.js +2 -2
  192. package/node/Collapsable/CollapsableReach.js +246 -134
  193. package/node/Collapsable/index.js +3 -2
  194. package/node/Debug/Debug.js +7 -20
  195. package/node/Debug/index.js +1 -1
  196. package/node/Details/Details.js +67 -0
  197. package/node/Details/index.js +4 -0
  198. package/node/Dialog/DialogMui.js +12 -11
  199. package/node/Dialog/css/bare.js +11 -10
  200. package/node/Dialog/m/bare.js +18 -14
  201. package/node/Dialog/m/basic.js +1 -1
  202. package/node/Dialog/m/index.js +4 -4
  203. package/node/Dialog/sc/bare.js +22 -41
  204. package/node/Dialog/sc/framer.js +5 -5
  205. package/node/Dialog/sc/framerMaterial.js +5 -5
  206. package/node/Dialog/sc/material.js +12 -33
  207. package/node/Dialog/tw/bare.js +19 -14
  208. package/node/Dialog/tw/elegant.js +11 -9
  209. package/node/Dialog/tw/framer.js +5 -5
  210. package/node/Dialog/tw/framerMaterial.js +5 -5
  211. package/node/Dialog/tw/material.js +11 -9
  212. package/node/Editor/Editor--tiptap.js +19 -17
  213. package/node/Editor/components.js +9 -28
  214. package/node/Editor/index.js +1 -1
  215. package/node/Favicon/FaviconTags.js +3 -2
  216. package/node/Favicon/index.js +1 -1
  217. package/node/Form/Form.js +65 -0
  218. package/node/{Forms/Form → Form}/index.js +1 -1
  219. package/node/Form/sc/bare.js +23 -0
  220. package/node/Forms/Checkbox/Checkbox.js +13 -20
  221. package/node/Forms/Checkbox/index.js +1 -1
  222. package/node/Forms/Feedback/Feedback.js +8 -10
  223. package/node/Forms/Feedback/index.js +1 -1
  224. package/node/Forms/Field/Field.js +18 -30
  225. package/node/Forms/Field/FieldControl.js +26 -22
  226. package/node/Forms/Field/FieldHint.js +4 -7
  227. package/node/Forms/Field/index.js +1 -1
  228. package/node/Forms/Input/Input.js +15 -22
  229. package/node/Forms/Input/index.js +1 -1
  230. package/node/Forms/InputGroup/InputGroup.js +14 -42
  231. package/node/Forms/InputGroup/index.js +1 -1
  232. package/node/Forms/Label/Label.js +6 -25
  233. package/node/Forms/Label/index.js +1 -1
  234. package/node/Forms/Password/Password.js +16 -30
  235. package/node/Forms/Password/index.js +1 -1
  236. package/node/Forms/Radio/Radio.js +21 -25
  237. package/node/Forms/Radio/index.js +1 -1
  238. package/node/Forms/Switch/Switch.js +15 -46
  239. package/node/Forms/Switch/index.js +1 -1
  240. package/node/Forms/Textarea/Textarea.js +11 -13
  241. package/node/Forms/Textarea/TextareaRich.js +16 -31
  242. package/node/Forms/Textarea/index.js +1 -1
  243. package/node/Forms/Toggle/Toggle.js +24 -72
  244. package/node/Forms/Toggle/index.js +1 -1
  245. package/node/Forms/Toggle/useToggle.js +33 -33
  246. package/node/Forms/antispam.js +14 -14
  247. package/node/Forms/helpers.js +9 -8
  248. package/node/Forms/index.js +1 -2
  249. package/node/Forms/styles.js +16 -48
  250. package/node/Gauge/Gauge.js +1 -1
  251. package/node/Grid/Grid.js +24 -51
  252. package/node/Grid/index.js +1 -1
  253. package/node/Hamburger/Hamburger.js +37 -50
  254. package/node/Hamburger/index.js +1 -1
  255. package/node/Header/index.js +1 -1
  256. package/node/Header/useHeader.js +16 -16
  257. package/node/Hidden/Hidden.js +10 -15
  258. package/node/Hidden/index.js +1 -1
  259. package/node/Img/index.js +1 -1
  260. package/node/Img/sc/bare.js +4 -3
  261. package/node/Link/Link.js +4 -3
  262. package/node/Link/LinkBlank.js +11 -21
  263. package/node/Link/index.js +1 -1
  264. package/node/Menu/Menu.js +4 -12
  265. package/node/Menu/index.js +1 -1
  266. package/node/MenuItem/MenuItem.js +4 -21
  267. package/node/MenuItem/index.js +1 -1
  268. package/node/Meta/Meta.js +4 -3
  269. package/node/Meta/index.js +1 -1
  270. package/node/NoJs/NoJs.js +3 -3
  271. package/node/NoJs/index.js +1 -1
  272. package/node/Pagination/PaginationNav.js +30 -53
  273. package/node/Pagination/PaginationResults.js +10 -10
  274. package/node/Pagination/index.js +1 -1
  275. package/node/Pill/Pill.js +7 -38
  276. package/node/Pill/index.js +1 -1
  277. package/node/Progress/ProgressCircular.js +11 -33
  278. package/node/Progress/ProgressLinear.js +11 -20
  279. package/node/Progress/ProgressOverlay.js +18 -35
  280. package/node/Progress/index.js +1 -1
  281. package/node/Rating/Rating.js +28 -48
  282. package/node/Rating/index.js +20 -16
  283. package/node/Select/components.js +11 -18
  284. package/node/Sidebar/Sidebar.js +21 -47
  285. package/node/Sidebar/index.js +1 -1
  286. package/node/Spacing/Spacing.js +16 -17
  287. package/node/Spacing/index.js +1 -1
  288. package/node/Sticky/StickyCss.js +5 -3
  289. package/node/Sticky/index.js +1 -1
  290. package/node/Tabs/TabsMui.js +49 -0
  291. package/node/Tabs/index.js +2 -2
  292. package/node/Tabs/sc/bare.js +87 -0
  293. package/node/Tabs/tw/bare.js +20 -0
  294. package/node/Tabs/tw/material.js +21 -0
  295. package/node/Tabs/useTabs.js +48 -0
  296. package/node/Typography/CopyPasteVisible.js +4 -7
  297. package/node/Typography/Native.js +14 -48
  298. package/node/Typography/ReadMore.js +30 -57
  299. package/node/Typography/TextLoop.js +22 -25
  300. package/node/Typography/TypeStairs.js +22 -18
  301. package/node/Typography/index.js +1 -1
  302. package/node/css/index.js +2 -1
  303. package/node/helpers/classed.js +23 -19
  304. package/node/helpers/extend-component.js +7 -7
  305. package/node/helpers/index.js +1 -1
  306. package/node/hooks/index.js +9 -1
  307. package/node/hooks/types.js +2 -0
  308. package/node/hooks/useAsyncFn.js +40 -0
  309. package/node/hooks/useDateLocale.js +23 -37
  310. package/node/hooks/useEffectOnce.js +12 -0
  311. package/node/hooks/useFirstMountState.js +16 -0
  312. package/node/hooks/useFocus.js +4 -4
  313. package/node/hooks/useId.js +12 -0
  314. package/node/hooks/useIsomorphicLayoutEffect.js +11 -0
  315. package/node/hooks/useMount.js +13 -0
  316. package/node/hooks/useMountedState.js +19 -0
  317. package/node/hooks/usePrevious.js +3 -3
  318. package/node/hooks/useScrollPosition.js +23 -19
  319. package/node/hooks/useScrollTo.js +9 -7
  320. package/node/hooks/useTraceUpdate.js +5 -4
  321. package/node/hooks/useUpdateEffect.js +18 -0
  322. package/node/hooks/useWindowSize.js +4 -4
  323. package/node/index.js +1 -1
  324. package/node/m/MotionProvider.js +6 -4
  325. package/node/m/index.js +1 -1
  326. package/node/m/lite.js +1 -1
  327. package/node/m/max.js +1 -1
  328. package/node/sc/index.js +4 -2
  329. package/node/scm/index.js +2 -1
  330. package/node/shared/index.js +1 -1
  331. package/node/styles/Body.js +5 -10
  332. package/node/styles/Global.js +5 -37
  333. package/node/styles/index.js +1 -1
  334. package/node/styles/media.js +42 -38
  335. package/node/styles/spacing.js +15 -16
  336. package/node/styles/styled.js +7 -21
  337. package/node/styles/theme--vanilla.js +21 -19
  338. package/node/styles/theme.js +9 -9
  339. package/node/tw/index.js +2 -1
  340. package/node/twm/index.js +2 -1
  341. package/package.json +20 -9
  342. package/sc/index.d.ts +1 -0
  343. package/sc/index.js +1 -0
  344. package/scm/index.js +1 -0
  345. package/styles/Body.js +4 -8
  346. package/styles/Global.js +4 -36
  347. package/styles/media.js +41 -36
  348. package/styles/spacing.js +15 -16
  349. package/styles/styled.js +7 -21
  350. package/styles/theme--vanilla.js +21 -19
  351. package/styles/theme.js +11 -11
  352. package/tw/index.js +1 -0
  353. package/twm/index.js +1 -0
  354. package/Forms/Form/Form.d.ts +0 -31
  355. package/Forms/Form/Form.js +0 -62
  356. package/Tabs/Tabs.d.ts +0 -27
  357. package/Tabs/Tabs.js +0 -62
  358. package/node/Forms/Form/Form.js +0 -67
  359. package/node/Tabs/Tabs.js +0 -67
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TextLoop = exports.TextLoopPiece = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const framer_motion_1 = require("framer-motion");
7
- const TextLoopPiece = ({ text = "", style = {}, className = "", direction = "up", inline = true, noOverflow = true, delay = 400, }) => {
8
- const placeholderRef = (0, react_1.useRef)(null);
9
- const [content, setContent] = (0, react_1.useState)({ data: "", key: "" });
10
- const [width, setWidth] = (0, react_1.useState)(inline ? 0 : "auto");
11
- (0, react_1.useEffect)(() => {
12
- const timeoutId = setTimeout(() => {
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var react_1 = require("react");
7
+ var framer_motion_1 = require("framer-motion");
8
+ var TextLoopPiece = function (_a) {
9
+ var _b = _a.text, text = _b === void 0 ? "" : _b, _c = _a.style, style = _c === void 0 ? {} : _c, _d = _a.className, className = _d === void 0 ? "" : _d, _e = _a.direction, direction = _e === void 0 ? "up" : _e, _f = _a.inline, inline = _f === void 0 ? true : _f, _g = _a.noOverflow, noOverflow = _g === void 0 ? true : _g, _h = _a.delay, delay = _h === void 0 ? 400 : _h;
10
+ var placeholderRef = (0, react_1.useRef)(null);
11
+ var _j = (0, react_1.useState)({ data: "", key: "" }), content = _j[0], setContent = _j[1];
12
+ var _k = (0, react_1.useState)(inline ? 0 : "auto"), width = _k[0], setWidth = _k[1];
13
+ (0, react_1.useEffect)(function () {
14
+ var timeoutId = setTimeout(function () {
13
15
  if (!placeholderRef.current)
14
16
  return;
15
17
  placeholderRef.current.innerHTML = text + "";
@@ -17,15 +19,9 @@ const TextLoopPiece = ({ text = "", style = {}, className = "", direction = "up"
17
19
  setWidth(placeholderRef.current.offsetWidth);
18
20
  setContent({ data: text + "", key: new Date() + "" });
19
21
  }, delay);
20
- return () => clearTimeout(timeoutId);
22
+ return function () { return clearTimeout(timeoutId); };
21
23
  }, [text, delay, inline]);
22
- return ((0, jsx_runtime_1.jsxs)("div", { className: className, style: {
23
- ...style,
24
- position: "relative",
25
- display: inline ? "inline-block" : "block",
26
- width,
27
- whiteSpace: inline ? "nowrap" : "normal",
28
- }, children: [(0, jsx_runtime_1.jsx)("span", { ref: placeholderRef, style: { visibility: "hidden" } }), (0, jsx_runtime_1.jsx)("div", { style: {
24
+ return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: className, style: tslib_1.__assign(tslib_1.__assign({}, style), { position: "relative", display: inline ? "inline-block" : "block", width: width, whiteSpace: inline ? "nowrap" : "normal" }) }, { children: [(0, jsx_runtime_1.jsx)("span", { ref: placeholderRef, style: { visibility: "hidden" } }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
29
25
  overflow: noOverflow ? "hidden" : "visible",
30
26
  display: "block",
31
27
  position: "absolute",
@@ -33,22 +29,23 @@ const TextLoopPiece = ({ text = "", style = {}, className = "", direction = "up"
33
29
  left: 0,
34
30
  height: "100%",
35
31
  width: "100%",
36
- }, children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, { style: { position: "absolute" }, initial: {
32
+ } }, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, tslib_1.__assign({ style: { position: "absolute" }, initial: {
37
33
  opacity: 0,
38
34
  y: direction === "down" ? "-100%" : "100%",
39
35
  }, animate: { opacity: 1, y: 0 }, exit: {
40
36
  opacity: 0,
41
37
  y: direction === "down" ? "100%" : "-100%",
42
- }, children: content.data }, content.key) }) })] }));
38
+ } }, { children: content.data }), content.key) }) }))] })));
43
39
  };
44
40
  exports.TextLoopPiece = TextLoopPiece;
45
- const TextLoop = ({ texts, interval = 3000, ...props }) => {
46
- const [index, setIndex] = (0, react_1.useState)(0);
47
- (0, react_1.useEffect)(() => {
48
- const intervalId = setInterval(() => setIndex((index) => index + 1), interval // every 3 seconds
41
+ var TextLoop = function (_a) {
42
+ var texts = _a.texts, _b = _a.interval, interval = _b === void 0 ? 3000 : _b, props = tslib_1.__rest(_a, ["texts", "interval"]);
43
+ var _c = (0, react_1.useState)(0), index = _c[0], setIndex = _c[1];
44
+ (0, react_1.useEffect)(function () {
45
+ var intervalId = setInterval(function () { return setIndex(function (index) { return index + 1; }); }, interval // every 3 seconds
49
46
  );
50
- return () => clearTimeout(intervalId);
47
+ return function () { return clearTimeout(intervalId); };
51
48
  }, [interval]);
52
- return (0, jsx_runtime_1.jsx)(exports.TextLoopPiece, { ...props, text: texts[index % texts.length] });
49
+ return (0, jsx_runtime_1.jsx)(exports.TextLoopPiece, tslib_1.__assign({}, props, { text: texts[index % texts.length] }));
53
50
  };
54
51
  exports.TextLoop = TextLoop;
@@ -1,26 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypeStairs = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- exports.TypeStairs = (0, react_1.forwardRef)(({ children, limit }, ref) => {
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var react_1 = require("react");
7
+ exports.TypeStairs = (0, react_1.forwardRef)(function (_a, ref) {
8
+ var children = _a.children, limit = _a.limit;
7
9
  // split in rows or just use one row if there is no limit
8
- const rows = limit ? splitTextIntoRows(children, limit) : [children];
9
- return rows.length > 1 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: rows.map((row, rowIndex) => {
10
- return ((0, jsx_runtime_1.jsxs)("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, `row-${rowIndex}`));
10
+ var rows = limit ? splitTextIntoRows(children, limit) : [children];
11
+ return rows.length > 1 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: rows.map(function (row, rowIndex) {
12
+ return ((0, jsx_runtime_1.jsxs)("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, "row-".concat(rowIndex)));
11
13
  }) })) : (renderRow(rows[0], 0, ref));
12
14
  });
13
15
  /**
14
16
  * every number chars find a space and break, then restart the gradient weight
15
17
  * @see https://stackoverflow.com/a/25770787
16
18
  */
17
- function splitTextIntoRows(input = "", limit = 18) {
18
- const rows = [];
19
- const arr = input.split(" ");
20
- let currow = arr[0];
21
- let rowlen = currow.length;
22
- for (let i = 1; i < arr.length; i++) {
23
- const word = arr[i];
19
+ function splitTextIntoRows(input, limit) {
20
+ if (input === void 0) { input = ""; }
21
+ if (limit === void 0) { limit = 18; }
22
+ var rows = [];
23
+ var arr = input.split(" ");
24
+ var currow = arr[0];
25
+ var rowlen = currow.length;
26
+ for (var i = 1; i < arr.length; i++) {
27
+ var word = arr[i];
24
28
  rowlen += word.length + 1;
25
29
  if (rowlen <= limit) {
26
30
  currow += " " + word;
@@ -35,15 +39,15 @@ function splitTextIntoRows(input = "", limit = 18) {
35
39
  return rows;
36
40
  }
37
41
  function renderRow(row, rowIndex, ref) {
38
- const letters = row.split("");
39
- let fontWeightIdx = 1;
42
+ var letters = row.split("");
43
+ var fontWeightIdx = 1;
40
44
  // const fontWeight = Math.min(fontWeightIdx * 100, 800);
41
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: letters.map((letter, letterIndex) => {
42
- const fontWeight = Math.min(fontWeightIdx * 100, 800);
45
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: letters.map(function (letter, letterIndex) {
46
+ var fontWeight = Math.min(fontWeightIdx * 100, 800);
43
47
  // don't waste a fontWeight for a white space
44
48
  if (letter !== " ") {
45
49
  fontWeightIdx++;
46
50
  }
47
- return ((0, jsx_runtime_1.jsx)("span", { style: { fontWeight }, ref: ref, children: letter }, `letter-${rowIndex}-${letterIndex}`));
51
+ return ((0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ style: { fontWeight: fontWeight }, ref: ref }, { children: letter }), "letter-".concat(rowIndex, "-").concat(letterIndex)));
48
52
  }) }));
49
53
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
3
+ var tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./CopyPasteVisible"), exports);
5
5
  tslib_1.__exportStar(require("./Native"), exports);
6
6
  tslib_1.__exportStar(require("./ReadMore"), exports);
package/node/css/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KoineDialog = void 0;
4
- const tslib_1 = require("tslib");
4
+ var tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("../shared"), exports);
6
6
  // export * from "../Alert";
7
7
  // export * from "../Animations";
@@ -14,6 +14,7 @@ tslib_1.__exportStar(require("../shared"), exports);
14
14
  // export * from "../Debug";
15
15
  var bare_1 = require("../Dialog/css/bare");
16
16
  Object.defineProperty(exports, "KoineDialog", { enumerable: true, get: function () { return bare_1.KoineDialog; } });
17
+ // export * from "../Form";
17
18
  // export * from "../Forms";
18
19
  // export * from "../Grid";
19
20
  // export * from "../Hamburger";
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.classed = void 0;
4
- const react_1 = require("react");
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
5
6
  /**
6
7
  * This utility allows to extend a component a là `styled-components` but for
7
8
  * a className based styling solution like Tailwind,
@@ -18,12 +19,17 @@ const react_1 = require("react");
18
19
  */
19
20
  function classed(component) {
20
21
  // @ts-expect-error nevermind for now...
21
- const type = component.type || component;
22
- return function (strings, ...args) {
23
- const WrappedComponent = (0, react_1.forwardRef)(function (props, ref) {
24
- const argResolved = args
25
- .map((arg, index) => {
26
- let result = "";
22
+ var type = component.type || component;
23
+ return function (strings) {
24
+ var args = [];
25
+ for (var _i = 1; _i < arguments.length; _i++) {
26
+ args[_i - 1] = arguments[_i];
27
+ }
28
+ var WrappedComponent = (0, react_1.forwardRef)(function (props, ref) {
29
+ var _a;
30
+ var argResolved = args
31
+ .map(function (arg, index) {
32
+ var result = "";
27
33
  if (typeof arg === "function") {
28
34
  result = arg(props);
29
35
  }
@@ -33,32 +39,30 @@ function classed(component) {
33
39
  return strings[index] + result;
34
40
  })
35
41
  .join("");
36
- const isNativeHtmlElement = typeof type === "string";
37
- const propsToForward = isNativeHtmlElement
42
+ var isNativeHtmlElement = typeof type === "string";
43
+ var propsToForward = isNativeHtmlElement
38
44
  ? {}
39
45
  : props;
40
46
  if (isNativeHtmlElement) {
41
- for (const key in props) {
47
+ for (var key in props) {
42
48
  // like styled-components `transient` props
43
49
  if (!key.startsWith("$")) {
50
+ // FIXME: for react 18 we need: @ts-expect-error
44
51
  propsToForward[key] = props[key];
45
52
  }
46
53
  }
47
54
  }
48
55
  // get the tagged function string outcome
49
- let className = argResolved || strings[0];
56
+ var className = argResolved || strings[0];
50
57
  // check if we need to clean it or not from the optional structure `< class="..."`
51
- className = className.match(/class="([^"]*)/)?.[1] || className;
58
+ className = ((_a = className.match(/class="([^"]*)/)) === null || _a === void 0 ? void 0 : _a[1]) || className;
52
59
  // add the custom classes from props
53
- className += props?.className ? " " + props?.className : "";
54
- return (0, react_1.createElement)(type, {
55
- // ...props,
56
- ...propsToForward,
60
+ className += (props === null || props === void 0 ? void 0 : props.className) ? " " + (props === null || props === void 0 ? void 0 : props.className) : "";
61
+ return (0, react_1.createElement)(type, tslib_1.__assign(tslib_1.__assign({}, propsToForward), {
57
62
  // only add ot props if it is not an empty string
58
- className: className || undefined,
63
+ className: className || undefined,
59
64
  // add ref to props
60
- ref,
61
- });
65
+ ref: ref }));
62
66
  });
63
67
  // FIXME: not sure if this is needed
64
68
  // WrappedComponent.displayName = type.toString();
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extendComponent = void 0;
4
- const react_1 = require("react");
5
- const extendComponent = (component, defaultProps) => {
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var extendComponent = function (component, defaultProps) {
6
7
  // FIXME: check if we need to forwardRef or not
7
- const NewComponent = (props) => (0, react_1.createElement)(component, props);
8
+ var NewComponent = function (props) {
9
+ return (0, react_1.createElement)(component, props);
10
+ };
8
11
  // const NewComponent = forwardRef<React.ComponentProps<Component>, Component>(
9
12
  // (props, ref) => createElement(component, { ...props, ref })
10
13
  // );
11
- return Object.assign(NewComponent, {
12
- ...defaultProps,
13
- defaultProps,
14
- });
14
+ return Object.assign(NewComponent, tslib_1.__assign(tslib_1.__assign({}, defaultProps), { defaultProps: defaultProps }));
15
15
  };
16
16
  exports.extendComponent = extendComponent;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
3
+ var tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./classed"), exports);
5
5
  tslib_1.__exportStar(require("./extend-component"), exports);
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./useAsyncFn"), exports);
4
5
  tslib_1.__exportStar(require("./useDateLocale"), exports);
6
+ tslib_1.__exportStar(require("./useEffectOnce"), exports);
7
+ tslib_1.__exportStar(require("./useFirstMountState"), exports);
5
8
  tslib_1.__exportStar(require("./useFocus"), exports);
9
+ tslib_1.__exportStar(require("./useId"), exports);
10
+ tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
11
+ tslib_1.__exportStar(require("./useMount"), exports);
12
+ tslib_1.__exportStar(require("./useMountedState"), exports);
6
13
  tslib_1.__exportStar(require("./usePrevious"), exports);
7
14
  tslib_1.__exportStar(require("./useScrollPosition"), exports);
8
15
  // export * from "./useScrollTo";
9
16
  tslib_1.__exportStar(require("./useTraceUpdate"), exports);
17
+ tslib_1.__exportStar(require("./useUpdateEffect"), exports);
10
18
  tslib_1.__exportStar(require("./useWindowSize"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAsyncFn = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var useMountedState_1 = require("./useMountedState");
7
+ /**
8
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
9
+ */
10
+ function useAsyncFn(fn, deps, initialState) {
11
+ if (deps === void 0) { deps = []; }
12
+ if (initialState === void 0) { initialState = { loading: false }; }
13
+ var lastCallId = (0, react_1.useRef)(0);
14
+ var isMounted = (0, useMountedState_1.useMountedState)();
15
+ var _a = (0, react_1.useState)(initialState), state = _a[0], set = _a[1];
16
+ var callback = (0, react_1.useCallback)(function () {
17
+ var args = [];
18
+ for (var _i = 0; _i < arguments.length; _i++) {
19
+ args[_i] = arguments[_i];
20
+ }
21
+ var callId = ++lastCallId.current;
22
+ if (!state.loading) {
23
+ set(function (prevState) { return (tslib_1.__assign(tslib_1.__assign({}, prevState), { loading: true })); });
24
+ }
25
+ return fn.apply(void 0, args).then(function (value) {
26
+ isMounted() &&
27
+ callId === lastCallId.current &&
28
+ set({ value: value, loading: false });
29
+ return value;
30
+ }, function (error) {
31
+ isMounted() &&
32
+ callId === lastCallId.current &&
33
+ set({ error: error, loading: false });
34
+ return error;
35
+ });
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, deps);
38
+ return [state, callback];
39
+ }
40
+ exports.useAsyncFn = useAsyncFn;
@@ -1,51 +1,37 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.useDateLocale = void 0;
27
- const react_1 = require("react");
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
28
6
  /**
29
7
  * Dynamically import the date-fns correct locale
30
8
  *
31
9
  * Inspired by:
32
10
  * @see https://robertmarshall.dev/blog/dynamically-import-datefns-locale-mui-datepicker-localization/
33
11
  */
34
- function useDateLocale(locale, defaultLocale = "en") {
35
- const [data, setData] = (0, react_1.useState)();
36
- const [current, setCurrent] = (0, react_1.useState)(defaultLocale);
12
+ function useDateLocale(locale, defaultLocale) {
13
+ var _this = this;
14
+ if (defaultLocale === void 0) { defaultLocale = "en"; }
15
+ var _a = (0, react_1.useState)(), data = _a[0], setData = _a[1];
16
+ var _b = (0, react_1.useState)(defaultLocale), current = _b[0], setCurrent = _b[1];
37
17
  // const [ready, setReady] = useState(false);
38
18
  // If the user changes the locale listen to the change and import the locale that is now required.
39
- (0, react_1.useEffect)(() => {
40
- const importLocaleFile = async () => {
41
- // This webpack option stops all of the date-fns files being imported and chunked.
42
- const localeToSet = await Promise.resolve().then(() => __importStar(require(
43
- /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
44
- `date-fns/locale/${locale}/index.js`)));
45
- setCurrent(locale || current);
46
- setData(localeToSet.default);
47
- // setReady(true);
48
- };
19
+ (0, react_1.useEffect)(function () {
20
+ var importLocaleFile = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
21
+ var localeToSet;
22
+ return tslib_1.__generator(this, function (_a) {
23
+ switch (_a.label) {
24
+ case 0: return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require(
25
+ /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
26
+ "date-fns/locale/".concat(locale, "/index.js"))); })];
27
+ case 1:
28
+ localeToSet = _a.sent();
29
+ setCurrent(locale || current);
30
+ setData(localeToSet.default);
31
+ return [2 /*return*/];
32
+ }
33
+ });
34
+ }); };
49
35
  // If the locale has not yet been loaded.
50
36
  if (locale !== current) {
51
37
  importLocaleFile();
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEffectOnce = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts)
7
+ */
8
+ var useEffectOnce = function (effect) {
9
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10
+ (0, react_1.useEffect)(effect, []);
11
+ };
12
+ exports.useEffectOnce = useEffectOnce;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFirstMountState = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
7
+ */
8
+ function useFirstMountState() {
9
+ var isFirst = (0, react_1.useRef)(true);
10
+ if (isFirst.current) {
11
+ isFirst.current = false;
12
+ return true;
13
+ }
14
+ return isFirst.current;
15
+ }
16
+ exports.useFirstMountState = useFirstMountState;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFocus = void 0;
4
- const react_1 = require("react");
4
+ var react_1 = require("react");
5
5
  /**
6
6
  * @see https://stackoverflow.com/a/54159564/1938970
7
7
  */
8
- const useFocus = () => {
9
- const element = (0, react_1.useRef)(null);
10
- const setFocus = () => {
8
+ var useFocus = function () {
9
+ var element = (0, react_1.useRef)(null);
10
+ var setFocus = function () {
11
11
  element.current && element.current.focus();
12
12
  };
13
13
  return [element, setFocus];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useId = void 0;
4
+ var utils_1 = require("@koine/utils");
5
+ /**
6
+ * FIXME: once we can move to react 18 just replace this import with `{ useId } from "react";`
7
+ */
8
+ function useId(prefix) {
9
+ if (prefix === void 0) { prefix = "uid"; }
10
+ return "".concat(prefix, "-").concat((0, utils_1.uid)());
11
+ }
12
+ exports.useId = useId;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsomorphicLayoutEffect = void 0;
4
+ var react_1 = require("react");
5
+ var utils_1 = require("@koine/utils");
6
+ /**
7
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
8
+ */
9
+ exports.useIsomorphicLayoutEffect = utils_1.isBrowser
10
+ ? react_1.useLayoutEffect
11
+ : react_1.useEffect;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMount = void 0;
4
+ var useEffectOnce_1 = require("./useEffectOnce");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMount.ts)
7
+ */
8
+ var useMount = function (fn) {
9
+ (0, useEffectOnce_1.useEffectOnce)(function () {
10
+ fn();
11
+ });
12
+ };
13
+ exports.useMount = useMount;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMountedState = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts)
7
+ */
8
+ function useMountedState() {
9
+ var mountedRef = (0, react_1.useRef)(false);
10
+ var get = (0, react_1.useCallback)(function () { return mountedRef.current; }, []);
11
+ (0, react_1.useEffect)(function () {
12
+ mountedRef.current = true;
13
+ return function () {
14
+ mountedRef.current = false;
15
+ };
16
+ }, []);
17
+ return get;
18
+ }
19
+ exports.useMountedState = useMountedState;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePrevious = void 0;
4
- const react_1 = require("react");
4
+ var react_1 = require("react");
5
5
  function usePrevious(value) {
6
- const ref = (0, react_1.useRef)();
7
- (0, react_1.useEffect)(() => {
6
+ var ref = (0, react_1.useRef)();
7
+ (0, react_1.useEffect)(function () {
8
8
  ref.current = value;
9
9
  });
10
10
  return ref.current;
@@ -1,21 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useScrollPosition = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = require("react");
6
- const useIsomorphicLayoutEffect_1 = tslib_1.__importDefault(require("react-use/esm/useIsomorphicLayoutEffect"));
7
- const utils_1 = require("@koine/utils");
8
- const zeroPosition = { x: 0, y: 0 };
9
- const getClientRect = (element) => element?.getBoundingClientRect();
10
- const getScrollPosition = (element, useWindow, boundingElement) => {
4
+ var react_1 = require("react");
5
+ var utils_1 = require("@koine/utils");
6
+ var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
7
+ var zeroPosition = { x: 0, y: 0 };
8
+ var getClientRect = function (element) {
9
+ return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
10
+ };
11
+ var getScrollPosition = function (element, useWindow, boundingElement) {
11
12
  if (!utils_1.isBrowser) {
12
13
  return zeroPosition;
13
14
  }
14
15
  if (useWindow) {
15
16
  return { x: window.scrollX, y: window.scrollY };
16
17
  }
17
- const targetPosition = getClientRect(element?.current || document.body);
18
- const containerPosition = getClientRect(boundingElement?.current);
18
+ var targetPosition = getClientRect((element === null || element === void 0 ? void 0 : element.current) || document.body);
19
+ var containerPosition = getClientRect(boundingElement === null || boundingElement === void 0 ? void 0 : boundingElement.current);
19
20
  if (!targetPosition) {
20
21
  return zeroPosition;
21
22
  }
@@ -33,20 +34,22 @@ const getScrollPosition = (element, useWindow, boundingElement) => {
33
34
  * - reused internal helper functions
34
35
  * - compacted object arguments in functions as plain argument list to improve compression
35
36
  */
36
- const useScrollPosition = (effect, deps = [], element, useWindow, wait, boundingElement) => {
37
- const position = (0, react_1.useRef)(getScrollPosition(null, useWindow, boundingElement));
38
- let throttleTimeout = null;
39
- const callBack = () => {
40
- const current = getScrollPosition(element, useWindow, boundingElement);
37
+ var useScrollPosition = function (effect, deps, element, useWindow, wait, boundingElement) {
38
+ if (deps === void 0) { deps = []; }
39
+ var position = (0, react_1.useRef)(getScrollPosition(null, useWindow, boundingElement));
40
+ var throttleTimeout = null;
41
+ var callBack = function () {
42
+ var current = getScrollPosition(element, useWindow, boundingElement);
41
43
  effect(current, position.current);
42
44
  position.current = current;
43
45
  throttleTimeout = null;
44
46
  };
45
- (0, useIsomorphicLayoutEffect_1.default)(() => {
47
+ (0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
48
+ var _a;
46
49
  if (!utils_1.isBrowser) {
47
50
  return undefined;
48
51
  }
49
- const handleScroll = () => {
52
+ var handleScroll = function () {
50
53
  if (wait) {
51
54
  if (throttleTimeout === null) {
52
55
  throttleTimeout = window.setTimeout(callBack, wait);
@@ -57,16 +60,17 @@ const useScrollPosition = (effect, deps = [], element, useWindow, wait, bounding
57
60
  }
58
61
  };
59
62
  if (boundingElement) {
60
- boundingElement.current?.addEventListener("scroll", handleScroll, {
63
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", handleScroll, {
61
64
  passive: true,
62
65
  });
63
66
  }
64
67
  else {
65
68
  window.addEventListener("scroll", handleScroll, { passive: true });
66
69
  }
67
- return () => {
70
+ return function () {
71
+ var _a;
68
72
  if (boundingElement) {
69
- boundingElement.current?.removeEventListener("scroll", handleScroll);
73
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", handleScroll);
70
74
  }
71
75
  else {
72
76
  window.removeEventListener("scroll", handleScroll);