@neko-os/ui 0.0.5 → 0.0.7

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 (337) hide show
  1. package/dist/NekoUI.js +1 -1
  2. package/dist/abstractions/ActivityIndicator.js +1 -0
  3. package/dist/abstractions/ActivityIndicator.native.js +1 -0
  4. package/dist/abstractions/AnimatedView.js +1 -0
  5. package/dist/abstractions/AnimatedView.native.js +1 -0
  6. package/dist/abstractions/DraggableSlideView.js +1 -0
  7. package/dist/abstractions/DraggableSlideView.native.js +1 -0
  8. package/dist/abstractions/Icon.js +1 -1
  9. package/dist/abstractions/Image.js +1 -0
  10. package/dist/abstractions/Image.native.js +1 -0
  11. package/dist/abstractions/Image.web.js +1 -0
  12. package/dist/abstractions/Platform.js +1 -0
  13. package/dist/abstractions/Platform.native.js +1 -0
  14. package/dist/abstractions/Platform.web.js +1 -0
  15. package/dist/abstractions/SafeAreaView.js +1 -0
  16. package/dist/abstractions/SafeAreaView.native.js +1 -0
  17. package/dist/abstractions/Table.js +1 -0
  18. package/dist/abstractions/Table.native.js +1 -0
  19. package/dist/abstractions/Text.js +1 -1
  20. package/dist/abstractions/TextInput.js +1 -0
  21. package/dist/abstractions/TextInput.native.js +1 -0
  22. package/dist/abstractions/TextInput.web.js +1 -0
  23. package/dist/abstractions/View.js +1 -1
  24. package/dist/abstractions/helpers/componentSize.js +1 -0
  25. package/dist/abstractions/helpers/componentSize.native.js +1 -0
  26. package/dist/abstractions/helpers/transformStyle.js +1 -0
  27. package/dist/abstractions/helpers/transformStyle.native.js +1 -0
  28. package/dist/components/actions/Breadcrumb.js +1 -0
  29. package/dist/components/actions/Button.js +1 -1
  30. package/dist/components/actions/Dropdown.js +1 -0
  31. package/dist/components/actions/Link.js +1 -1
  32. package/dist/components/actions/index.js +1 -1
  33. package/dist/components/actions/menu/HorizontalMenu.js +1 -0
  34. package/dist/components/actions/menu/Menu.js +1 -0
  35. package/dist/components/actions/menu/SubmenuWrapper.js +1 -0
  36. package/dist/components/actions/menu/VerticalMenu.js +1 -0
  37. package/dist/components/animations/AnimatedView.js +1 -0
  38. package/dist/components/animations/DraggableSlideView.js +1 -0
  39. package/dist/components/animations/index.js +1 -0
  40. package/dist/components/calendar/DayPicker.js +1 -0
  41. package/dist/components/calendar/_helpers/calendarDays.js +1 -0
  42. package/dist/components/calendar/index.js +1 -0
  43. package/dist/components/feedback/index.js +1 -0
  44. package/dist/components/feedback/notifications/Notification.js +1 -0
  45. package/dist/components/feedback/notifications/NotificationsHandler.js +1 -0
  46. package/dist/components/form/Form.js +1 -1
  47. package/dist/components/form/FormGroup.js +1 -1
  48. package/dist/components/form/FormItem.js +1 -1
  49. package/dist/components/form/FormList.js +1 -1
  50. package/dist/components/form/FormWrapperComponent.js +1 -1
  51. package/dist/components/form/FormWrapperComponent.native.js +1 -1
  52. package/dist/components/form/SubmitButton.js +1 -0
  53. package/dist/components/form/index.js +1 -1
  54. package/dist/components/form/useNewForm.js +1 -0
  55. package/dist/components/form/useWatch.js +1 -0
  56. package/dist/components/helpers/LazyRender.js +1 -0
  57. package/dist/components/helpers/LazyRender.native.js +1 -0
  58. package/dist/components/helpers/Portal.js +1 -0
  59. package/dist/components/helpers/PortalHandler.js +1 -0
  60. package/dist/components/helpers/Responsive.js +1 -1
  61. package/dist/components/helpers/Separator.js +1 -1
  62. package/dist/components/helpers/VerticalView.js +1 -0
  63. package/dist/components/helpers/index.js +1 -1
  64. package/dist/components/index.js +1 -1
  65. package/dist/components/inputs/Checkbox.js +1 -0
  66. package/dist/components/inputs/InputWrapper.js +1 -0
  67. package/dist/components/inputs/Picker.js +1 -0
  68. package/dist/components/inputs/Radio.js +1 -0
  69. package/dist/components/inputs/Switch.js +1 -0
  70. package/dist/components/inputs/TextInput.js +1 -0
  71. package/dist/components/inputs/index.js +1 -0
  72. package/dist/components/layout/Layout.js +1 -0
  73. package/dist/components/layout/LayoutContent.js +1 -0
  74. package/dist/components/layout/LayoutHeader.js +1 -0
  75. package/dist/components/layout/LayoutSider.js +1 -0
  76. package/dist/components/layout/index.js +1 -0
  77. package/dist/components/presentation/Avatar.js +1 -0
  78. package/dist/components/presentation/AvatarLabel.js +1 -0
  79. package/dist/components/presentation/Badge.js +1 -0
  80. package/dist/components/presentation/ContentLabel.js +1 -1
  81. package/dist/components/presentation/IconLabel.js +1 -1
  82. package/dist/components/presentation/Image.js +1 -0
  83. package/dist/components/presentation/LabelValue.js +1 -0
  84. package/dist/components/presentation/Result.js +1 -0
  85. package/dist/components/presentation/ResultBar.js +1 -0
  86. package/dist/components/presentation/Tag.js +1 -1
  87. package/dist/components/presentation/Tooltip.js +1 -0
  88. package/dist/components/presentation/index.js +1 -1
  89. package/dist/components/state/Loading.js +1 -0
  90. package/dist/components/state/LoadingView.js +1 -0
  91. package/dist/components/state/index.js +1 -0
  92. package/dist/components/structure/Accordion.js +1 -0
  93. package/dist/components/structure/AccordionGroup.js +1 -0
  94. package/dist/components/structure/Card.js +1 -1
  95. package/dist/components/structure/Col.js +1 -0
  96. package/dist/components/structure/Row.js +1 -0
  97. package/dist/components/structure/SafeAreaView.js +1 -0
  98. package/dist/components/structure/View.js +1 -1
  99. package/dist/components/structure/index.js +1 -1
  100. package/dist/components/structure/overlay/OverlayHandler.js +1 -0
  101. package/dist/components/structure/overlay/OverlayHandler.native.js +1 -0
  102. package/dist/components/structure/overlay/OverlayWrapper.js +1 -0
  103. package/dist/components/structure/overlay/calculatePosition.js +1 -0
  104. package/dist/components/structure/overlay/smartPlacement.js +1 -0
  105. package/dist/components/structure/popover/Popover.js +1 -0
  106. package/dist/components/structure/popover/Popover.native.js +1 -0
  107. package/dist/components/structure/popover/PopoverContent.js +1 -0
  108. package/dist/components/table/DataTable.js +1 -0
  109. package/dist/components/table/Pagination.js +1 -0
  110. package/dist/components/table/Table.js +1 -0
  111. package/dist/components/table/TableCol.js +1 -0
  112. package/dist/components/table/TableHeader.js +1 -0
  113. package/dist/components/table/TableHeaderRow.js +1 -0
  114. package/dist/components/table/TableRow.js +1 -0
  115. package/dist/components/table/index.js +1 -0
  116. package/dist/components/text/Text.js +1 -1
  117. package/dist/components/text/VerticalText.js +1 -0
  118. package/dist/components/text/index.js +1 -1
  119. package/dist/helpers/debounce.js +1 -0
  120. package/dist/helpers/index.js +1 -1
  121. package/dist/helpers/options.js +1 -0
  122. package/dist/helpers/random.js +1 -0
  123. package/dist/index.css +10 -0
  124. package/dist/index.js +1 -1
  125. package/dist/modifiers/alignConverter.js +1 -0
  126. package/dist/modifiers/animation.js +1 -0
  127. package/dist/modifiers/animations/animatedEffects.js +1 -0
  128. package/dist/modifiers/animations/animatedEffects.native.js +1 -0
  129. package/dist/modifiers/animations/animatedEffects.web.js +1 -0
  130. package/dist/modifiers/animations/fadeEffect.js +1 -0
  131. package/dist/modifiers/animations/fadeEffect.native.js +1 -0
  132. package/dist/modifiers/animations/slideEffect.js +1 -0
  133. package/dist/modifiers/animations/slideEffect.native.js +1 -0
  134. package/dist/modifiers/applyStyles.js +1 -0
  135. package/dist/modifiers/border.js +1 -1
  136. package/dist/modifiers/display.js +1 -1
  137. package/dist/modifiers/flex.js +1 -1
  138. package/dist/modifiers/flexWrapper.js +1 -1
  139. package/dist/modifiers/fullColor.js +1 -1
  140. package/dist/modifiers/grid.js +1 -0
  141. package/dist/modifiers/overflow.js +1 -0
  142. package/dist/modifiers/position.js +1 -1
  143. package/dist/modifiers/responsiveConverter.js +1 -0
  144. package/dist/modifiers/size.js +1 -1
  145. package/dist/modifiers/state.js +1 -0
  146. package/dist/responsive/ResponsiveHandler.js +1 -0
  147. package/dist/responsive/index.js +1 -0
  148. package/dist/responsive/responsiveHooks.js +1 -0
  149. package/dist/theme/ThemeHandler.js +1 -1
  150. package/dist/theme/default/base.js +1 -1
  151. package/dist/theme/default/darkTheme.js +1 -1
  152. package/dist/theme/default/hackerTheme.js +1 -1
  153. package/dist/theme/default/lightTheme.js +1 -1
  154. package/dist/theme/default/msdosTheme.js +1 -1
  155. package/dist/theme/helpers/contrastColor.js +1 -0
  156. package/dist/theme/helpers/dynamicColor.js +1 -0
  157. package/dist/theme/helpers/relatedScales.js +1 -1
  158. package/dist/theme/helpers/sizeScale.js +1 -1
  159. package/dist/theme/helpers/textScale.js +1 -1
  160. package/package.json +9 -4
  161. package/src/NekoUI.js +15 -1
  162. package/src/abstractions/ActivityIndicator.js +31 -0
  163. package/src/abstractions/ActivityIndicator.native.js +44 -0
  164. package/src/abstractions/AnimatedView.js +3 -0
  165. package/src/abstractions/AnimatedView.native.js +6 -0
  166. package/src/abstractions/DraggableSlideView.js +85 -0
  167. package/src/abstractions/DraggableSlideView.native.js +62 -0
  168. package/src/abstractions/Icon.js +4 -42
  169. package/src/abstractions/Image.js +12 -0
  170. package/src/abstractions/Image.native.js +7 -0
  171. package/src/abstractions/Image.web.js +7 -0
  172. package/src/abstractions/Platform.js +1 -0
  173. package/src/abstractions/Platform.native.js +3 -0
  174. package/src/abstractions/Platform.web.js +3 -0
  175. package/src/abstractions/SafeAreaView.js +3 -0
  176. package/src/abstractions/SafeAreaView.native.js +3 -0
  177. package/src/abstractions/Table.js +29 -0
  178. package/src/abstractions/Table.native.js +19 -0
  179. package/src/abstractions/Text.js +13 -2
  180. package/src/abstractions/TextInput.js +3 -0
  181. package/src/abstractions/TextInput.native.js +5 -0
  182. package/src/abstractions/TextInput.web.js +5 -0
  183. package/src/abstractions/View.js +2 -2
  184. package/src/abstractions/helpers/componentSize.js +13 -0
  185. package/src/abstractions/helpers/componentSize.native.js +12 -0
  186. package/src/abstractions/helpers/transformStyle.js +8 -0
  187. package/src/abstractions/helpers/transformStyle.native.js +3 -0
  188. package/src/components/actions/Breadcrumb.js +47 -0
  189. package/src/components/actions/Button.js +8 -3
  190. package/src/components/actions/Dropdown.js +68 -0
  191. package/src/components/actions/Link.js +21 -8
  192. package/src/components/actions/index.js +3 -0
  193. package/src/components/actions/menu/HorizontalMenu.js +96 -0
  194. package/src/components/actions/menu/Menu.js +7 -0
  195. package/src/components/actions/menu/SubmenuWrapper.js +16 -0
  196. package/src/components/actions/menu/VerticalMenu.js +107 -0
  197. package/src/components/animations/AnimatedView.js +45 -0
  198. package/src/components/animations/DraggableSlideView.js +42 -0
  199. package/src/components/animations/index.js +2 -0
  200. package/src/components/calendar/DayPicker.js +94 -0
  201. package/src/components/calendar/_helpers/calendarDays.js +16 -0
  202. package/src/components/calendar/index.js +1 -0
  203. package/src/components/feedback/index.js +1 -0
  204. package/src/components/feedback/notifications/Notification.js +37 -0
  205. package/src/components/feedback/notifications/NotificationsHandler.js +65 -0
  206. package/src/components/form/Form.js +15 -4
  207. package/src/components/form/FormGroup.js +4 -4
  208. package/src/components/form/FormItem.js +30 -8
  209. package/src/components/form/FormList.js +45 -9
  210. package/src/components/form/FormWrapperComponent.js +37 -2
  211. package/src/components/form/FormWrapperComponent.native.js +2 -2
  212. package/src/components/form/SubmitButton.js +20 -0
  213. package/src/components/form/index.js +3 -2
  214. package/src/components/form/useNewForm.js +67 -0
  215. package/src/components/form/useWatch.js +70 -0
  216. package/src/components/helpers/LazyRender.js +55 -0
  217. package/src/components/helpers/LazyRender.native.js +58 -0
  218. package/src/components/helpers/Portal.js +21 -0
  219. package/src/components/helpers/PortalHandler.js +32 -0
  220. package/src/components/helpers/Responsive.js +1 -1
  221. package/src/components/helpers/Separator.js +10 -14
  222. package/src/components/helpers/VerticalView.js +34 -0
  223. package/src/components/helpers/index.js +4 -0
  224. package/src/components/index.js +7 -0
  225. package/src/components/inputs/Checkbox.js +56 -0
  226. package/src/components/inputs/InputWrapper.js +79 -0
  227. package/src/components/inputs/Picker.js +116 -0
  228. package/src/components/inputs/Radio.js +55 -0
  229. package/src/components/inputs/Switch.js +60 -0
  230. package/src/components/inputs/TextInput.js +22 -0
  231. package/src/components/inputs/index.js +6 -0
  232. package/src/components/layout/Layout.js +40 -0
  233. package/src/components/layout/LayoutContent.js +42 -0
  234. package/src/components/layout/LayoutHeader.js +69 -0
  235. package/src/components/layout/LayoutSider.js +64 -0
  236. package/src/components/layout/index.js +4 -0
  237. package/src/components/presentation/Avatar.js +79 -0
  238. package/src/components/presentation/AvatarLabel.js +58 -0
  239. package/src/components/presentation/Badge.js +90 -0
  240. package/src/components/presentation/ContentLabel.js +24 -6
  241. package/src/components/presentation/IconLabel.js +12 -2
  242. package/src/components/presentation/Image.js +33 -0
  243. package/src/components/presentation/LabelValue.js +49 -0
  244. package/src/components/presentation/Result.js +60 -0
  245. package/src/components/presentation/ResultBar.js +56 -0
  246. package/src/components/presentation/Tag.js +8 -11
  247. package/src/components/presentation/Tooltip.js +43 -0
  248. package/src/components/presentation/index.js +8 -0
  249. package/src/components/state/Loading.js +20 -0
  250. package/src/components/state/LoadingView.js +28 -0
  251. package/src/components/state/index.js +2 -0
  252. package/src/components/structure/Accordion.js +69 -0
  253. package/src/components/structure/AccordionGroup.js +35 -0
  254. package/src/components/structure/Card.js +4 -1
  255. package/src/components/structure/Col.js +22 -0
  256. package/src/components/structure/Row.js +42 -0
  257. package/src/components/structure/SafeAreaView.js +42 -0
  258. package/src/components/structure/View.js +9 -3
  259. package/src/components/structure/index.js +6 -0
  260. package/src/components/structure/overlay/OverlayHandler.js +70 -0
  261. package/src/components/structure/overlay/OverlayHandler.native.js +6 -0
  262. package/src/components/structure/overlay/OverlayWrapper.js +52 -0
  263. package/src/components/structure/overlay/calculatePosition.js +29 -0
  264. package/src/components/structure/overlay/smartPlacement.js +32 -0
  265. package/src/components/structure/popover/Popover.js +69 -0
  266. package/src/components/structure/popover/Popover.native.js +75 -0
  267. package/src/components/structure/popover/PopoverContent.js +18 -0
  268. package/src/components/table/DataTable.js +57 -0
  269. package/src/components/table/Pagination.js +128 -0
  270. package/src/components/table/Table.js +65 -0
  271. package/src/components/table/TableCol.js +67 -0
  272. package/src/components/table/TableHeader.js +69 -0
  273. package/src/components/table/TableHeaderRow.js +31 -0
  274. package/src/components/table/TableRow.js +30 -0
  275. package/src/components/table/index.js +7 -0
  276. package/src/components/text/Text.js +4 -0
  277. package/src/components/text/VerticalText.js +29 -0
  278. package/src/components/text/index.js +1 -0
  279. package/src/helpers/debounce.js +9 -0
  280. package/src/helpers/index.js +2 -1
  281. package/src/helpers/options.js +65 -0
  282. package/src/helpers/random.js +5 -0
  283. package/src/index.css +10 -0
  284. package/src/index.js +1 -0
  285. package/src/modifiers/alignConverter.js +11 -0
  286. package/src/modifiers/animation.js +18 -0
  287. package/src/modifiers/animations/animatedEffects.js +63 -0
  288. package/src/modifiers/animations/animatedEffects.native.js +53 -0
  289. package/src/modifiers/animations/animatedEffects.web.js +3 -0
  290. package/src/modifiers/animations/fadeEffect.js +43 -0
  291. package/src/modifiers/animations/fadeEffect.native.js +33 -0
  292. package/src/modifiers/animations/slideEffect.js +61 -0
  293. package/src/modifiers/animations/slideEffect.native.js +53 -0
  294. package/src/modifiers/applyStyles.js +7 -0
  295. package/src/modifiers/border.js +30 -6
  296. package/src/modifiers/display.js +3 -5
  297. package/src/modifiers/flex.js +1 -1
  298. package/src/modifiers/flexWrapper.js +48 -7
  299. package/src/modifiers/fullColor.js +5 -5
  300. package/src/modifiers/grid.js +27 -0
  301. package/src/modifiers/overflow.js +23 -0
  302. package/src/modifiers/position.js +10 -2
  303. package/src/modifiers/responsiveConverter.js +19 -0
  304. package/src/modifiers/size.js +10 -4
  305. package/src/modifiers/state.js +33 -0
  306. package/src/responsive/ResponsiveHandler.js +28 -0
  307. package/src/responsive/index.js +2 -0
  308. package/src/responsive/responsiveHooks.js +54 -0
  309. package/src/theme/ThemeHandler.js +1 -1
  310. package/src/theme/default/base.js +22 -22
  311. package/src/theme/default/darkTheme.js +2 -2
  312. package/src/theme/default/hackerTheme.js +8 -0
  313. package/src/theme/default/lightTheme.js +1 -1
  314. package/src/theme/default/msdosTheme.js +1 -1
  315. package/src/theme/helpers/contrastColor.js +20 -0
  316. package/src/theme/helpers/dynamicColor.js +32 -0
  317. package/src/theme/helpers/relatedScales.js +6 -6
  318. package/src/theme/helpers/sizeScale.js +7 -2
  319. package/src/theme/helpers/textScale.js +1 -1
  320. package/dist/components/form/inputs/Checkbox.js +0 -1
  321. package/dist/components/form/inputs/Radio.js +0 -1
  322. package/dist/components/form/inputs/Switch.js +0 -1
  323. package/dist/components/form/inputs/index.js +0 -1
  324. package/dist/components/form/useForm.js +0 -1
  325. package/dist/helpers/responsive.js +0 -1
  326. package/src/components/form/inputs/Checkbox.js +0 -42
  327. package/src/components/form/inputs/Radio.js +0 -42
  328. package/src/components/form/inputs/Switch.js +0 -44
  329. package/src/components/form/inputs/index.js +0 -3
  330. package/src/components/form/useForm.js +0 -65
  331. package/src/helpers/responsive.js +0 -54
  332. /package/dist/abstractions/{windowWidth.js → helpers/windowWidth.js} +0 -0
  333. /package/dist/abstractions/{windowWidth.native.js → helpers/windowWidth.native.js} +0 -0
  334. /package/dist/abstractions/{windowWidth.web.js → helpers/windowWidth.web.js} +0 -0
  335. /package/src/abstractions/{windowWidth.js → helpers/windowWidth.js} +0 -0
  336. /package/src/abstractions/{windowWidth.native.js → helpers/windowWidth.native.js} +0 -0
  337. /package/src/abstractions/{windowWidth.web.js → helpers/windowWidth.web.js} +0 -0
@@ -0,0 +1,32 @@
1
+ import React from 'react'
2
+
3
+ const PortalContext = React.createContext(null)
4
+
5
+ export const usePortal = () => React.useContext(PortalContext) || {}
6
+
7
+ export function PortalHandler({ children }) {
8
+ const [portals, setPortals] = React.useState([])
9
+
10
+ const mount = React.useCallback((key, element) => {
11
+ setPortals((prev) => [...prev, { key, element }])
12
+ }, [])
13
+
14
+ const update = React.useCallback((key, element) => {
15
+ setPortals((prev) => prev.map((p) => (p.key === key ? { ...p, element } : p)))
16
+ }, [])
17
+
18
+ const unmount = React.useCallback((key) => {
19
+ setPortals((prev) => prev.filter((p) => p.key !== key))
20
+ }, [])
21
+
22
+ const value = React.useMemo(() => ({ mount, update, unmount }), [mount, update, unmount])
23
+
24
+ return (
25
+ <PortalContext.Provider value={value}>
26
+ {children}
27
+ {portals.map((p) => (
28
+ <React.Fragment key={p.key}>{p.element}</React.Fragment>
29
+ ))}
30
+ </PortalContext.Provider>
31
+ )
32
+ }
@@ -1,4 +1,4 @@
1
- import { useResponsiveValue } from '../../helpers/responsive'
1
+ import { useResponsiveValue } from '../../responsive/responsiveHooks'
2
2
 
3
3
  export function ResponsiveRender(props) {
4
4
  const value = useResponsiveValue(props) || props.df
@@ -1,4 +1,4 @@
1
- import { pipe } from 'ramda'
1
+ import { pipe, is } from 'ramda'
2
2
 
3
3
  import { AbsView } from '../../abstractions/View'
4
4
  import { View } from '../structure/View'
@@ -11,10 +11,11 @@ import { useSizeConverter } from '../../modifiers/sizeConverter'
11
11
  import { useSizeModifier } from '../../modifiers/size'
12
12
  import { useThemeComponentModifier } from '../../modifiers/themeComponent'
13
13
 
14
- const DEFAULT_PROPS = ([{ size, sizeCode }, { withLine }]) => ({
15
- height: withLine ? 2 * size : size,
14
+ const DEFAULT_PROPS = ([{ size, sizeCode }, { line }]) => ({
15
+ height: !!line ? 2 * size : size,
16
16
  br: sizeCode,
17
17
  center: true,
18
+ fullW: true,
18
19
  })
19
20
 
20
21
  export function Separator(rootProps) {
@@ -29,21 +30,16 @@ export function Separator(rootProps) {
29
30
  useFlexWrapperModifier
30
31
  )([{}, rootProps])
31
32
 
32
- const { withLine, lineProps, lineWidth, lineHeight = 1, ...props } = formattedProps
33
+ const { line, lineProps, ...props } = formattedProps
34
+ const lineHeight = is(Number, line) ? line : 1
33
35
 
34
36
  return (
35
37
  <AbsView className="neko-separator" {...props}>
36
- {!!withLine && (
37
- <View
38
- bg={color}
39
- br={lineHeight}
40
- height={lineHeight}
41
- fullW
42
- maxWidth={lineWidth}
43
- className="neko-separator-line"
44
- {...lineProps}
45
- />
38
+ {!!line && (
39
+ <View bg={color} br={lineHeight} height={lineHeight} fullW className="neko-separator-line" {...lineProps} />
46
40
  )}
47
41
  </AbsView>
48
42
  )
49
43
  }
44
+
45
+ export const Divider = Separator
@@ -0,0 +1,34 @@
1
+ import React from 'react'
2
+
3
+ import { View } from '../structure/View'
4
+ import { formatTransform } from '../../abstractions/helpers/transformStyle'
5
+ import { getElementSize } from '../../abstractions/helpers/componentSize'
6
+
7
+ export function VerticalView({ children, invert, ...props }) {
8
+ const wrapperRef = React.useRef(null)
9
+ const [size, setSize] = React.useState({})
10
+
11
+ React.useLayoutEffect(() => {
12
+ getElementSize(wrapperRef, setSize)
13
+ }, [])
14
+
15
+ const { height, width } = size
16
+
17
+ return (
18
+ <View width="100%" height="100%" {...props} relative ref={wrapperRef}>
19
+ <View
20
+ style={{
21
+ position: 'absolute',
22
+ width: height,
23
+ height: width,
24
+ transform: formatTransform([{ rotate: !!invert ? '90deg' : '-90deg' }]),
25
+ left: width / 2 - height / 2,
26
+ top: '50%',
27
+ marginTop: -width / 2,
28
+ }}
29
+ >
30
+ {children}
31
+ </View>
32
+ </View>
33
+ )
34
+ }
@@ -1,2 +1,6 @@
1
1
  export * from './Separator'
2
2
  export * from './Responsive'
3
+ export * from './VerticalView'
4
+ export * from './PortalHandler'
5
+ export * from './Portal'
6
+ export * from './LazyRender'
@@ -1,6 +1,13 @@
1
1
  export * from './actions'
2
+ export * from './animations'
2
3
  export * from './form'
3
4
  export * from './presentation'
4
5
  export * from './structure'
5
6
  export * from './text'
6
7
  export * from './helpers'
8
+ export * from './inputs'
9
+ export * from './state'
10
+ export * from './layout'
11
+ export * from './table'
12
+ export * from './feedback'
13
+ export * from './calendar'
@@ -0,0 +1,56 @@
1
+ import { pipe } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { AbsHiddenInput } from '../../abstractions/HiddenInput'
5
+ import { ContentLabel } from '../presentation/ContentLabel'
6
+ import { Link } from '../actions/Link'
7
+ import { Picker } from './Picker'
8
+ import { View } from '../structure/View'
9
+ import { useColorConverter } from '../../modifiers/colorConverter'
10
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
11
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
12
+
13
+ export function Checkbox({ value, onChange, disabled, initialValue, ...rootProps }) {
14
+ const [{ size, sizeCode, color }, props] = pipe(
15
+ useColorConverter('primary'),
16
+ useSizeConverter('elementHeights', 'md'),
17
+ useThemeComponentModifier('Checkbox') //
18
+ )([{}, rootProps])
19
+
20
+ const [localValue, setLocalValue] = React.useState(initialValue)
21
+ value = value === undefined ? localValue : value
22
+
23
+ const toggle = () => {
24
+ if (!!disabled) return
25
+ setLocalValue(!value)
26
+ onChange?.(!value)
27
+ }
28
+
29
+ return (
30
+ <Link onPress={toggle} className="neko-checkbox" disabled={disabled}>
31
+ <AbsHiddenInput checked={value} onChange={toggle} type="checkbox" disabled={disabled} />
32
+ <ContentLabel
33
+ size={sizeCode}
34
+ gap={8}
35
+ content={
36
+ <View height={size * 0.65} ratio={1} border={2} padding={2} borderColor={color} br={3} center>
37
+ {!!value && <View bg={color} br={2} flex fullW fullH />}
38
+ </View>
39
+ }
40
+ {...props}
41
+ />
42
+ </Link>
43
+ )
44
+ }
45
+
46
+ export function CheckboxGroup({ checkboxProps, ...props }) {
47
+ return (
48
+ <Picker
49
+ {...props}
50
+ multiple
51
+ renderOption={({ option, selected, onChange, labelKey, ...props }) => (
52
+ <Checkbox label={option[labelKey]} value={selected} onChange={onChange} {...props} {...checkboxProps} />
53
+ )}
54
+ />
55
+ )
56
+ }
@@ -0,0 +1,79 @@
1
+ import { pipe, is } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { Icon } from '../presentation/Icon'
5
+ import { Loading } from '../state/Loading'
6
+ import { Text } from '../text/Text'
7
+ import { View } from '../structure/View'
8
+ import { useDefaultModifier } from '../../modifiers/default'
9
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
10
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
11
+
12
+ const DEFAULT_PROPS = {
13
+ fullW: '100%', //
14
+ paddingH: 'sm',
15
+ bg: 'overlayBG',
16
+ border: true,
17
+ br: 'md',
18
+ row: true,
19
+ gap: 'sm',
20
+ }
21
+
22
+ export function InputWrapper({ prefix, suffix, prefixIcon, suffixIcon, loading, error, children, ...rootProps }) {
23
+ const [hover, setHover] = React.useState(false)
24
+ const inputRef = React.useRef()
25
+ const [{ size, sizeCode, onChange }, props] = pipe(
26
+ useSizeConverter('elementHeights', 'md'),
27
+ useThemeComponentModifier('InputWrapper'),
28
+ useDefaultModifier(DEFAULT_PROPS)
29
+ )([{}, rootProps])
30
+
31
+ const handlePress = () => {
32
+ inputRef?.current?.focus?.()
33
+ }
34
+
35
+ if (!!prefix && is(String, prefix)) prefix = <Text>{prefix}</Text>
36
+ if (!!suffix && is(String, suffix)) suffix = <Text>{suffix}</Text>
37
+ if (!prefix && !!prefixIcon) prefix = <Icon name={prefixIcon} size={sizeCode} />
38
+ if (!suffix && !!suffixIcon) suffix = <Icon name={suffixIcon} size={sizeCode} />
39
+ if (!prefix && !!error) suffix = <Icon name="close-circle-fill" size={sizeCode} red />
40
+ if (!!loading) suffix = <Loading size={sizeCode} />
41
+
42
+ let borderColor = !!hover ? 'primary_op40' : 'divider'
43
+ if (!!error) borderColor = 'red_op40'
44
+
45
+ const child = React.Children.only(children)
46
+ const childWithProps = React.cloneElement(child, {
47
+ ...child.props,
48
+ ref: inputRef,
49
+ onChange: child.props.onChange || onChange,
50
+ })
51
+
52
+ return (
53
+ <View
54
+ className="neko-input-wrapper"
55
+ height={size}
56
+ onPress={handlePress}
57
+ borderColor={borderColor}
58
+ onMouseEnter={() => setHover(true)}
59
+ onMouseLeave={() => setHover(false)}
60
+ {...props}
61
+ >
62
+ {!!prefix && (
63
+ <View paddingV={5} fullHeight center>
64
+ {prefix}
65
+ </View>
66
+ )}
67
+
68
+ <View flex fullH>
69
+ {childWithProps}
70
+ </View>
71
+
72
+ {!!suffix && (
73
+ <View paddingV={5} fullHeight center>
74
+ {suffix}
75
+ </View>
76
+ )}
77
+ </View>
78
+ )
79
+ }
@@ -0,0 +1,116 @@
1
+ import React from 'react'
2
+
3
+ import { Col } from '../structure/Col'
4
+ import { LoadingView } from '../state/LoadingView'
5
+ import { Row } from '../structure/Row'
6
+ import { useOptions } from '../../helpers/options'
7
+
8
+ function isSelected(value, option, config = {}) {
9
+ return !!config.multiple
10
+ ? value?.some?.((item) => compareOptionsValues(item, option, config))
11
+ : compareOptionsValues(value, option, config)
12
+ }
13
+
14
+ function compareOptionsValues(optionA, optionB, config = {}) {
15
+ const valueKey = config.valueKey || 'value'
16
+ const valueA = optionA?.[valueKey] || optionA
17
+ const valueB = optionB?.[valueKey] || optionB
18
+
19
+ if (!valueA || !valueB) return false
20
+
21
+ return valueA === valueB
22
+ }
23
+
24
+ function formatSingleChangeValue(option, value, { useRawOption, selected, valueKey }) {
25
+ let selectedOption = option
26
+ let selectedValue = option[valueKey]
27
+ if (!!useRawOption) selectedValue = option
28
+ if (selected) {
29
+ selectedOption = null
30
+ selectedValue = null
31
+ }
32
+
33
+ return selectedValue
34
+ }
35
+
36
+ function formatMultipleChangeValue(option, value, { useRawOption, selected, multiple, valueKey }) {
37
+ let selectedOption = option
38
+ let selectedValue = option[valueKey]
39
+ value = [...(value || [])]
40
+ if (!!useRawOption) selectedValue = option
41
+ if (selected) {
42
+ value = value.filter((item) => !isSelected(item, selectedOption, { multiple, valueKey }))
43
+ } else {
44
+ value.push(selectedValue)
45
+ }
46
+
47
+ return value
48
+ }
49
+
50
+ function PickerItem({ option, onChange, value, renderOption, useRawOption, multiple, labelKey, valueKey, ...props }) {
51
+ const selected = isSelected(value, option, { multiple, valueKey })
52
+
53
+ const handleChange = () => {
54
+ const formatChangeValueFunc = multiple ? formatMultipleChangeValue : formatSingleChangeValue
55
+ const formattedValue = formatChangeValueFunc(option, value, { selected, useRawOption, valueKey })
56
+ onChange(formattedValue)
57
+ }
58
+
59
+ return <Col {...props}>{renderOption({ option, selected, onChange: handleChange, valueKey, labelKey })}</Col>
60
+ }
61
+
62
+ export function Picker({
63
+ value,
64
+ initialValue,
65
+ onChange,
66
+ disabled,
67
+ options,
68
+ renderOption,
69
+ colProps,
70
+ useRawOption,
71
+ multiple,
72
+ valueKey,
73
+ labelKey,
74
+ ...rootProps
75
+ }) {
76
+ const [localValue, setLocalValue] = React.useState(initialValue)
77
+ value = value === undefined ? localValue : value
78
+ onChange = onChange || setLocalValue
79
+
80
+ const handleChange = (v) => {
81
+ if (!!disabled) return
82
+ setLocalValue(v)
83
+ onChange?.(v)
84
+ }
85
+
86
+ const { options: finalOptions, isFirstLoad } = useOptions(options, {})
87
+
88
+ valueKey = valueKey || 'value'
89
+ labelKey = labelKey || 'label'
90
+
91
+ if (!renderOption) {
92
+ console.error('Picker requires a renderOption prop')
93
+ return false
94
+ }
95
+
96
+ return (
97
+ <LoadingView active={isFirstLoad} replaceChildren>
98
+ <Row className="neko-picker" gap="md" {...rootProps}>
99
+ {finalOptions?.map?.((option) => (
100
+ <PickerItem
101
+ key={option.value}
102
+ option={option}
103
+ onChange={handleChange}
104
+ value={value}
105
+ renderOption={renderOption}
106
+ useRawOption={useRawOption}
107
+ multiple={multiple}
108
+ valueKey={valueKey}
109
+ labelKey={labelKey}
110
+ {...colProps}
111
+ />
112
+ ))}
113
+ </Row>
114
+ </LoadingView>
115
+ )
116
+ }
@@ -0,0 +1,55 @@
1
+ import { pipe } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { AbsHiddenInput } from '../../abstractions/HiddenInput'
5
+ import { ContentLabel } from '../presentation/ContentLabel'
6
+ import { Link } from '../actions/Link'
7
+ import { Picker } from './Picker'
8
+ import { View } from '../structure/View'
9
+ import { useColorConverter } from '../../modifiers/colorConverter'
10
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
11
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
12
+
13
+ export function Radio({ value, onChange, disabled, initialValue, ...rootProps }) {
14
+ const [{ size, sizeCode, color }, props] = pipe(
15
+ useColorConverter('primary'),
16
+ useSizeConverter('elementHeights', 'md'),
17
+ useThemeComponentModifier('Radio') //
18
+ )([{}, rootProps])
19
+
20
+ const [localValue, setLocalValue] = React.useState(initialValue)
21
+ value = value === undefined ? localValue : value
22
+
23
+ const toggle = () => {
24
+ if (!!disabled) return
25
+ setLocalValue(!value)
26
+ onChange?.(!value)
27
+ }
28
+
29
+ return (
30
+ <Link onPress={toggle} className="neko-radio" disabled={disabled}>
31
+ <AbsHiddenInput checked={value} onChange={toggle} type="radio" disabled={disabled} />
32
+ <ContentLabel
33
+ size={sizeCode}
34
+ gap={8}
35
+ content={
36
+ <View height={size * 0.65} ratio={1} border={2} padding={3} borderColor={color} br={size} center>
37
+ {!!value && <View bg={color} br={size} flex fullW fullH />}
38
+ </View>
39
+ }
40
+ {...props}
41
+ />
42
+ </Link>
43
+ )
44
+ }
45
+
46
+ export function RadioGroup({ radioProps, ...props }) {
47
+ return (
48
+ <Picker
49
+ {...props}
50
+ renderOption={({ option, selected, onChange, labelKey, ...props }) => (
51
+ <Radio label={option[labelKey]} value={selected} onChange={onChange} {...props} {...radioProps} />
52
+ )}
53
+ />
54
+ )
55
+ }
@@ -0,0 +1,60 @@
1
+ import { pipe } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { AbsSwitch } from '../../abstractions/Switch'
5
+ import { ContentLabel } from '../presentation/ContentLabel'
6
+ import { Picker } from './Picker'
7
+ import { useColorConverter } from '../../modifiers/colorConverter'
8
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
9
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
10
+
11
+ export function Switch({ value, onChange, disabled, initialValue, ...rootProps }) {
12
+ const [{ size, sizeCode, color }, props] = pipe(
13
+ useColorConverter('primary'),
14
+ useSizeConverter('elementHeights', 'md'),
15
+ useThemeComponentModifier('Switch') //
16
+ )([{}, rootProps])
17
+
18
+ const [localValue, setLocalValue] = React.useState(initialValue)
19
+ value = value === undefined ? localValue : value
20
+ onChange = onChange || setLocalValue
21
+
22
+ const toggle = () => {
23
+ if (!!disabled) return
24
+ setLocalValue(!value)
25
+ onChange?.(!value)
26
+ }
27
+
28
+ return (
29
+ <ContentLabel
30
+ className="neko-checkbox"
31
+ size={sizeCode}
32
+ gap={8}
33
+ disabled={disabled}
34
+ content={
35
+ <AbsSwitch
36
+ color={color}
37
+ value={value}
38
+ onValueChange={toggle}
39
+ trackColor={{ true: color }}
40
+ disabled={disabled}
41
+ height={size * 0.75}
42
+ />
43
+ }
44
+ {...props}
45
+ />
46
+ )
47
+ }
48
+
49
+ export function SwitchGroup({ switchProps, ...props }) {
50
+ return (
51
+ <Picker
52
+ multiple
53
+ row={false}
54
+ {...props}
55
+ renderOption={({ option, selected, onChange, labelKey, ...props }) => (
56
+ <Switch label={option[labelKey]} value={selected} onChange={onChange} {...props} {...switchProps} />
57
+ )}
58
+ />
59
+ )
60
+ }
@@ -0,0 +1,22 @@
1
+ import { AbsTextInput } from '../../abstractions/TextInput'
2
+ import { InputWrapper } from './InputWrapper'
3
+ import { useColors } from '../../theme/ThemeHandler'
4
+
5
+ export function TextInput({ value, ...props }) {
6
+ const colors = useColors()
7
+
8
+ const STYLE = {
9
+ width: '100%',
10
+ height: '100%',
11
+ borderWidth: 0,
12
+ background: 'transparent',
13
+ outline: 'none',
14
+ color: colors.text,
15
+ }
16
+
17
+ return (
18
+ <InputWrapper {...props}>
19
+ <AbsTextInput style={STYLE} placeholderTextColor={colors.text_op30} {...props} value={value} />
20
+ </InputWrapper>
21
+ )
22
+ }
@@ -0,0 +1,6 @@
1
+ export * from './Checkbox'
2
+ export * from './Radio'
3
+ export * from './Switch'
4
+ export * from './InputWrapper'
5
+ export * from './TextInput'
6
+ export * from './Picker'
@@ -0,0 +1,40 @@
1
+ import React from 'react'
2
+
3
+ import { View } from '../structure/View'
4
+ import { getElementSize } from '../../abstractions/helpers/componentSize'
5
+
6
+ const LayoutContext = React.createContext({})
7
+ export const useLayout = () => React.useContext(LayoutContext) || {}
8
+
9
+ export function Layout({ children, ...rootProps }) {
10
+ const [layoutHeaderSpace, setLayoutHeaderSpace] = React.useState(0)
11
+ const [layoutSiderSpace, setLayoutSiderSpace] = React.useState(0)
12
+
13
+ const registerHeader = (space) => setLayoutHeaderSpace((v) => v + space)
14
+ const unregisterHeader = (space) => setLayoutHeaderSpace((v) => v - space)
15
+
16
+ const [layoutSize, setLayoutSize] = React.useState({})
17
+ const layoutRef = React.useRef(null)
18
+
19
+ React.useLayoutEffect(() => {
20
+ getElementSize(layoutRef, setLayoutSize)
21
+ }, [])
22
+
23
+ const value = {
24
+ layoutSize,
25
+ layoutHeaderSpace,
26
+ setLayoutHeaderSpace,
27
+ layoutSiderSpace,
28
+ layoutSiderSpace,
29
+ registerHeader,
30
+ unregisterHeader,
31
+ }
32
+
33
+ return (
34
+ <LayoutContext.Provider value={value}>
35
+ <View className="neko-layout" bg="bg" flex relative {...rootProps} ref={layoutRef}>
36
+ {children}
37
+ </View>
38
+ </LayoutContext.Provider>
39
+ )
40
+ }
@@ -0,0 +1,42 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsView } from '../../abstractions/View'
4
+ import { useBackgroundModifier } from '../../modifiers/background'
5
+ import { useBorderModifier } from '../../modifiers/border'
6
+ import { useDefaultModifier } from '../../modifiers/default'
7
+ import { useFlexModifier } from '../../modifiers/flex'
8
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
9
+ import { useMarginModifier } from '../../modifiers/margin'
10
+ import { useOverflowModifier } from '../../modifiers/overflow'
11
+ import { usePaddingModifier } from '../../modifiers/padding'
12
+ import { usePositionModifier } from '../../modifiers/position'
13
+ import { useSizeModifier } from '../../modifiers/size'
14
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
15
+
16
+ const DEFAULT_PROPS = {
17
+ // flex: 1,
18
+ }
19
+
20
+ export function LayoutContent({ children, ...rootProps }) {
21
+ const [_, props] = pipe(
22
+ useThemeComponentModifier('LayoutContent'),
23
+ useDefaultModifier(DEFAULT_PROPS),
24
+ useSizeModifier, //
25
+ usePositionModifier,
26
+ useOverflowModifier,
27
+ usePaddingModifier,
28
+ useMarginModifier,
29
+ useFlexWrapperModifier,
30
+ useFlexModifier,
31
+ useBackgroundModifier,
32
+ useBorderModifier
33
+ )([{}, rootProps])
34
+
35
+ return (
36
+ <>
37
+ <AbsView className="neko-layout-content" {...props}>
38
+ {children}
39
+ </AbsView>
40
+ </>
41
+ )
42
+ }