@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
@@ -0,0 +1,18 @@
1
+ import { __makeTemplateObject } from "tslib";
2
+ import { classed, extendComponent } from "../../helpers";
3
+ import { KoineTabs as _ } from "./bare";
4
+ export var Root = classed(_.Root)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["< class=\""], ["< class=\""])));
5
+ export var List = classed(_.List)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["< class=\"border-b-gray-200 border-b border-solid"], ["< class=\"border-b-gray-200 border-b border-solid"])));
6
+ export var Tab = classed(_.Tab)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["< class=\"flex-col relative py-3 px-4 uppercase"], ["< class=\"flex-col relative py-3 px-4 uppercase"]))); // ${p => p.selected ? "text-cyan-600" : ""}
7
+ export var Indicator = classed(_.Indicator)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["< class=\"absolute bottom-0 w-full h-[2px] ", ""], ["< class=\"absolute bottom-0 w-full h-[2px] ", ""])), function (p) {
8
+ return p.selected ? "bg-current" : "";
9
+ });
10
+ export var Panel = classed(_.Panel)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["< class=\"tabsPanel"], ["< class=\"tabsPanel"])));
11
+ export var KoineTabs = extendComponent(_, {
12
+ Root: Root,
13
+ List: List,
14
+ Tab: Tab,
15
+ Indicator: Indicator,
16
+ Panel: Panel,
17
+ });
18
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ export interface UseTabsProps {
3
+ /**
4
+ * The value of the currently selected `Tab`.
5
+ * If you don't want any selected `Tab`, you can set this prop to `false`.
6
+ */
7
+ value?: string | number | false;
8
+ /**
9
+ * The default value. Use when the component is not controlled.
10
+ */
11
+ defaultValue?: string | number | false;
12
+ /**
13
+ * The component orientation (layout flow direction).
14
+ * @default 'horizontal'
15
+ */
16
+ orientation?: "horizontal" | "vertical";
17
+ /**
18
+ * The direction of the text.
19
+ * @default 'ltr'
20
+ */
21
+ direction?: "ltr" | "rtl";
22
+ /**
23
+ * Callback invoked when new value is being set.
24
+ */
25
+ onChange?: (event: React.SyntheticEvent, value: number | string) => void;
26
+ /**
27
+ * If `true` the selected tab changes on focus. Otherwise it only
28
+ * changes on activation.
29
+ */
30
+ selectionFollowsFocus?: boolean;
31
+ }
32
+ export declare const useTabs: (props: UseTabsProps) => {
33
+ getRootProps: () => {};
34
+ tabsContextValue: {
35
+ idPrefix: string;
36
+ value: string | number | false;
37
+ onSelected: (event: React.SyntheticEvent, value: number | string) => void;
38
+ orientation: "horizontal" | "vertical" | undefined;
39
+ direction: "ltr" | "rtl" | undefined;
40
+ selectionFollowsFocus: boolean | undefined;
41
+ };
42
+ };
43
+ export default useTabs;
@@ -0,0 +1,44 @@
1
+ import { useCallback, /* useId, */ useMemo } from "react";
2
+ import { unstable_useControlled as useControlled } from "@mui/utils";
3
+ import { useId } from "../hooks/useId";
4
+ export var useTabs = function (props) {
5
+ var valueProp = props.value, defaultValue = props.defaultValue, onChange = props.onChange, orientation = props.orientation, direction = props.direction, selectionFollowsFocus = props.selectionFollowsFocus;
6
+ var _a = useControlled({
7
+ controlled: valueProp,
8
+ default: defaultValue,
9
+ name: "Tabs",
10
+ state: "value",
11
+ }), value = _a[0], setValue = _a[1];
12
+ var idPrefix = useId();
13
+ var onSelected = useCallback(function (e, newValue) {
14
+ setValue(newValue);
15
+ if (onChange) {
16
+ onChange(e, newValue);
17
+ }
18
+ }, [onChange, setValue]);
19
+ var getRootProps = function () {
20
+ return {};
21
+ };
22
+ var tabsContextValue = useMemo(function () {
23
+ return {
24
+ idPrefix: idPrefix,
25
+ value: value,
26
+ onSelected: onSelected,
27
+ orientation: orientation,
28
+ direction: direction,
29
+ selectionFollowsFocus: selectionFollowsFocus,
30
+ };
31
+ }, [
32
+ idPrefix,
33
+ value,
34
+ onSelected,
35
+ orientation,
36
+ direction,
37
+ selectionFollowsFocus,
38
+ ]);
39
+ return {
40
+ getRootProps: getRootProps,
41
+ tabsContextValue: tabsContextValue,
42
+ };
43
+ };
44
+ export default useTabs;
@@ -1,6 +1,4 @@
1
+ import { __makeTemplateObject } from "tslib";
1
2
  import styled from "styled-components";
2
- export const CopyPasteVisible = styled.span `
3
- color: transparent;
4
- opacity: 0;
5
- font-size: 0;
6
- `;
3
+ export var CopyPasteVisible = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: transparent;\n opacity: 0;\n font-size: 0;\n"], ["\n color: transparent;\n opacity: 0;\n font-size: 0;\n"])));
4
+ var templateObject_1;
@@ -1,47 +1,14 @@
1
+ import { __makeTemplateObject } from "tslib";
1
2
  import styled from "styled-components";
2
3
  import { min } from "../styles/media";
3
- export const p = `
4
- margin: 0 0 1em 0;
5
- `;
6
- export const h1 = `
7
- margin: 0 0 10px 0;
8
- font-size: 30px;
9
- font-weight: 800;
10
- line-height: var(--headingsLineHeight);
11
- ${min.md} {
12
- font-size: 50px;
13
- }
14
- `;
15
- export const h2 = `
16
- margin: 0 0 1em 0;
17
- font-size: 24px;
18
- font-weight: 800;
19
- line-height: var(--headingsLineHeight);
20
- `;
21
- export const h3 = `
22
- margin: 0 0 1em 0;
23
- font-size: 20px;
24
- font-weight: 600;
25
- line-height: var(--headingsLineHeight);
26
- `;
27
- export const h4 = `
28
- margin: 0 0 1em 0;
29
- font-size: 13px;
30
- font-weight: 600;
31
- line-height: var(--headingsLineHeight);
32
- `;
33
- export const P = styled.div `
34
- ${p}
35
- `;
36
- export const H1 = styled.div `
37
- ${h1}
38
- `;
39
- export const H2 = styled.div `
40
- ${h2}
41
- `;
42
- export const H3 = styled.div `
43
- ${h3}
44
- `;
45
- export const H4 = styled.div `
46
- ${h4}
47
- `;
4
+ export var p = "\n margin: 0 0 1em 0;\n";
5
+ export var h1 = "\n margin: 0 0 10px 0;\n font-size: 30px;\n font-weight: 800;\n line-height: var(--headingsLineHeight);\n ".concat(min.md, " {\n font-size: 50px;\n }\n");
6
+ export var h2 = "\n margin: 0 0 1em 0;\n font-size: 24px;\n font-weight: 800;\n line-height: var(--headingsLineHeight);\n";
7
+ export var h3 = "\n margin: 0 0 1em 0;\n font-size: 20px;\n font-weight: 600;\n line-height: var(--headingsLineHeight);\n";
8
+ export var h4 = "\n margin: 0 0 1em 0;\n font-size: 13px;\n font-weight: 600;\n line-height: var(--headingsLineHeight);\n";
9
+ export var P = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), p);
10
+ export var H1 = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h1);
11
+ export var H2 = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h2);
12
+ export var H3 = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h3);
13
+ export var H4 = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), h4);
14
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -1,60 +1,33 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { useState, useRef, useMemo } from "react";
3
4
  import styled from "styled-components";
4
- import { useIsomorphicLayoutEffect } from "react-use";
5
5
  import { m, useSpring } from "framer-motion";
6
6
  // import { CgArrowsExpandDownRight as IconExpand } from "react-icons/cg";
7
- const Root = styled.div ``;
8
- const Content = styled.div `
9
- & p:first-child {
10
- margin-top: 0;
11
- }
12
- `;
13
- const BtnWrap = styled.span `
14
- display: flex;
15
- justify-content: flex-end;
16
- transition: transform 0.18s ease-in-out;
17
- text-align: right;
18
- transform: translateY(${(p) => (p.$expanded ? "0" : "-100%")});
19
- opacity: ${(p) => (p.$expanded ? 0 : 1)};
20
- `;
21
- const BtnFader = styled.div `
22
- width: 30%;
23
- transition: transform 0.18s ease-in-out;
24
- background: linear-gradient(45deg, transparent 50%, ${(p) => p.$bg} 70%);
25
- `;
26
- const Btn = styled.span `
27
- padding: 0 10px 0 10px;
28
- line-height: ${(p) => (p.$lineHeight ? p.$lineHeight : "inherit")};
29
- background: var(--bodyBg);
30
- color: var(--grey600);
31
- white-space: nowrap;
32
- font-size: ${(p) => p.$fontSize}px;
33
- cursor: pointer;
34
- `;
35
- const BtnIcon = styled.span `
36
- display: inline-block;
37
- margin: 0 0 0 4px;
38
- transition: transform 0.18s ease-in-out;
39
- ${(p) => (p.$expanded ? "transform: rotate(180deg);" : "")};
40
- font-size: ${(p) => p.$fontSize}px;
41
- `;
42
- export const ReadMore = ({ lines = 3, lineHeight = 1.6, fontSize = 14, bg = "var(--bodyBg)", expand = "Expand", collapse = "Collapse", ...props }) => {
43
- const defaultMaxHeight = lines * (lineHeight * fontSize);
44
- const [expanded, setExpanded] = useState(false);
45
- const [maxHeight, setMaxHeight] = useState(defaultMaxHeight);
46
- const [fullHeight, setFullHeight] = useState(0);
47
- const [exceeds, setExceeds] = useState(false);
48
- const content = useRef(null);
49
- const height = useSpring(defaultMaxHeight);
50
- const styles = useMemo(() => (exceeds ? { height, overflow: "hidden" } : {}), [exceeds, height]);
51
- const handleExpandClick = () => {
52
- setExpanded((prevExpanded) => !prevExpanded);
7
+ import { useIsomorphicLayoutEffect } from "../hooks";
8
+ var Root = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
9
+ var Content = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n & p:first-child {\n margin-top: 0;\n }\n"], ["\n & p:first-child {\n margin-top: 0;\n }\n"])));
10
+ var BtnWrap = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n transition: transform 0.18s ease-in-out;\n text-align: right;\n transform: translateY(", ");\n opacity: ", ";\n"], ["\n display: flex;\n justify-content: flex-end;\n transition: transform 0.18s ease-in-out;\n text-align: right;\n transform: translateY(", ");\n opacity: ", ";\n"])), function (p) { return (p.$expanded ? "0" : "-100%"); }, function (p) { return (p.$expanded ? 0 : 1); });
11
+ var BtnFader = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 30%;\n transition: transform 0.18s ease-in-out;\n background: linear-gradient(45deg, transparent 50%, ", " 70%);\n"], ["\n width: 30%;\n transition: transform 0.18s ease-in-out;\n background: linear-gradient(45deg, transparent 50%, ", " 70%);\n"])), function (p) { return p.$bg; });
12
+ var Btn = styled.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: 0 10px 0 10px;\n line-height: ", ";\n background: var(--bodyBg);\n color: var(--grey600);\n white-space: nowrap;\n font-size: ", "px;\n cursor: pointer;\n"], ["\n padding: 0 10px 0 10px;\n line-height: ", ";\n background: var(--bodyBg);\n color: var(--grey600);\n white-space: nowrap;\n font-size: ", "px;\n cursor: pointer;\n"])), function (p) { return (p.$lineHeight ? p.$lineHeight : "inherit"); }, function (p) { return p.$fontSize; });
13
+ var BtnIcon = styled.span(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: inline-block;\n margin: 0 0 0 4px;\n transition: transform 0.18s ease-in-out;\n ", ";\n font-size: ", "px;\n"], ["\n display: inline-block;\n margin: 0 0 0 4px;\n transition: transform 0.18s ease-in-out;\n ", ";\n font-size: ", "px;\n"])), function (p) { return (p.$expanded ? "transform: rotate(180deg);" : ""); }, function (p) { return p.$fontSize; });
14
+ export var ReadMore = function (_a) {
15
+ var _b = _a.lines, lines = _b === void 0 ? 3 : _b, _c = _a.lineHeight, lineHeight = _c === void 0 ? 1.6 : _c, _d = _a.fontSize, fontSize = _d === void 0 ? 14 : _d, _e = _a.bg, bg = _e === void 0 ? "var(--bodyBg)" : _e, _f = _a.expand, expand = _f === void 0 ? "Expand" : _f, _g = _a.collapse, collapse = _g === void 0 ? "Collapse" : _g, props = __rest(_a, ["lines", "lineHeight", "fontSize", "bg", "expand", "collapse"]);
16
+ var defaultMaxHeight = lines * (lineHeight * fontSize);
17
+ var _h = useState(false), expanded = _h[0], setExpanded = _h[1];
18
+ var _j = useState(defaultMaxHeight), maxHeight = _j[0], setMaxHeight = _j[1];
19
+ var _k = useState(0), fullHeight = _k[0], setFullHeight = _k[1];
20
+ var _l = useState(false), exceeds = _l[0], setExceeds = _l[1];
21
+ var content = useRef(null);
22
+ var height = useSpring(defaultMaxHeight);
23
+ var styles = useMemo(function () { return (exceeds ? { height: height, overflow: "hidden" } : {}); }, [exceeds, height]);
24
+ var handleExpandClick = function () {
25
+ setExpanded(function (prevExpanded) { return !prevExpanded; });
53
26
  };
54
- useIsomorphicLayoutEffect(() => {
27
+ useIsomorphicLayoutEffect(function () {
55
28
  if (content.current) {
56
- const elementHeight = content.current.offsetHeight;
57
- const newExceeds = elementHeight > maxHeight;
29
+ var elementHeight = content.current.offsetHeight;
30
+ var newExceeds = elementHeight > maxHeight;
58
31
  if (!newExceeds) {
59
32
  setMaxHeight(elementHeight);
60
33
  }
@@ -62,8 +35,9 @@ export const ReadMore = ({ lines = 3, lineHeight = 1.6, fontSize = 14, bg = "var
62
35
  setFullHeight(elementHeight);
63
36
  }
64
37
  }, [content, maxHeight]);
65
- useIsomorphicLayoutEffect(() => {
38
+ useIsomorphicLayoutEffect(function () {
66
39
  height.set(expanded ? fullHeight : maxHeight);
67
40
  }, [expanded, height, fullHeight, maxHeight]);
68
- return (_jsxs(Root, { children: [_jsx(m.div, { style: styles, children: _jsx(Content, { ref: content, ...props }) }), exceeds && (_jsxs(BtnWrap, { "$expanded": expanded, children: [_jsx(BtnFader, { "$bg": bg }), _jsxs(Btn, { "$fontSize": fontSize, "$lineHeight": lineHeight, onClick: handleExpandClick, "aria-expanded": expanded, "aria-label": expanded ? collapse : expand, children: [expanded ? collapse : expand, _jsx(BtnIcon, { "$expanded": expanded })] })] }))] }));
41
+ return (_jsxs(Root, { children: [_jsx(m.div, __assign({ style: styles }, { children: _jsx(Content, __assign({ ref: content }, props)) })), exceeds && (_jsxs(BtnWrap, __assign({ "$expanded": expanded }, { children: [_jsx(BtnFader, { "$bg": bg }), _jsxs(Btn, __assign({ "$fontSize": fontSize, "$lineHeight": lineHeight, onClick: handleExpandClick, "aria-expanded": expanded, "aria-label": expanded ? collapse : expand }, { children: [expanded ? collapse : expand, _jsx(BtnIcon, { "$expanded": expanded })] }))] })))] }));
69
42
  };
43
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
@@ -1,12 +1,14 @@
1
+ import { __assign, __rest } from "tslib";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { useEffect, useRef, useState } from "react";
3
4
  import { m, AnimatePresence } from "framer-motion";
4
- export const TextLoopPiece = ({ text = "", style = {}, className = "", direction = "up", inline = true, noOverflow = true, delay = 400, }) => {
5
- const placeholderRef = useRef(null);
6
- const [content, setContent] = useState({ data: "", key: "" });
7
- const [width, setWidth] = useState(inline ? 0 : "auto");
8
- useEffect(() => {
9
- const timeoutId = setTimeout(() => {
5
+ export var TextLoopPiece = function (_a) {
6
+ 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;
7
+ var placeholderRef = useRef(null);
8
+ var _j = useState({ data: "", key: "" }), content = _j[0], setContent = _j[1];
9
+ var _k = useState(inline ? 0 : "auto"), width = _k[0], setWidth = _k[1];
10
+ useEffect(function () {
11
+ var timeoutId = setTimeout(function () {
10
12
  if (!placeholderRef.current)
11
13
  return;
12
14
  placeholderRef.current.innerHTML = text + "";
@@ -14,15 +16,9 @@ export const TextLoopPiece = ({ text = "", style = {}, className = "", direction
14
16
  setWidth(placeholderRef.current.offsetWidth);
15
17
  setContent({ data: text + "", key: new Date() + "" });
16
18
  }, delay);
17
- return () => clearTimeout(timeoutId);
19
+ return function () { return clearTimeout(timeoutId); };
18
20
  }, [text, delay, inline]);
19
- return (_jsxs("div", { className: className, style: {
20
- ...style,
21
- position: "relative",
22
- display: inline ? "inline-block" : "block",
23
- width,
24
- whiteSpace: inline ? "nowrap" : "normal",
25
- }, children: [_jsx("span", { ref: placeholderRef, style: { visibility: "hidden" } }), _jsx("div", { style: {
21
+ return (_jsxs("div", __assign({ className: className, style: __assign(__assign({}, style), { position: "relative", display: inline ? "inline-block" : "block", width: width, whiteSpace: inline ? "nowrap" : "normal" }) }, { children: [_jsx("span", { ref: placeholderRef, style: { visibility: "hidden" } }), _jsx("div", __assign({ style: {
26
22
  overflow: noOverflow ? "hidden" : "visible",
27
23
  display: "block",
28
24
  position: "absolute",
@@ -30,20 +26,21 @@ export const TextLoopPiece = ({ text = "", style = {}, className = "", direction
30
26
  left: 0,
31
27
  height: "100%",
32
28
  width: "100%",
33
- }, children: _jsx(AnimatePresence, { children: _jsx(m.div, { style: { position: "absolute" }, initial: {
29
+ } }, { children: _jsx(AnimatePresence, { children: _jsx(m.div, __assign({ style: { position: "absolute" }, initial: {
34
30
  opacity: 0,
35
31
  y: direction === "down" ? "-100%" : "100%",
36
32
  }, animate: { opacity: 1, y: 0 }, exit: {
37
33
  opacity: 0,
38
34
  y: direction === "down" ? "100%" : "-100%",
39
- }, children: content.data }, content.key) }) })] }));
35
+ } }, { children: content.data }), content.key) }) }))] })));
40
36
  };
41
- export const TextLoop = ({ texts, interval = 3000, ...props }) => {
42
- const [index, setIndex] = useState(0);
43
- useEffect(() => {
44
- const intervalId = setInterval(() => setIndex((index) => index + 1), interval // every 3 seconds
37
+ export var TextLoop = function (_a) {
38
+ var texts = _a.texts, _b = _a.interval, interval = _b === void 0 ? 3000 : _b, props = __rest(_a, ["texts", "interval"]);
39
+ var _c = useState(0), index = _c[0], setIndex = _c[1];
40
+ useEffect(function () {
41
+ var intervalId = setInterval(function () { return setIndex(function (index) { return index + 1; }); }, interval // every 3 seconds
45
42
  );
46
- return () => clearTimeout(intervalId);
43
+ return function () { return clearTimeout(intervalId); };
47
44
  }, [interval]);
48
- return _jsx(TextLoopPiece, { ...props, text: texts[index % texts.length] });
45
+ return _jsx(TextLoopPiece, __assign({}, props, { text: texts[index % texts.length] }));
49
46
  };
@@ -1,23 +1,27 @@
1
+ import { __assign } from "tslib";
1
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  import { forwardRef } from "react";
3
- export const TypeStairs = forwardRef(({ children, limit }, ref) => {
4
+ export var TypeStairs = forwardRef(function (_a, ref) {
5
+ var children = _a.children, limit = _a.limit;
4
6
  // split in rows or just use one row if there is no limit
5
- const rows = limit ? splitTextIntoRows(children, limit) : [children];
6
- return rows.length > 1 ? (_jsx(_Fragment, { children: rows.map((row, rowIndex) => {
7
- return (_jsxs("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && _jsx("br", {})] }, `row-${rowIndex}`));
7
+ var rows = limit ? splitTextIntoRows(children, limit) : [children];
8
+ return rows.length > 1 ? (_jsx(_Fragment, { children: rows.map(function (row, rowIndex) {
9
+ return (_jsxs("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && _jsx("br", {})] }, "row-".concat(rowIndex)));
8
10
  }) })) : (renderRow(rows[0], 0, ref));
9
11
  });
10
12
  /**
11
13
  * every number chars find a space and break, then restart the gradient weight
12
14
  * @see https://stackoverflow.com/a/25770787
13
15
  */
14
- function splitTextIntoRows(input = "", limit = 18) {
15
- const rows = [];
16
- const arr = input.split(" ");
17
- let currow = arr[0];
18
- let rowlen = currow.length;
19
- for (let i = 1; i < arr.length; i++) {
20
- const word = arr[i];
16
+ function splitTextIntoRows(input, limit) {
17
+ if (input === void 0) { input = ""; }
18
+ if (limit === void 0) { limit = 18; }
19
+ var rows = [];
20
+ var arr = input.split(" ");
21
+ var currow = arr[0];
22
+ var rowlen = currow.length;
23
+ for (var i = 1; i < arr.length; i++) {
24
+ var word = arr[i];
21
25
  rowlen += word.length + 1;
22
26
  if (rowlen <= limit) {
23
27
  currow += " " + word;
@@ -32,15 +36,15 @@ function splitTextIntoRows(input = "", limit = 18) {
32
36
  return rows;
33
37
  }
34
38
  function renderRow(row, rowIndex, ref) {
35
- const letters = row.split("");
36
- let fontWeightIdx = 1;
39
+ var letters = row.split("");
40
+ var fontWeightIdx = 1;
37
41
  // const fontWeight = Math.min(fontWeightIdx * 100, 800);
38
- return (_jsx(_Fragment, { children: letters.map((letter, letterIndex) => {
39
- const fontWeight = Math.min(fontWeightIdx * 100, 800);
42
+ return (_jsx(_Fragment, { children: letters.map(function (letter, letterIndex) {
43
+ var fontWeight = Math.min(fontWeightIdx * 100, 800);
40
44
  // don't waste a fontWeight for a white space
41
45
  if (letter !== " ") {
42
46
  fontWeightIdx++;
43
47
  }
44
- return (_jsx("span", { style: { fontWeight }, ref: ref, children: letter }, `letter-${rowIndex}-${letterIndex}`));
48
+ return (_jsx("span", __assign({ style: { fontWeight: fontWeight }, ref: ref }, { children: letter }), "letter-".concat(rowIndex, "-").concat(letterIndex)));
45
49
  }) }));
46
50
  }
package/css/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "../shared";
9
9
  // export * from "../Collapsable";
10
10
  // export * from "../Debug";
11
11
  export { KoineDialog } from "../Dialog/css/bare";
12
+ // export * from "../Form";
12
13
  // export * from "../Forms";
13
14
  // export * from "../Grid";
14
15
  // export * from "../Hamburger";
@@ -1,3 +1,4 @@
1
+ import { __assign } from "tslib";
1
2
  import { createElement, forwardRef } from "react";
2
3
  /**
3
4
  * This utility allows to extend a component a là `styled-components` but for
@@ -15,12 +16,17 @@ import { createElement, forwardRef } from "react";
15
16
  */
16
17
  export function classed(component) {
17
18
  // @ts-expect-error nevermind for now...
18
- const type = component.type || component;
19
- return function (strings, ...args) {
20
- const WrappedComponent = forwardRef(function (props, ref) {
21
- const argResolved = args
22
- .map((arg, index) => {
23
- let result = "";
19
+ var type = component.type || component;
20
+ return function (strings) {
21
+ var args = [];
22
+ for (var _i = 1; _i < arguments.length; _i++) {
23
+ args[_i - 1] = arguments[_i];
24
+ }
25
+ var WrappedComponent = forwardRef(function (props, ref) {
26
+ var _a;
27
+ var argResolved = args
28
+ .map(function (arg, index) {
29
+ var result = "";
24
30
  if (typeof arg === "function") {
25
31
  result = arg(props);
26
32
  }
@@ -30,32 +36,30 @@ export function classed(component) {
30
36
  return strings[index] + result;
31
37
  })
32
38
  .join("");
33
- const isNativeHtmlElement = typeof type === "string";
34
- const propsToForward = isNativeHtmlElement
39
+ var isNativeHtmlElement = typeof type === "string";
40
+ var propsToForward = isNativeHtmlElement
35
41
  ? {}
36
42
  : props;
37
43
  if (isNativeHtmlElement) {
38
- for (const key in props) {
44
+ for (var key in props) {
39
45
  // like styled-components `transient` props
40
46
  if (!key.startsWith("$")) {
47
+ // FIXME: for react 18 we need: @ts-expect-error
41
48
  propsToForward[key] = props[key];
42
49
  }
43
50
  }
44
51
  }
45
52
  // get the tagged function string outcome
46
- let className = argResolved || strings[0];
53
+ var className = argResolved || strings[0];
47
54
  // check if we need to clean it or not from the optional structure `< class="..."`
48
- className = className.match(/class="([^"]*)/)?.[1] || className;
55
+ className = ((_a = className.match(/class="([^"]*)/)) === null || _a === void 0 ? void 0 : _a[1]) || className;
49
56
  // add the custom classes from props
50
- className += props?.className ? " " + props?.className : "";
51
- return createElement(type, {
52
- // ...props,
53
- ...propsToForward,
57
+ className += (props === null || props === void 0 ? void 0 : props.className) ? " " + (props === null || props === void 0 ? void 0 : props.className) : "";
58
+ return createElement(type, __assign(__assign({}, propsToForward), {
54
59
  // only add ot props if it is not an empty string
55
- className: className || undefined,
60
+ className: className || undefined,
56
61
  // add ref to props
57
- ref,
58
- });
62
+ ref: ref }));
59
63
  });
60
64
  // FIXME: not sure if this is needed
61
65
  // WrappedComponent.displayName = type.toString();
@@ -1,12 +1,12 @@
1
+ import { __assign } from "tslib";
1
2
  import { createElement } from "react";
2
- export const extendComponent = (component, defaultProps) => {
3
+ export var extendComponent = function (component, defaultProps) {
3
4
  // FIXME: check if we need to forwardRef or not
4
- const NewComponent = (props) => createElement(component, props);
5
+ var NewComponent = function (props) {
6
+ return createElement(component, props);
7
+ };
5
8
  // const NewComponent = forwardRef<React.ComponentProps<Component>, Component>(
6
9
  // (props, ref) => createElement(component, { ...props, ref })
7
10
  // );
8
- return Object.assign(NewComponent, {
9
- ...defaultProps,
10
- defaultProps,
11
- });
11
+ return Object.assign(NewComponent, __assign(__assign({}, defaultProps), { defaultProps: defaultProps }));
12
12
  };
package/hooks/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
+ export * from "./useAsyncFn";
1
2
  export * from "./useDateLocale";
3
+ export * from "./useEffectOnce";
4
+ export * from "./useFirstMountState";
2
5
  export * from "./useFocus";
6
+ export * from "./useId";
7
+ export * from "./useIsomorphicLayoutEffect";
8
+ export * from "./useMount";
9
+ export * from "./useMountedState";
3
10
  export * from "./usePrevious";
4
11
  export * from "./useScrollPosition";
5
12
  export * from "./useTraceUpdate";
13
+ export * from "./useUpdateEffect";
6
14
  export * from "./useWindowSize";
package/hooks/index.js CHANGED
@@ -1,7 +1,15 @@
1
+ export * from "./useAsyncFn";
1
2
  export * from "./useDateLocale";
3
+ export * from "./useEffectOnce";
4
+ export * from "./useFirstMountState";
2
5
  export * from "./useFocus";
6
+ export * from "./useId";
7
+ export * from "./useIsomorphicLayoutEffect";
8
+ export * from "./useMount";
9
+ export * from "./useMountedState";
3
10
  export * from "./usePrevious";
4
11
  export * from "./useScrollPosition";
5
12
  // export * from "./useScrollTo";
6
13
  export * from "./useTraceUpdate";
14
+ export * from "./useUpdateEffect";
7
15
  export * from "./useWindowSize";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
3
+ */
4
+ export declare type PromiseType<P extends Promise<any>> = P extends Promise<infer T> ? T : never;
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
7
+ */
8
+ export declare type FunctionReturningPromise = (...args: any[]) => Promise<any>;
package/hooks/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import type { FunctionReturningPromise, PromiseType } from "./types";
3
+ export declare type AsyncState<T> = {
4
+ loading: boolean;
5
+ error?: undefined;
6
+ value?: undefined;
7
+ } | {
8
+ loading: true;
9
+ error?: Error | undefined;
10
+ value?: T;
11
+ } | {
12
+ loading: false;
13
+ error: Error;
14
+ value?: undefined;
15
+ } | {
16
+ loading: false;
17
+ error?: undefined;
18
+ value: T;
19
+ };
20
+ declare type StateFromFunctionReturningPromise<T extends FunctionReturningPromise> = AsyncState<PromiseType<ReturnType<T>>>;
21
+ export declare type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturningPromise> = [StateFromFunctionReturningPromise<T>, T];
22
+ /**
23
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
24
+ */
25
+ export declare function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
26
+ export {};
@@ -0,0 +1,36 @@
1
+ import { __assign } from "tslib";
2
+ import { useCallback, useRef, useState } from "react";
3
+ import { useMountedState } from "./useMountedState";
4
+ /**
5
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
6
+ */
7
+ export function useAsyncFn(fn, deps, initialState) {
8
+ if (deps === void 0) { deps = []; }
9
+ if (initialState === void 0) { initialState = { loading: false }; }
10
+ var lastCallId = useRef(0);
11
+ var isMounted = useMountedState();
12
+ var _a = useState(initialState), state = _a[0], set = _a[1];
13
+ var callback = useCallback(function () {
14
+ var args = [];
15
+ for (var _i = 0; _i < arguments.length; _i++) {
16
+ args[_i] = arguments[_i];
17
+ }
18
+ var callId = ++lastCallId.current;
19
+ if (!state.loading) {
20
+ set(function (prevState) { return (__assign(__assign({}, prevState), { loading: true })); });
21
+ }
22
+ return fn.apply(void 0, args).then(function (value) {
23
+ isMounted() &&
24
+ callId === lastCallId.current &&
25
+ set({ value: value, loading: false });
26
+ return value;
27
+ }, function (error) {
28
+ isMounted() &&
29
+ callId === lastCallId.current &&
30
+ set({ error: error, loading: false });
31
+ return error;
32
+ });
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ }, deps);
35
+ return [state, callback];
36
+ }