@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,23 @@
1
+ import { clearProps } from './_helpers'
2
+
3
+ export function useOverflowModifier([values, props]) {
4
+ let { hiddenOverflow, scroll, scrollY, scrollX, overflow, overflowY, overflowX, ...restProps } = props
5
+
6
+ if (hiddenOverflow) overflow = 'hidden'
7
+ if (scroll) overflow = 'scroll'
8
+ if (scrollY) overflowY = 'scroll'
9
+ if (scrollX) overflowX = 'scroll'
10
+
11
+ const style = clearProps({ overflow, overflowY, overflowX })
12
+
13
+ return [
14
+ values,
15
+ {
16
+ ...restProps,
17
+ style: {
18
+ ...props.style,
19
+ ...style,
20
+ },
21
+ },
22
+ ]
23
+ }
@@ -1,12 +1,20 @@
1
+ import { Platform } from '../abstractions/Platform'
1
2
  import { clearProps } from './_helpers'
2
3
 
3
4
  export function usePositionModifier([values, props]) {
4
- let { position, absolute, relative, top, bottom, left, right, ...restProps } = props
5
+ let { position, absolute, relative, fixed, sticky, top, bottom, left, right, zIndex, ...restProps } = props
5
6
 
7
+ if (!zIndex && !!absolute) zIndex = 10
6
8
  if (absolute) position = 'absolute'
7
9
  if (relative) position = 'relative'
10
+ if (fixed) position = 'fixed'
11
+ if (sticky) position = 'sticky'
8
12
 
9
- const style = clearProps({ position, top, bottom, left, right })
13
+ if (Platform.OS !== 'web' && ['fixed', 'sticky'].includes(position)) {
14
+ position = 'absolute'
15
+ }
16
+
17
+ const style = clearProps({ position, top, bottom, left, right, zIndex })
10
18
 
11
19
  return [
12
20
  values,
@@ -0,0 +1,19 @@
1
+ import { curry } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { useGetResponsiveValue } from '../responsive/responsiveHooks'
5
+
6
+ export const useResponsiveConverter = curry(function (keys, [values, props]) {
7
+ const getValue = useGetResponsiveValue()
8
+
9
+ return React.useMemo(() => {
10
+ const formattedProps = Object.keys(props).reduce((acc, k) => {
11
+ let v = props[k]
12
+ if (!keys?.length || keys.includes(k)) v = getValue(v)
13
+ acc[k] = v
14
+ return acc
15
+ }, {})
16
+
17
+ return [values, formattedProps]
18
+ }, [getValue])
19
+ })
@@ -20,16 +20,22 @@ export function useSizeModifier([values, props]) {
20
20
  fullH,
21
21
  ratio,
22
22
  square,
23
+ span,
24
+ parentSpan,
23
25
  ...restProps
24
26
  } = props || {}
25
27
 
26
28
  minHeight = getHeight(minHeight || minH)
27
- minWidth = minWidth || minW
29
+ minWidth = getHeight(minWidth || minW)
28
30
 
29
- maxHeight = maxHeight || maxH
30
- maxWidth = maxWidth || maxW
31
+ maxHeight = getHeight(maxHeight || maxH)
32
+ maxWidth = getHeight(maxWidth || maxW)
31
33
 
32
34
  height = getHeight(height)
35
+ width = getHeight(width)
36
+
37
+ span = span ?? parentSpan
38
+ if (span) width = (span / 24) * 100 + '%'
33
39
 
34
40
  if (fullWidth || fullW) width = '100%'
35
41
  if (fullHeight || fullH) height = '100%'
@@ -37,7 +43,7 @@ export function useSizeModifier([values, props]) {
37
43
  let aspectRatio = ratio
38
44
  if (!!square) aspectRatio = 1
39
45
 
40
- const style = clearProps({ height, width, minHeight, minHeight, maxHeight, maxWidth, aspectRatio })
46
+ const style = clearProps({ height, width, minHeight, minHeight, maxHeight, minWidth, maxWidth, aspectRatio })
41
47
 
42
48
  return [
43
49
  values,
@@ -0,0 +1,33 @@
1
+ import { clearProps } from './_helpers'
2
+
3
+ export function useStateModifier([values, props]) {
4
+ let { disabled, loading, onClick, onPress, onChange, ...restProps } = props
5
+
6
+ let cursor = props.style
7
+ let opacity = props.opacity
8
+
9
+ if (!!disabled) {
10
+ opacity = 0.3
11
+ onChange = undefined
12
+ cursor = 'not-allowed'
13
+ }
14
+ if (!!disabled || !!loading) {
15
+ onPress = undefined
16
+ onClick = undefined
17
+ }
18
+
19
+ const style = clearProps({ opacity, cursor })
20
+ const newProps = clearProps({ onPress, onClick, onChange })
21
+
22
+ return [
23
+ { disabled, loading, ...values },
24
+ {
25
+ ...newProps,
26
+ ...restProps,
27
+ style: {
28
+ ...props.style,
29
+ ...style,
30
+ },
31
+ },
32
+ ]
33
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react'
2
+
3
+ import { useBreakpoints } from '../theme/ThemeHandler'
4
+ import { useWindowWidth } from '../abstractions/helpers/windowWidth'
5
+
6
+ const ResponsiveContext = React.createContext(null)
7
+
8
+ export const useResponsive = () => React.useContext(ResponsiveContext)
9
+
10
+ export function ResponsiveHandler({ children }) {
11
+ const width = useWindowWidth()
12
+
13
+ const breakpoints = useBreakpoints()
14
+
15
+ const screen = React.useMemo(() => {
16
+ if (!breakpoints?.length) return false
17
+ for (let i = 0; i < breakpoints.length; i++) {
18
+ if (width < breakpoints[i].value) {
19
+ return breakpoints[i].name
20
+ }
21
+ }
22
+ return breakpoints[breakpoints.length - 1]?.name
23
+ }, [width, breakpoints])
24
+
25
+ const value = React.useMemo(() => ({ width, screen }), [width, screen])
26
+
27
+ return <ResponsiveContext.Provider value={value}>{children}</ResponsiveContext.Provider>
28
+ }
@@ -0,0 +1,2 @@
1
+ export * from './responsiveHooks'
2
+ export * from './ResponsiveHandler'
@@ -0,0 +1,54 @@
1
+ import { is } from 'ramda'
2
+ import React from 'react'
3
+
4
+ import { useBreakpoints } from '../theme/ThemeHandler'
5
+ import { useResponsive } from '../responsive/ResponsiveHandler'
6
+
7
+ export function useGetResponsiveValue() {
8
+ const breakpoints = useBreakpoints()
9
+ const { width, screen } = useResponsive()
10
+
11
+ return React.useCallback(
12
+ (value) => {
13
+ const isObj = is(Object, value)
14
+
15
+ if (!isObj) return value
16
+
17
+ if (value[screen]) return value[screen]
18
+
19
+ const keys = Object.keys(value)
20
+ for (let k of keys) {
21
+ const match = k.match(/^(\w+)([du])$/)
22
+ if (!match) continue
23
+
24
+ const bpName = match[1]
25
+ const mode = match[2]
26
+
27
+ const bpIndex = breakpoints.findIndex((b) => b.name === bpName)
28
+ if (bpIndex === -1) continue
29
+
30
+ // For "up", use the lower boundary of the range (previous breakpoint value)
31
+ // For "down", use the upper boundary of the range (current breakpoint value)
32
+ if (mode === 'u') {
33
+ const lowerBound = bpIndex > 0 ? breakpoints[bpIndex - 1].value : 0
34
+ if (width >= lowerBound) return value[k]
35
+ }
36
+ if (mode === 'd') {
37
+ if (width < breakpoints[bpIndex].value) return value[k]
38
+ }
39
+ }
40
+
41
+ return value?.df
42
+ },
43
+ [screen]
44
+ )
45
+ }
46
+
47
+ export function useResponsiveValue(value) {
48
+ const getValue = useGetResponsiveValue()
49
+
50
+ const isObj = is(Object, value)
51
+ const valueWatch = isObj ? Object.keys(value).map((k) => `${k}:${value[k]}`) : [value]
52
+
53
+ return React.useMemo(() => getValue(value), [getValue, ...valueWatch])
54
+ }
@@ -9,7 +9,7 @@ const DEFAULT_BREAKPOINTS = [
9
9
  { name: 'sm', value: 768 },
10
10
  { name: 'md', value: 1024 },
11
11
  { name: 'lg', value: 1440 },
12
- { name: 'xlg', value: 10000 },
12
+ { name: 'xl', value: 10000 },
13
13
  ]
14
14
 
15
15
  const ThemeContext = React.createContext(null)
@@ -1,47 +1,47 @@
1
1
  export const BASE_THEME = {
2
2
  spaces: {
3
- xxxsm: 1,
4
- xxsm: 3,
5
- xsm: 5,
3
+ xxxs: 1,
4
+ xxs: 3,
5
+ xs: 5,
6
6
  sm: 10,
7
7
  md: 15,
8
8
  lg: 20,
9
- xlg: 30,
10
- xxlg: 40,
11
- xxxlg: 50,
9
+ xl: 30,
10
+ xxl: 40,
11
+ xxxl: 50,
12
12
  },
13
13
 
14
14
  radius: {
15
- xxxsm: 4,
16
- xxsm: 5,
17
- xsm: 5,
15
+ xxxs: 4,
16
+ xxs: 5,
17
+ xs: 5,
18
18
  sm: 7,
19
19
  md: 8,
20
20
  lg: 10,
21
- xlg: 12,
22
- xxlg: 15,
23
- xxxlg: 18,
21
+ xl: 12,
22
+ xxl: 15,
23
+ xxxl: 18,
24
24
  },
25
25
 
26
26
  icons: {
27
- xxxsm: 10,
28
- xxsm: 12,
29
- xsm: 14,
27
+ xxxs: 10,
28
+ xxs: 12,
29
+ xs: 14,
30
30
  sm: 16,
31
31
  md: 18,
32
32
  lg: 22,
33
- xlg: 26,
34
- xxlg: 28,
35
- xxxlg: 32,
33
+ xl: 26,
34
+ xxl: 28,
35
+ xxxl: 32,
36
36
  },
37
37
 
38
38
  // Buttons, inputs, etc.
39
39
  elementHeights: {
40
- xsm: 20,
40
+ xs: 20,
41
41
  sm: 30,
42
42
  md: 35,
43
43
  lg: 50,
44
- xlg: 60,
44
+ xl: 60,
45
45
  },
46
46
 
47
47
  texts: {
@@ -71,7 +71,7 @@ export const BASE_THEME = {
71
71
  },
72
72
  p: { fontSize: 14 },
73
73
  sm: { fontSize: 12 },
74
- xsm: { fontSize: 10 },
75
- xxsm: { fontSize: 8 },
74
+ xs: { fontSize: 10 },
75
+ xxs: { fontSize: 8 },
76
76
  },
77
77
  }
@@ -11,8 +11,8 @@ export const DEFAULT_DARK_THEME = mergeDeepRight(BASE_THEME, {
11
11
 
12
12
  bg: '#383E44',
13
13
  overlayBG: '#272D34',
14
- shadow: 'rgba(39, 45, 52, 0.6)',
15
- divider: 'rgba(255,255,255, 0.2)',
14
+ shadow: 'rgba(216, 210, 203, 0.1)',
15
+ divider: '#383E44',
16
16
 
17
17
  blue: '#4DA3FF',
18
18
  yellow: '#FFD93B',
@@ -29,4 +29,12 @@ export const DEFAULT_MATRIX_THEME = mergeDeepRight(BASE_THEME, {
29
29
  lylac: '#8E24AA',
30
30
  pink: '#C51162',
31
31
  },
32
+
33
+ components: {
34
+ Card: {
35
+ border: 1,
36
+ br: 5,
37
+ borderColor: 'divider',
38
+ },
39
+ },
32
40
  })
@@ -12,7 +12,7 @@ export const DEFAULT_LIGHT_THEME = mergeDeepRight(BASE_THEME, {
12
12
  bg: '#F4F5FE',
13
13
  overlayBG: '#FFFFFF',
14
14
  shadow: 'rgba(39, 45, 52, 0.15)',
15
- divider: 'rgba(0,0,0, 0.1)',
15
+ divider: '#e0e0e0',
16
16
 
17
17
  blue: '#4DA3FF',
18
18
  yellow: '#FFD93B',
@@ -32,7 +32,7 @@ export const DEFAULT_MSDOS_THEME = mergeDeepRight(BASE_THEME, {
32
32
 
33
33
  components: {
34
34
  Card: {
35
- borderWidth: 1,
35
+ border: 1,
36
36
  br: 5,
37
37
  borderColor: 'divider',
38
38
  },
@@ -0,0 +1,20 @@
1
+ import tinycolor from 'tinycolor2'
2
+
3
+ export function getContrastColor(bg, options = ['#FFFFFF', '#666666'], tolerance = 2.5) {
4
+ if (!options.length) return '#666666'
5
+
6
+ return tinycolor.mostReadable(bg, options).toHexString()
7
+
8
+ // const contrasts = options.map((color) => ({
9
+ // color,
10
+ // contrast: tinycolor.readability(bg, color),
11
+ // }))
12
+
13
+ // contrasts.sort((a, b) => b.contrast - a.contrast)
14
+
15
+ // if (contrasts.length > 1 && Math.abs(contrasts[0].contrast - contrasts[1].contrast) < tolerance) {
16
+ // return options[0]
17
+ // }
18
+
19
+ // return contrasts[0].color
20
+ }
@@ -0,0 +1,32 @@
1
+ const BASE_COLORS = [
2
+ 'text3',
3
+ 'blue',
4
+ 'yellow',
5
+ 'green',
6
+ 'purple',
7
+ 'orange',
8
+ 'cyan',
9
+ 'red',
10
+ 'navy',
11
+ 'indigo',
12
+ 'gray',
13
+ 'brown',
14
+ 'lylac',
15
+ 'pink',
16
+ ]
17
+
18
+ const COLORS = [...BASE_COLORS, ...BASE_COLORS.map((c) => `${c}+10`), ...BASE_COLORS.map((c) => `${c}-10`)]
19
+
20
+ export function getDynamicColor(id) {
21
+ let num
22
+ if (typeof id === 'number') {
23
+ num = id
24
+ } else {
25
+ num = String(id)
26
+ .split('')
27
+ .reduce((acc, char) => acc + char.charCodeAt(0), 0)
28
+ }
29
+
30
+ const index = num % COLORS.length
31
+ return COLORS[index]
32
+ }
@@ -1,15 +1,15 @@
1
1
  import { is } from 'ramda'
2
2
 
3
3
  const SCALES = [
4
- ['xxxsm'],
5
- ['xxsm'],
6
- ['xsm'],
4
+ ['xxxs'],
5
+ ['xxs'],
6
+ ['xs'],
7
7
  ['sm', 'small'],
8
8
  ['md', 'p'],
9
9
  ['lg', 'h6'],
10
- ['xlg', 'h5'],
11
- ['xxlg', 'h4'],
12
- ['xxxlg', 'h3'],
10
+ ['xl', 'h5'],
11
+ ['xxl', 'h4'],
12
+ ['xxxl', 'h3'],
13
13
  ]
14
14
 
15
15
  export function getScaleSynonyms(key) {
@@ -1,11 +1,16 @@
1
1
  import { omit } from 'ramda'
2
2
 
3
- const SCALE = ['xxxsm', 'xxsm', 'xsm', 'sm', 'md', 'lg', 'xlg', 'xxlg', 'xxxlg']
3
+ const SCALE = ['xxxs', 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl']
4
4
 
5
5
  export function moveScale(value, unit = 1) {
6
6
  const index = SCALE.indexOf(value)
7
7
  if (!index) return value
8
- return SCALE[index + unit] || value
8
+ const movedIndex = index + unit
9
+ let movedValue = SCALE[index + unit]
10
+ if (!movedValue) {
11
+ movedValue = unit > 0 ? 'xxxl' : 'xxxs'
12
+ }
13
+ return movedValue
9
14
  }
10
15
 
11
16
  export function getSizeFromProps({ size, ...props }, defaultValue) {
@@ -1,6 +1,6 @@
1
1
  import { omit } from 'ramda'
2
2
 
3
- const SCALE = ['xxxsm', 'xxsm', 'xsm', 'sm', 'p', 'h6', 'h5', 'h4', 'h3', 'h2', 'h1']
3
+ const SCALE = ['xxxs', 'xxs', 'xs', 'sm', 'p', 'h6', 'h5', 'h4', 'h3', 'h2', 'h1']
4
4
 
5
5
  export function moveTextScale(value, unit = 1) {
6
6
  const index = SCALE.indexOf(value)
@@ -1 +0,0 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _jsxFileName="/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/form/inputs/Checkbox.js";var _excluded=["value","onChange","disabled"];import{pipe}from'ramda';import React from'react';import{AbsHiddenInput}from"../../../abstractions/HiddenInput";import{ContentLabel}from"../../presentation/ContentLabel";import{Link}from"../../actions/Link";import{View}from"../../structure/View";import{useColorConverter}from"../../../modifiers/colorConverter";import{useSizeConverter}from"../../../modifiers/sizeConverter";import{useThemeComponentModifier}from"../../../modifiers/themeComponent";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function Checkbox(_ref){var value=_ref.value,onChange=_ref.onChange,disabled=_ref.disabled,rootProps=_objectWithoutProperties(_ref,_excluded);var _pipe=pipe(useColorConverter('primary'),useSizeConverter('elementHeights','md'),useThemeComponentModifier('Checkbox'))([{},rootProps]),_pipe2=_slicedToArray(_pipe,2),_pipe2$=_pipe2[0],size=_pipe2$.size,sizeCode=_pipe2$.sizeCode,color=_pipe2$.color,props=_pipe2[1];var _React$useState=React.useState(value),_React$useState2=_slicedToArray(_React$useState,2),checked=_React$useState2[0],setChecked=_React$useState2[1];var toggle=function toggle(){if(!!disabled)return;setChecked(!checked);if(onChange)onChange(!checked);};return _jsxs(Link,{onPress:toggle,className:"neko-checkbox",disabled:disabled,children:[_jsx(AbsHiddenInput,{checked:checked,onChange:toggle,type:"checkbox",disabled:disabled}),_jsx(ContentLabel,Object.assign({size:sizeCode,gap:8,content:_jsx(View,{height:size*0.75,ratio:1,borderWidth:2,padding:3,borderColor:color,br:3,center:true,children:checked&&_jsx(View,{bg:color,br:2,flex:true,fullW:true,fullH:true})})},props))]});}
@@ -1 +0,0 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _jsxFileName="/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/form/inputs/Radio.js";var _excluded=["value","onChange","disabled"];import{pipe}from'ramda';import React from'react';import{AbsHiddenInput}from"../../../abstractions/HiddenInput";import{ContentLabel}from"../../presentation/ContentLabel";import{Link}from"../../actions/Link";import{View}from"../../structure/View";import{useColorConverter}from"../../../modifiers/colorConverter";import{useSizeConverter}from"../../../modifiers/sizeConverter";import{useThemeComponentModifier}from"../../../modifiers/themeComponent";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function Radio(_ref){var value=_ref.value,onChange=_ref.onChange,disabled=_ref.disabled,rootProps=_objectWithoutProperties(_ref,_excluded);var _pipe=pipe(useColorConverter('primary'),useSizeConverter('elementHeights','md'),useThemeComponentModifier('Radio'))([{},rootProps]),_pipe2=_slicedToArray(_pipe,2),_pipe2$=_pipe2[0],size=_pipe2$.size,sizeCode=_pipe2$.sizeCode,color=_pipe2$.color,props=_pipe2[1];var _React$useState=React.useState(value),_React$useState2=_slicedToArray(_React$useState,2),checked=_React$useState2[0],setChecked=_React$useState2[1];var toggle=function toggle(){if(!!disabled)return;setChecked(!checked);if(onChange)onChange(!checked);};return _jsxs(Link,{onPress:toggle,className:"neko-radio",disabled:disabled,children:[_jsx(AbsHiddenInput,{checked:checked,onChange:toggle,type:"radio",disabled:disabled}),_jsx(ContentLabel,Object.assign({size:sizeCode,gap:8,content:_jsx(View,{height:size*0.75,ratio:1,borderWidth:2,padding:3,borderColor:color,br:size,center:true,children:checked&&_jsx(View,{bg:color,br:size,flex:true,fullW:true,fullH:true})})},props))]});}
@@ -1 +0,0 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _jsxFileName="/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/form/inputs/Switch.js";var _excluded=["value","onChange","disabled"];import{pipe}from'ramda';import React from'react';import{AbsSwitch}from"../../../abstractions/Switch";import{ContentLabel}from"../../presentation/ContentLabel";import{useColorConverter}from"../../../modifiers/colorConverter";import{useSizeConverter}from"../../../modifiers/sizeConverter";import{useThemeComponentModifier}from"../../../modifiers/themeComponent";import{jsx as _jsx}from"react/jsx-runtime";export function Switch(_ref){var value=_ref.value,onChange=_ref.onChange,disabled=_ref.disabled,rootProps=_objectWithoutProperties(_ref,_excluded);var _pipe=pipe(useColorConverter('primary'),useSizeConverter('elementHeights','md'),useThemeComponentModifier('Switch'))([{},rootProps]),_pipe2=_slicedToArray(_pipe,2),_pipe2$=_pipe2[0],size=_pipe2$.size,sizeCode=_pipe2$.sizeCode,color=_pipe2$.color,props=_pipe2[1];var _React$useState=React.useState(value),_React$useState2=_slicedToArray(_React$useState,2),checked=_React$useState2[0],setChecked=_React$useState2[1];var toggle=function toggle(){if(!!disabled)return;setChecked(!checked);if(onChange)onChange(!checked);};return _jsx(ContentLabel,Object.assign({className:"neko-checkbox",size:sizeCode,gap:8,disabled:disabled,content:_jsx(AbsSwitch,{color:color,value:checked,onValueChange:toggle,trackColor:{true:color},disabled:disabled,height:size*0.75})},props));}
@@ -1 +0,0 @@
1
- export*from"./Checkbox";export*from"./Radio";export*from"./Switch";
@@ -1 +0,0 @@
1
- import{assocPath,path}from'ramda';import React from'react';export function useForm(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$initialValues=_ref.initialValues,initialValues=_ref$initialValues===void 0?{}:_ref$initialValues,validate=_ref.validate;var valuesRef=React.useRef(Object.assign({},initialValues));var errorsRef=React.useRef({});var listenersRef=React.useRef({});var notify=function notify(name){var key=Array.isArray(name)?name.join('.'):name;if(listenersRef.current[key]){listenersRef.current[key].forEach(function(cb){return cb(path(name,valuesRef.current));});}};var setFieldValue=function setFieldValue(name,value){valuesRef.current=assocPath(name,value,valuesRef.current);notify(name);};var getFieldValue=function getFieldValue(name){return path(name,valuesRef.current);};var getError=function getError(name){return path(name,errorsRef.current);};var setError=function setError(name,error){errorsRef.current=assocPath(name,error,errorsRef.current);};var registerListener=function registerListener(name,cb){var key=Array.isArray(name)?name.join('.'):name;if(!listenersRef.current[key]){listenersRef.current[key]=[];}listenersRef.current[key].push(cb);return function(){listenersRef.current[key]=listenersRef.current[key].filter(function(fn){return fn!==cb;});};};var validateForm=function validateForm(){if(!validate)return true;var newErrors=validate(valuesRef.current)||{};errorsRef.current=newErrors;return Object.keys(newErrors).length===0;};var handleSubmit=function handleSubmit(onValid){return function(){var isValid=validateForm();if(isValid){onValid(valuesRef.current);}};};return{setFieldValue:setFieldValue,getFieldValue:getFieldValue,getError:getError,setError:setError,registerListener:registerListener,handleSubmit:handleSubmit,valuesRef:valuesRef};}
@@ -1 +0,0 @@
1
- import{is}from'ramda';import{useBreakpoints}from"../theme/ThemeHandler";import{useWindowWidth}from"../abstractions/windowWidth";export function useResponsiveScreen(){var _breakpoints;var breakpoints=useBreakpoints();var width=useWindowWidth();if(!(breakpoints!=null&&breakpoints.length))return false;for(var i=0;i<breakpoints.length;i++){if(width<breakpoints[i].value){return breakpoints[i].name;}}return(_breakpoints=breakpoints[breakpoints.length-1])==null?void 0:_breakpoints.name;}export function useResponsiveValue(value){var breakpoints=useBreakpoints();var width=useWindowWidth();var screen=useResponsiveScreen();if(!is(Object,value))return value;if(value[screen])return value[screen];var keys=Object.keys(value);var _loop=function _loop(){var match=k.match(/^(\w+)([du])$/);if(!match)return 0;var bpName=match[1];var mode=match[2];var bpIndex=breakpoints.findIndex(function(b){return b.name===bpName;});if(bpIndex===-1)return 0;if(mode==='u'){var lowerBound=bpIndex>0?breakpoints[bpIndex-1].value:0;if(width>=lowerBound)return{v:value[k]};}if(mode==='d'){if(width<breakpoints[bpIndex].value)return{v:value[k]};}},_ret;for(var k of keys){_ret=_loop();if(_ret===0)continue;if(_ret)return _ret.v;}return value==null?void 0:value.df;}
@@ -1,42 +0,0 @@
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 { View } from '../../structure/View'
8
- import { useColorConverter } from '../../../modifiers/colorConverter'
9
- import { useSizeConverter } from '../../../modifiers/sizeConverter'
10
- import { useThemeComponentModifier } from '../../../modifiers/themeComponent'
11
-
12
- export function Checkbox({ value, onChange, disabled, ...rootProps }) {
13
- const [{ size, sizeCode, color }, props] = pipe(
14
- useColorConverter('primary'),
15
- useSizeConverter('elementHeights', 'md'),
16
- useThemeComponentModifier('Checkbox') //
17
- )([{}, rootProps])
18
-
19
- const [checked, setChecked] = React.useState(value)
20
-
21
- const toggle = () => {
22
- if (!!disabled) return
23
- setChecked(!checked)
24
- if (onChange) onChange(!checked)
25
- }
26
-
27
- return (
28
- <Link onPress={toggle} className="neko-checkbox" disabled={disabled}>
29
- <AbsHiddenInput checked={checked} onChange={toggle} type="checkbox" disabled={disabled} />
30
- <ContentLabel
31
- size={sizeCode}
32
- gap={8}
33
- content={
34
- <View height={size * 0.75} ratio={1} borderWidth={2} padding={3} borderColor={color} br={3} center>
35
- {checked && <View bg={color} br={2} flex fullW fullH />}
36
- </View>
37
- }
38
- {...props}
39
- />
40
- </Link>
41
- )
42
- }
@@ -1,42 +0,0 @@
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 { View } from '../../structure/View'
8
- import { useColorConverter } from '../../../modifiers/colorConverter'
9
- import { useSizeConverter } from '../../../modifiers/sizeConverter'
10
- import { useThemeComponentModifier } from '../../../modifiers/themeComponent'
11
-
12
- export function Radio({ value, onChange, disabled, ...rootProps }) {
13
- const [{ size, sizeCode, color }, props] = pipe(
14
- useColorConverter('primary'),
15
- useSizeConverter('elementHeights', 'md'),
16
- useThemeComponentModifier('Radio') //
17
- )([{}, rootProps])
18
-
19
- const [checked, setChecked] = React.useState(value)
20
-
21
- const toggle = () => {
22
- if (!!disabled) return
23
- setChecked(!checked)
24
- if (onChange) onChange(!checked)
25
- }
26
-
27
- return (
28
- <Link onPress={toggle} className="neko-radio" disabled={disabled}>
29
- <AbsHiddenInput checked={checked} onChange={toggle} type="radio" disabled={disabled} />
30
- <ContentLabel
31
- size={sizeCode}
32
- gap={8}
33
- content={
34
- <View height={size * 0.75} ratio={1} borderWidth={2} padding={3} borderColor={color} br={size} center>
35
- {checked && <View bg={color} br={size} flex fullW fullH />}
36
- </View>
37
- }
38
- {...props}
39
- />
40
- </Link>
41
- )
42
- }
@@ -1,44 +0,0 @@
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 { useColorConverter } from '../../../modifiers/colorConverter'
7
- import { useSizeConverter } from '../../../modifiers/sizeConverter'
8
- import { useThemeComponentModifier } from '../../../modifiers/themeComponent'
9
-
10
- export function Switch({ value, onChange, disabled, ...rootProps }) {
11
- const [{ size, sizeCode, color }, props] = pipe(
12
- useColorConverter('primary'),
13
- useSizeConverter('elementHeights', 'md'),
14
- useThemeComponentModifier('Switch') //
15
- )([{}, rootProps])
16
-
17
- const [checked, setChecked] = React.useState(value)
18
-
19
- const toggle = () => {
20
- if (!!disabled) return
21
- setChecked(!checked)
22
- if (onChange) onChange(!checked)
23
- }
24
-
25
- return (
26
- <ContentLabel
27
- className="neko-checkbox"
28
- size={sizeCode}
29
- gap={8}
30
- disabled={disabled}
31
- content={
32
- <AbsSwitch
33
- color={color}
34
- value={checked}
35
- onValueChange={toggle}
36
- trackColor={{ true: color }}
37
- disabled={disabled}
38
- height={size * 0.75}
39
- />
40
- }
41
- {...props}
42
- />
43
- )
44
- }
@@ -1,3 +0,0 @@
1
- export * from './Checkbox'
2
- export * from './Radio'
3
- export * from './Switch'