@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,3 +1,4 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { useEffect, useState } from "react";
2
3
  /**
3
4
  * Dynamically import the date-fns correct locale
@@ -5,21 +6,29 @@ import { useEffect, useState } from "react";
5
6
  * Inspired by:
6
7
  * @see https://robertmarshall.dev/blog/dynamically-import-datefns-locale-mui-datepicker-localization/
7
8
  */
8
- export function useDateLocale(locale, defaultLocale = "en") {
9
- const [data, setData] = useState();
10
- const [current, setCurrent] = useState(defaultLocale);
9
+ export function useDateLocale(locale, defaultLocale) {
10
+ var _this = this;
11
+ if (defaultLocale === void 0) { defaultLocale = "en"; }
12
+ var _a = useState(), data = _a[0], setData = _a[1];
13
+ var _b = useState(defaultLocale), current = _b[0], setCurrent = _b[1];
11
14
  // const [ready, setReady] = useState(false);
12
15
  // If the user changes the locale listen to the change and import the locale that is now required.
13
- useEffect(() => {
14
- const importLocaleFile = async () => {
15
- // This webpack option stops all of the date-fns files being imported and chunked.
16
- const localeToSet = await import(
17
- /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
18
- `date-fns/locale/${locale}/index.js`);
19
- setCurrent(locale || current);
20
- setData(localeToSet.default);
21
- // setReady(true);
22
- };
16
+ useEffect(function () {
17
+ var importLocaleFile = function () { return __awaiter(_this, void 0, void 0, function () {
18
+ var localeToSet;
19
+ return __generator(this, function (_a) {
20
+ switch (_a.label) {
21
+ case 0: return [4 /*yield*/, import(
22
+ /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
23
+ "date-fns/locale/".concat(locale, "/index.js"))];
24
+ case 1:
25
+ localeToSet = _a.sent();
26
+ setCurrent(locale || current);
27
+ setData(localeToSet.default);
28
+ return [2 /*return*/];
29
+ }
30
+ });
31
+ }); };
23
32
  // If the locale has not yet been loaded.
24
33
  if (locale !== current) {
25
34
  importLocaleFile();
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts)
4
+ */
5
+ export declare const useEffectOnce: (effect: React.EffectCallback) => void;
@@ -0,0 +1,8 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts)
4
+ */
5
+ export var useEffectOnce = function (effect) {
6
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7
+ useEffect(effect, []);
8
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
3
+ */
4
+ export declare function useFirstMountState(): boolean;
@@ -0,0 +1,12 @@
1
+ import { useRef } from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
4
+ */
5
+ export function useFirstMountState() {
6
+ var isFirst = useRef(true);
7
+ if (isFirst.current) {
8
+ isFirst.current = false;
9
+ return true;
10
+ }
11
+ return isFirst.current;
12
+ }
package/hooks/useFocus.js CHANGED
@@ -2,9 +2,9 @@ import { useRef } from "react";
2
2
  /**
3
3
  * @see https://stackoverflow.com/a/54159564/1938970
4
4
  */
5
- export const useFocus = () => {
6
- const element = useRef(null);
7
- const setFocus = () => {
5
+ export var useFocus = function () {
6
+ var element = useRef(null);
7
+ var setFocus = function () {
8
8
  element.current && element.current.focus();
9
9
  };
10
10
  return [element, setFocus];
@@ -0,0 +1,4 @@
1
+ /**
2
+ * FIXME: once we can move to react 18 just replace this import with `{ useId } from "react";`
3
+ */
4
+ export declare function useId(prefix?: string): string;
package/hooks/useId.js ADDED
@@ -0,0 +1,8 @@
1
+ import { uid } from "@koine/utils";
2
+ /**
3
+ * FIXME: once we can move to react 18 just replace this import with `{ useId } from "react";`
4
+ */
5
+ export function useId(prefix) {
6
+ if (prefix === void 0) { prefix = "uid"; }
7
+ return "".concat(prefix, "-").concat(uid());
8
+ }
@@ -0,0 +1,5 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
4
+ */
5
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -0,0 +1,8 @@
1
+ import { useEffect, useLayoutEffect } from "react";
2
+ import { isBrowser } from "@koine/utils";
3
+ /**
4
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
5
+ */
6
+ export var useIsomorphicLayoutEffect = isBrowser
7
+ ? useLayoutEffect
8
+ : useEffect;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMount.ts)
3
+ */
4
+ export declare const useMount: (fn: () => void) => void;
@@ -0,0 +1,9 @@
1
+ import { useEffectOnce } from "./useEffectOnce";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMount.ts)
4
+ */
5
+ export var useMount = function (fn) {
6
+ useEffectOnce(function () {
7
+ fn();
8
+ });
9
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts)
3
+ */
4
+ export declare function useMountedState(): () => boolean;
@@ -0,0 +1,15 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts)
4
+ */
5
+ export function useMountedState() {
6
+ var mountedRef = useRef(false);
7
+ var get = useCallback(function () { return mountedRef.current; }, []);
8
+ useEffect(function () {
9
+ mountedRef.current = true;
10
+ return function () {
11
+ mountedRef.current = false;
12
+ };
13
+ }, []);
14
+ return get;
15
+ }
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  export function usePrevious(value) {
3
- const ref = useRef();
4
- useEffect(() => {
3
+ var ref = useRef();
4
+ useEffect(function () {
5
5
  ref.current = value;
6
6
  });
7
7
  return ref.current;
@@ -1,17 +1,19 @@
1
1
  import { useRef } from "react";
2
- import useIsomorphicLayoutEffect from "react-use/esm/useIsomorphicLayoutEffect";
3
2
  import { isBrowser } from "@koine/utils";
4
- const zeroPosition = { x: 0, y: 0 };
5
- const getClientRect = (element) => element?.getBoundingClientRect();
6
- const getScrollPosition = (element, useWindow, boundingElement) => {
3
+ import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
4
+ var zeroPosition = { x: 0, y: 0 };
5
+ var getClientRect = function (element) {
6
+ return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
7
+ };
8
+ var getScrollPosition = function (element, useWindow, boundingElement) {
7
9
  if (!isBrowser) {
8
10
  return zeroPosition;
9
11
  }
10
12
  if (useWindow) {
11
13
  return { x: window.scrollX, y: window.scrollY };
12
14
  }
13
- const targetPosition = getClientRect(element?.current || document.body);
14
- const containerPosition = getClientRect(boundingElement?.current);
15
+ var targetPosition = getClientRect((element === null || element === void 0 ? void 0 : element.current) || document.body);
16
+ var containerPosition = getClientRect(boundingElement === null || boundingElement === void 0 ? void 0 : boundingElement.current);
15
17
  if (!targetPosition) {
16
18
  return zeroPosition;
17
19
  }
@@ -29,20 +31,22 @@ const getScrollPosition = (element, useWindow, boundingElement) => {
29
31
  * - reused internal helper functions
30
32
  * - compacted object arguments in functions as plain argument list to improve compression
31
33
  */
32
- export const useScrollPosition = (effect, deps = [], element, useWindow, wait, boundingElement) => {
33
- const position = useRef(getScrollPosition(null, useWindow, boundingElement));
34
- let throttleTimeout = null;
35
- const callBack = () => {
36
- const current = getScrollPosition(element, useWindow, boundingElement);
34
+ export var useScrollPosition = function (effect, deps, element, useWindow, wait, boundingElement) {
35
+ if (deps === void 0) { deps = []; }
36
+ var position = useRef(getScrollPosition(null, useWindow, boundingElement));
37
+ var throttleTimeout = null;
38
+ var callBack = function () {
39
+ var current = getScrollPosition(element, useWindow, boundingElement);
37
40
  effect(current, position.current);
38
41
  position.current = current;
39
42
  throttleTimeout = null;
40
43
  };
41
- useIsomorphicLayoutEffect(() => {
44
+ useIsomorphicLayoutEffect(function () {
45
+ var _a;
42
46
  if (!isBrowser) {
43
47
  return undefined;
44
48
  }
45
- const handleScroll = () => {
49
+ var handleScroll = function () {
46
50
  if (wait) {
47
51
  if (throttleTimeout === null) {
48
52
  throttleTimeout = window.setTimeout(callBack, wait);
@@ -53,16 +57,17 @@ export const useScrollPosition = (effect, deps = [], element, useWindow, wait, b
53
57
  }
54
58
  };
55
59
  if (boundingElement) {
56
- boundingElement.current?.addEventListener("scroll", handleScroll, {
60
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", handleScroll, {
57
61
  passive: true,
58
62
  });
59
63
  }
60
64
  else {
61
65
  window.addEventListener("scroll", handleScroll, { passive: true });
62
66
  }
63
- return () => {
67
+ return function () {
68
+ var _a;
64
69
  if (boundingElement) {
65
- boundingElement.current?.removeEventListener("scroll", handleScroll);
70
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", handleScroll);
66
71
  }
67
72
  else {
68
73
  window.removeEventListener("scroll", handleScroll);
@@ -1,13 +1,15 @@
1
1
  import { isBrowser } from "@koine/utils";
2
2
  import { useHeader } from "../Header/useHeader";
3
- export function useScrollTo(id = "", offset = 0) {
4
- const [, , headerHeight] = useHeader();
3
+ export function useScrollTo(id, offset) {
4
+ if (id === void 0) { id = ""; }
5
+ if (offset === void 0) { offset = 0; }
6
+ var _a = useHeader(), headerHeight = _a[2];
5
7
  if (!isBrowser) {
6
8
  return;
7
9
  }
8
- const headerOffset = headerHeight || 0;
9
- let element = document.getElementById(id);
10
- let top = 0;
10
+ var headerOffset = headerHeight || 0;
11
+ var element = document.getElementById(id);
12
+ var top = 0;
11
13
  if (element && element.offsetParent) {
12
14
  do {
13
15
  top += element.offsetTop;
@@ -3,9 +3,10 @@ import { useEffect, useRef } from "react";
3
3
  * @see https://stackoverflow.com/a/51082563/9122820
4
4
  */
5
5
  export function useTraceUpdate(props) {
6
- const prev = useRef(props);
7
- useEffect(() => {
8
- const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
6
+ var prev = useRef(props);
7
+ useEffect(function () {
8
+ var changedProps = Object.entries(props).reduce(function (ps, _a) {
9
+ var k = _a[0], v = _a[1];
9
10
  if (prev.current[k] !== v) {
10
11
  // @ts-expect-error Does not matter here...
11
12
  ps[k] = [prev.current[k], v];
@@ -0,0 +1,5 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts)
4
+ */
5
+ export declare const useUpdateEffect: typeof useEffect;
@@ -0,0 +1,14 @@
1
+ import { useEffect } from "react";
2
+ import { useFirstMountState } from "./useFirstMountState";
3
+ /**
4
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts)
5
+ */
6
+ export var useUpdateEffect = function (effect, deps) {
7
+ var isFirstMount = useFirstMountState();
8
+ useEffect(function () {
9
+ if (!isFirstMount) {
10
+ return effect();
11
+ }
12
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13
+ }, deps);
14
+ };
@@ -1,13 +1,13 @@
1
1
  import { useEffect, useState } from "react";
2
2
  export function useWindowSize() {
3
- const [size, setSize] = useState([0, 0]);
4
- useEffect(() => {
3
+ var _a = useState([0, 0]), size = _a[0], setSize = _a[1];
4
+ useEffect(function () {
5
5
  function updateSize() {
6
6
  setSize([window.innerWidth, window.innerHeight]);
7
7
  }
8
8
  window.addEventListener("resize", updateSize);
9
9
  updateSize();
10
- return () => window.removeEventListener("resize", updateSize);
10
+ return function () { return window.removeEventListener("resize", updateSize); };
11
11
  }, []);
12
12
  return size;
13
13
  }
@@ -1,3 +1,4 @@
1
+ import { __assign } from "tslib";
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { LazyMotion } from "framer-motion";
3
4
  /**
@@ -32,6 +33,7 @@ import { LazyMotion } from "framer-motion";
32
33
  * </MotionProvider>
33
34
  * ```
34
35
  */
35
- export const MotionProvider = ({ features, children }) => {
36
- return _jsx(LazyMotion, { features: features, children: children });
36
+ export var MotionProvider = function (_a) {
37
+ var features = _a.features, children = _a.children;
38
+ return _jsx(LazyMotion, __assign({ features: features }, { children: children }));
37
39
  };
@@ -1,21 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Alert = void 0;
4
- const tslib_1 = require("tslib");
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
7
- const AlertRoot = styled_components_1.default.div `
8
- font-size: 12px;
9
- ${(p) => (p.$danger ? `color: var(--danger)` : "")}
10
- `;
11
- const AlertInner = styled_components_1.default.div `
12
- padding: 1em;
13
- background-color: rgba(0, 0, 0, 0.05);
14
- /* border: 1px solid var(--grey700); */
15
- /* background: pink; */
16
- /* color: red; */
17
- `;
18
- const Alert = ({ $danger, children, ...props }) => {
19
- return ((0, jsx_runtime_1.jsx)(AlertRoot, { "$danger": $danger, ...props, children: (0, jsx_runtime_1.jsx)(AlertInner, { children: children }) }));
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var styled_components_1 = tslib_1.__importDefault(require("styled-components"));
7
+ var AlertRoot = styled_components_1.default.div(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n font-size: 12px;\n ", "\n"], ["\n font-size: 12px;\n ", "\n"])), function (p) { return (p.$danger ? "color: var(--danger)" : ""); });
8
+ var AlertInner = styled_components_1.default.div(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n padding: 1em;\n background-color: rgba(0, 0, 0, 0.05);\n /* border: 1px solid var(--grey700); */\n /* background: pink; */\n /* color: red; */\n"], ["\n padding: 1em;\n background-color: rgba(0, 0, 0, 0.05);\n /* border: 1px solid var(--grey700); */\n /* background: pink; */\n /* color: red; */\n"])));
9
+ var Alert = function (_a) {
10
+ var $danger = _a.$danger, children = _a.children, props = tslib_1.__rest(_a, ["$danger", "children"]);
11
+ return ((0, jsx_runtime_1.jsx)(AlertRoot, tslib_1.__assign({ "$danger": $danger }, props, { children: (0, jsx_runtime_1.jsx)(AlertInner, { children: children }) })));
20
12
  };
21
13
  exports.Alert = Alert;
14
+ var templateObject_1, templateObject_2;
@@ -1,4 +1,4 @@
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("./Alert"), exports);
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Reveal = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const framer_motion_1 = require("framer-motion");
6
- const useReveal_1 = require("./useReveal");
7
- const Reveal = ({ children, direction, offsetStartY, offsetEndY, offsetStartX, ...props }) => {
8
- const effectOptions = { direction, offsetStartY, offsetEndY, offsetStartX };
9
- const prefersReducedMotion = (0, framer_motion_1.useReducedMotion)();
10
- const { ref, startY, endY, startX } = (0, useReveal_1.useReveal)(effectOptions);
11
- const { scrollYProgress } = (0, framer_motion_1.useViewportScroll)();
12
- const xRange = (0, framer_motion_1.useTransform)(scrollYProgress, [startY, endY], [startX, 0]);
13
- const opacityRange = (0, framer_motion_1.useTransform)(scrollYProgress, [startY, endY], [0, 1]);
14
- const x = (0, framer_motion_1.useSpring)(xRange, { stiffness: 400, damping: 90 });
15
- const opacity = (0, framer_motion_1.useSpring)(opacityRange);
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var framer_motion_1 = require("framer-motion");
7
+ var useReveal_1 = require("./useReveal");
8
+ var Reveal = function (_a) {
9
+ var children = _a.children, direction = _a.direction, offsetStartY = _a.offsetStartY, offsetEndY = _a.offsetEndY, offsetStartX = _a.offsetStartX, props = tslib_1.__rest(_a, ["children", "direction", "offsetStartY", "offsetEndY", "offsetStartX"]);
10
+ var effectOptions = { direction: direction, offsetStartY: offsetStartY, offsetEndY: offsetEndY, offsetStartX: offsetStartX };
11
+ var prefersReducedMotion = (0, framer_motion_1.useReducedMotion)();
12
+ var _b = (0, useReveal_1.useReveal)(effectOptions), ref = _b.ref, startY = _b.startY, endY = _b.endY, startX = _b.startX;
13
+ var scrollYProgress = (0, framer_motion_1.useViewportScroll)().scrollYProgress;
14
+ var xRange = (0, framer_motion_1.useTransform)(scrollYProgress, [startY, endY], [startX, 0]);
15
+ var opacityRange = (0, framer_motion_1.useTransform)(scrollYProgress, [startY, endY], [0, 1]);
16
+ var x = (0, framer_motion_1.useSpring)(xRange, { stiffness: 400, damping: 90 });
17
+ var opacity = (0, framer_motion_1.useSpring)(opacityRange);
16
18
  // console.log("start, end", startY, endY)
17
- return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { ...props, ref: ref, style: prefersReducedMotion ? {} : { x, opacity }, children: children }));
19
+ return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, tslib_1.__assign({}, props, { ref: ref, style: prefersReducedMotion ? {} : { x: x, opacity: opacity } }, { children: children })));
18
20
  };
19
21
  exports.Reveal = Reveal;
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnderlineSkewed = void 0;
4
- const tslib_1 = require("tslib");
5
- const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
6
- const framer_motion_1 = require("framer-motion");
7
- exports.UnderlineSkewed = (0, styled_components_1.default)(framer_motion_1.m.i) `
8
- display: block;
9
- position: absolute;
10
- top: 50%;
11
- left: 15%;
12
- right: 15%;
13
- height: 20px;
14
- margin-top: -10px;
15
- z-index: 0;
16
- pointer-events: none;
17
- background: var(--accent400);
18
- transform: skewY(-5deg);
19
- `;
4
+ var tslib_1 = require("tslib");
5
+ var styled_components_1 = tslib_1.__importDefault(require("styled-components"));
6
+ var framer_motion_1 = require("framer-motion");
7
+ exports.UnderlineSkewed = (0, styled_components_1.default)(framer_motion_1.m.i)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n display: block;\n position: absolute;\n top: 50%;\n left: 15%;\n right: 15%;\n height: 20px;\n margin-top: -10px;\n z-index: 0;\n pointer-events: none;\n background: var(--accent400);\n transform: skewY(-5deg);\n"], ["\n display: block;\n position: absolute;\n top: 50%;\n left: 15%;\n right: 15%;\n height: 20px;\n margin-top: -10px;\n z-index: 0;\n pointer-events: none;\n background: var(--accent400);\n transform: skewY(-5deg);\n"])));
8
+ var templateObject_1;
@@ -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("./Reveal"), exports);
5
5
  tslib_1.__exportStar(require("./Underline"), exports);
6
6
  tslib_1.__exportStar(require("./useReveal"), exports);
@@ -1,35 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useReveal = void 0;
4
- const react_1 = require("react");
5
- function useReveal({ direction = "left", offsetStartY = -2, offsetEndY = 0, offsetStartX = "all", }) {
6
- const ref = (0, react_1.useRef)(null);
7
- const [startY, setStartY] = (0, react_1.useState)(0);
8
- const [endY, setEndY] = (0, react_1.useState)(0);
9
- const [startX, setStartX] = (0, react_1.useState)(0);
10
- (0, react_1.useEffect)(() => {
4
+ var react_1 = require("react");
5
+ function useReveal(_a) {
6
+ var _b = _a.direction, direction = _b === void 0 ? "left" : _b, _c = _a.offsetStartY, offsetStartY = _c === void 0 ? -2 : _c, _d = _a.offsetEndY, offsetEndY = _d === void 0 ? 0 : _d, _e = _a.offsetStartX, offsetStartX = _e === void 0 ? "all" : _e;
7
+ var ref = (0, react_1.useRef)(null);
8
+ var _f = (0, react_1.useState)(0), startY = _f[0], setStartY = _f[1];
9
+ var _g = (0, react_1.useState)(0), endY = _g[0], setEndY = _g[1];
10
+ var _h = (0, react_1.useState)(0), startX = _h[0], setStartX = _h[1];
11
+ (0, react_1.useEffect)(function () {
11
12
  if (!ref.current) {
12
13
  return;
13
14
  }
14
- const rect = ref.current.getBoundingClientRect();
15
+ var rect = ref.current.getBoundingClientRect();
15
16
  // scroll position from top of the window
16
- const scrollTop = window.scrollY || document.documentElement.scrollTop;
17
- const elementHeight = rect.height;
17
+ var scrollTop = window.scrollY || document.documentElement.scrollTop;
18
+ var elementHeight = rect.height;
18
19
  // rect.top is the distance from the currently visible viewport to the top
19
20
  // of the given element
20
21
  // so distanceTop is the distance between the top edge of the window and the
21
22
  // top edge of the given element
22
- const elementTop = rect.top;
23
- const distanceTop = elementTop + scrollTop;
24
- const offsetTop = offsetStartY ? elementHeight * offsetStartY : 0;
25
- const offsetBottom = offsetEndY ? elementHeight * offsetEndY : offsetTop;
23
+ var elementTop = rect.top;
24
+ var distanceTop = elementTop + scrollTop;
25
+ var offsetTop = offsetStartY ? elementHeight * offsetStartY : 0;
26
+ var offsetBottom = offsetEndY ? elementHeight * offsetEndY : offsetTop;
26
27
  // the distance of the element from the top divided by the full height
27
28
  // of the window gives back the start position of the given element in
28
29
  // a scale from 0 to 1
29
- const startY = (distanceTop + offsetTop) / document.body.clientHeight;
30
+ var startY = (distanceTop + offsetTop) / document.body.clientHeight;
30
31
  // same for the end, we just add the given element height to the first value
31
- const endY = (distanceTop + elementHeight + offsetBottom) / document.body.clientHeight;
32
- let startX;
32
+ var endY = (distanceTop + elementHeight + offsetBottom) / document.body.clientHeight;
33
+ var startX;
33
34
  if (offsetStartX === "all") {
34
35
  startX = direction === "left" ? -rect.right : rect.left;
35
36
  }
@@ -54,7 +55,7 @@ function useReveal({ direction = "left", offsetStartY = -2, offsetEndY = 0, offs
54
55
  offsetStartX,
55
56
  direction,
56
57
  ]);
57
- return { ref, startY, endY, startX };
58
+ return { ref: ref, startY: startY, endY: endY, startX: startX };
58
59
  }
59
60
  exports.useReveal = useReveal;
60
61
  // function addMarker(top: string, color = "red", position = "absolute") {