@neko-os/ui 0.0.4 → 0.0.5

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 (193) hide show
  1. package/dist/abstractions/BKTouchableOpacity.js +0 -0
  2. package/dist/abstractions/HiddenInput.js +1 -0
  3. package/dist/abstractions/HiddenInput.native.js +1 -0
  4. package/dist/abstractions/Icon.js +1 -1
  5. package/dist/abstractions/Icon.native.js +1 -1
  6. package/dist/abstractions/Icon.web.js +1 -1
  7. package/dist/abstractions/Switch.js +1 -0
  8. package/dist/abstractions/Switch.native.js +1 -0
  9. package/dist/abstractions/TouchableOpacity.js +1 -1
  10. package/dist/abstractions/TouchableOpacity.native.js +1 -0
  11. package/dist/abstractions/TouchableOpacity.web.js +1 -0
  12. package/dist/abstractions/windowWidth.js +1 -0
  13. package/dist/abstractions/windowWidth.native.js +1 -0
  14. package/dist/abstractions/windowWidth.web.js +1 -0
  15. package/dist/components/actions/Button.js +1 -0
  16. package/dist/components/actions/Link.js +1 -0
  17. package/dist/components/actions/index.js +1 -0
  18. package/dist/components/form/Form.js +1 -0
  19. package/dist/components/form/FormGroup.js +1 -0
  20. package/dist/components/form/FormItem.js +1 -0
  21. package/dist/components/form/FormList.js +1 -0
  22. package/dist/components/form/FormWrapperComponent.js +1 -0
  23. package/dist/{form → components/form}/index.js +1 -1
  24. package/dist/components/form/inputs/Checkbox.js +1 -0
  25. package/dist/components/form/inputs/Radio.js +1 -0
  26. package/dist/components/form/inputs/Switch.js +1 -0
  27. package/dist/components/form/inputs/index.js +1 -0
  28. package/dist/components/helpers/Responsive.js +1 -0
  29. package/dist/components/helpers/Separator.js +1 -0
  30. package/dist/components/helpers/index.js +1 -0
  31. package/dist/components/index.js +1 -0
  32. package/dist/components/presentation/ContentLabel.js +1 -0
  33. package/dist/components/presentation/Icon.js +1 -0
  34. package/dist/components/presentation/IconLabel.js +1 -0
  35. package/dist/components/presentation/Tag.js +1 -0
  36. package/dist/components/presentation/index.js +1 -0
  37. package/dist/components/structure/Card.js +1 -0
  38. package/dist/components/structure/View.js +1 -0
  39. package/dist/components/text/Text.js +1 -0
  40. package/dist/helpers/index.js +1 -0
  41. package/dist/helpers/responsive.js +1 -0
  42. package/dist/index.css +5 -0
  43. package/dist/index.js +1 -1
  44. package/dist/modifiers/background.js +1 -1
  45. package/dist/modifiers/border.js +1 -1
  46. package/dist/modifiers/colorConverter.js +1 -0
  47. package/dist/modifiers/default.js +1 -0
  48. package/dist/modifiers/display.js +1 -0
  49. package/dist/modifiers/flex.js +1 -1
  50. package/dist/modifiers/flexWrapper.js +1 -1
  51. package/dist/modifiers/fullColor.js +1 -0
  52. package/dist/modifiers/logger.js +1 -0
  53. package/dist/modifiers/margin.js +1 -1
  54. package/dist/modifiers/padding.js +1 -1
  55. package/dist/modifiers/position.js +1 -1
  56. package/dist/modifiers/shadow.js +1 -1
  57. package/dist/modifiers/size.js +1 -1
  58. package/dist/modifiers/sizeConverter.js +1 -0
  59. package/dist/modifiers/text.js +1 -1
  60. package/dist/modifiers/textConverter.js +1 -0
  61. package/dist/modifiers/themeComponent.js +1 -0
  62. package/dist/theme/ThemeHandler.js +1 -1
  63. package/dist/theme/default/base.js +1 -1
  64. package/dist/theme/default/cyberpunkTheme.js +1 -1
  65. package/dist/theme/default/darkTheme.js +1 -1
  66. package/dist/theme/default/deepWoodsTheme.js +1 -1
  67. package/dist/theme/default/forestTheme.js +1 -1
  68. package/dist/theme/default/hackerTheme.js +1 -0
  69. package/dist/theme/default/lightTheme.js +1 -1
  70. package/dist/theme/default/midnightTheme.js +1 -1
  71. package/dist/theme/default/msdosTheme.js +1 -0
  72. package/dist/theme/default/oceanTheme.js +1 -1
  73. package/dist/theme/default/pastelTheme.js +1 -1
  74. package/dist/theme/default/sunsetTheme.js +1 -1
  75. package/dist/theme/default/themes.js +1 -1
  76. package/dist/theme/helpers/colorScale.js +1 -0
  77. package/dist/theme/helpers/mergePreset.js +1 -0
  78. package/dist/theme/helpers/relatedScales.js +1 -0
  79. package/dist/theme/helpers/sizeScale.js +1 -1
  80. package/dist/theme/helpers/textScale.js +1 -0
  81. package/package.json +1 -1
  82. package/src/abstractions/BKTouchableOpacity.js +12 -0
  83. package/src/abstractions/HiddenInput.js +3 -0
  84. package/src/abstractions/HiddenInput.native.js +3 -0
  85. package/src/abstractions/Icon.js +23 -1
  86. package/src/abstractions/Icon.native.js +11 -2
  87. package/src/abstractions/Icon.web.js +11 -2
  88. package/src/abstractions/Switch.js +97 -0
  89. package/src/abstractions/Switch.native.js +12 -0
  90. package/src/abstractions/TouchableOpacity.js +3 -11
  91. package/src/abstractions/TouchableOpacity.native.js +3 -0
  92. package/src/abstractions/TouchableOpacity.web.js +3 -0
  93. package/src/abstractions/windowWidth.js +13 -0
  94. package/src/abstractions/windowWidth.native.js +6 -0
  95. package/src/abstractions/windowWidth.web.js +6 -0
  96. package/src/components/actions/Button.js +62 -0
  97. package/src/components/actions/Link.js +39 -0
  98. package/src/{actions → components/actions}/index.js +1 -0
  99. package/src/{form → components/form}/FormItem.js +2 -2
  100. package/src/{form → components/form}/FormList.js +2 -2
  101. package/src/{form → components/form}/index.js +1 -0
  102. package/src/components/form/inputs/Checkbox.js +42 -0
  103. package/src/components/form/inputs/Radio.js +42 -0
  104. package/src/components/form/inputs/Switch.js +44 -0
  105. package/src/components/form/inputs/index.js +3 -0
  106. package/src/components/helpers/Responsive.js +18 -0
  107. package/src/components/helpers/Separator.js +49 -0
  108. package/src/components/helpers/index.js +2 -0
  109. package/src/components/index.js +6 -0
  110. package/src/components/presentation/ContentLabel.js +25 -0
  111. package/src/components/presentation/Icon.js +20 -0
  112. package/src/components/presentation/IconLabel.js +29 -0
  113. package/src/components/presentation/Tag.js +72 -0
  114. package/src/{presentation → components/presentation}/index.js +1 -0
  115. package/src/components/structure/Card.js +42 -0
  116. package/src/components/structure/View.js +36 -0
  117. package/src/components/text/Text.js +28 -0
  118. package/src/helpers/index.js +2 -0
  119. package/src/helpers/responsive.js +54 -0
  120. package/src/index.css +5 -0
  121. package/src/index.js +2 -5
  122. package/src/modifiers/background.js +10 -7
  123. package/src/modifiers/border.js +10 -7
  124. package/src/modifiers/colorConverter.js +13 -0
  125. package/src/modifiers/default.js +9 -0
  126. package/src/modifiers/display.js +24 -0
  127. package/src/modifiers/flex.js +10 -7
  128. package/src/modifiers/flexWrapper.js +12 -9
  129. package/src/modifiers/{fullColor.js.js → fullColor.js} +8 -9
  130. package/src/modifiers/logger.js +6 -0
  131. package/src/modifiers/margin.js +10 -7
  132. package/src/modifiers/padding.js +10 -7
  133. package/src/modifiers/position.js +10 -7
  134. package/src/modifiers/shadow.js +10 -7
  135. package/src/modifiers/size.js +8 -5
  136. package/src/modifiers/sizeConverter.js +12 -0
  137. package/src/modifiers/text.js +14 -13
  138. package/src/modifiers/textConverter.js +12 -0
  139. package/src/modifiers/themeComponent.js +11 -0
  140. package/src/theme/ThemeHandler.js +31 -33
  141. package/src/theme/default/base.js +13 -1
  142. package/src/theme/default/cyberpunkTheme.js +1 -0
  143. package/src/theme/default/darkTheme.js +1 -0
  144. package/src/theme/default/deepWoodsTheme.js +1 -0
  145. package/src/theme/default/forestTheme.js +1 -0
  146. package/src/theme/default/hackerTheme.js +32 -0
  147. package/src/theme/default/lightTheme.js +1 -0
  148. package/src/theme/default/midnightTheme.js +1 -0
  149. package/src/theme/default/msdosTheme.js +40 -0
  150. package/src/theme/default/oceanTheme.js +1 -0
  151. package/src/theme/default/pastelTheme.js +1 -0
  152. package/src/theme/default/sunsetTheme.js +1 -0
  153. package/src/theme/default/themes.js +4 -0
  154. package/src/theme/helpers/colorScale.js +11 -0
  155. package/src/theme/helpers/mergePreset.js +7 -0
  156. package/src/theme/helpers/relatedScales.js +34 -0
  157. package/src/theme/helpers/sizeScale.js +12 -4
  158. package/src/theme/helpers/textScale.js +15 -0
  159. package/dist/actions/Button.js +0 -1
  160. package/dist/actions/index.js +0 -1
  161. package/dist/form/Form.js +0 -1
  162. package/dist/form/FormGroup.js +0 -1
  163. package/dist/form/FormItem.js +0 -1
  164. package/dist/form/FormList.js +0 -1
  165. package/dist/form/FormWrapperComponent.js +0 -1
  166. package/dist/modifiers/fullColor.js.js +0 -1
  167. package/dist/presentation/Icon.js +0 -1
  168. package/dist/presentation/Tag.js +0 -1
  169. package/dist/presentation/index.js +0 -1
  170. package/dist/structure/Card.js +0 -1
  171. package/dist/structure/View.js +0 -1
  172. package/dist/text/Text.js +0 -1
  173. package/dist/theme/default/base.native.js +0 -1
  174. package/dist/theme/default/base.web.js +0 -1
  175. package/src/actions/Button.js +0 -48
  176. package/src/presentation/Icon.js +0 -14
  177. package/src/presentation/Tag.js +0 -32
  178. package/src/structure/Card.js +0 -36
  179. package/src/structure/View.js +0 -34
  180. package/src/text/Text.js +0 -20
  181. package/src/theme/default/base.native.js +0 -58
  182. package/src/theme/default/base.web.js +0 -3
  183. /package/dist/{form → components/form}/FormWrapperComponent.native.js +0 -0
  184. /package/dist/{form → components/form}/useForm.js +0 -0
  185. /package/dist/{structure → components/structure}/index.js +0 -0
  186. /package/dist/{text → components/text}/index.js +0 -0
  187. /package/src/{form → components/form}/Form.js +0 -0
  188. /package/src/{form → components/form}/FormGroup.js +0 -0
  189. /package/src/{form → components/form}/FormWrapperComponent.js +0 -0
  190. /package/src/{form → components/form}/FormWrapperComponent.native.js +0 -0
  191. /package/src/{form → components/form}/useForm.js +0 -0
  192. /package/src/{structure → components/structure}/index.js +0 -0
  193. /package/src/{text → components/text}/index.js +0 -0
@@ -0,0 +1,3 @@
1
+ export function AbsHiddenInput() {
2
+ return false
3
+ }
@@ -20,7 +20,29 @@ export function AbsIcon({ name, ...props }) {
20
20
  }
21
21
  }, [])
22
22
 
23
- if (loading) return false
23
+ if (loading) {
24
+ return (
25
+ <div
26
+ style={{
27
+ height: props.size,
28
+ width: props.size,
29
+ borderRadius: props.size,
30
+ display: 'flex',
31
+ justifyContent: 'center',
32
+ alignItems: 'center',
33
+ }}
34
+ >
35
+ <div
36
+ style={{
37
+ height: props.size / 3,
38
+ width: props.size / 3,
39
+ borderRadius: props.size,
40
+ backgroundColor: props.color,
41
+ }}
42
+ />
43
+ </div>
44
+ )
45
+ }
24
46
 
25
47
  return <Component {...props} />
26
48
  }
@@ -1,2 +1,11 @@
1
- import RmIcon from 'react-native-remix-icon'
2
- export const AbsIcon = RmIcon
1
+ let AbsIcon
2
+
3
+ try {
4
+ const RmIcon = require('react-native-remix-icon')?.default
5
+ console.log(RmIcon)
6
+ AbsIcon = (props) => <RmIcon {...props} />
7
+ } catch {
8
+ AbsIcon = () => false
9
+ }
10
+
11
+ export { AbsIcon }
@@ -1,2 +1,11 @@
1
- import RmIcon from 'react-native-remix-icon'
2
- export const AbsIcon = RmIcon
1
+ let AbsIcon
2
+
3
+ try {
4
+ const RmIcon = require('react-native-remix-icon')?.default
5
+ console.log(RmIcon)
6
+ AbsIcon = (props) => <RmIcon {...props} />
7
+ } catch {
8
+ AbsIcon = () => false
9
+ }
10
+
11
+ export { AbsIcon }
@@ -0,0 +1,97 @@
1
+ import { useCallback } from 'react'
2
+
3
+ export function AbsSwitch({
4
+ value = false,
5
+ onValueChange = () => {},
6
+ disabled = false,
7
+ trackColor = { false: '#767577', true: '#81b0ff' },
8
+ thumbColor,
9
+ height = 32,
10
+ style,
11
+ ...rest
12
+ }) {
13
+ const isOn = !!value
14
+
15
+ const handleToggle = useCallback(() => {
16
+ if (disabled) return
17
+ onValueChange(!isOn)
18
+ }, [disabled, isOn, onValueChange])
19
+
20
+ const onKeyDown = useCallback(
21
+ (e) => {
22
+ if (disabled) return
23
+ if (e.key === 'Enter' || e.key === ' ') {
24
+ e.preventDefault()
25
+ onValueChange(!isOn)
26
+ }
27
+ if (e.key === 'ArrowLeft' && isOn) onValueChange(false)
28
+ if (e.key === 'ArrowRight' && !isOn) onValueChange(true)
29
+ },
30
+ [disabled, isOn, onValueChange]
31
+ )
32
+
33
+ const trackOff = (trackColor && trackColor.false) || '#76757750'
34
+ const trackOn = (trackColor && trackColor.true) || '#81b0ff'
35
+ const currentTrack = isOn ? trackOn : trackOff
36
+
37
+ const defaultThumb = '#ffffff'
38
+ const currentThumb = thumbColor || defaultThumb
39
+
40
+ const width = 1.7 * height
41
+ const padding = 2
42
+ const thumbSize = height - padding * 2
43
+ const translateX = isOn ? width - thumbSize - padding * 2 : 0
44
+
45
+ return (
46
+ <button
47
+ type="button"
48
+ role="switch"
49
+ aria-checked={isOn}
50
+ aria-disabled={disabled}
51
+ onClick={handleToggle}
52
+ onKeyDown={onKeyDown}
53
+ disabled={disabled}
54
+ style={{
55
+ WebkitTapHighlightColor: 'transparent',
56
+ cursor: disabled ? 'not-allowed' : 'pointer',
57
+ background: 'transparent',
58
+ border: 'none',
59
+ padding: 0,
60
+ margin: 0,
61
+ outline: 'none',
62
+ display: 'inline-flex',
63
+ alignItems: 'center',
64
+ ...style,
65
+ }}
66
+ {...rest}
67
+ >
68
+ <span
69
+ aria-hidden
70
+ style={{
71
+ position: 'relative',
72
+ width,
73
+ height,
74
+ borderRadius: height / 2,
75
+ backgroundColor: currentTrack,
76
+ transition: 'background-color 150ms ease',
77
+ _opacity: disabled ? 0.6 : 1,
78
+ display: 'inline-block',
79
+ }}
80
+ >
81
+ <span
82
+ style={{
83
+ position: 'absolute',
84
+ top: padding,
85
+ left: padding + translateX,
86
+ width: thumbSize,
87
+ height: thumbSize,
88
+ borderRadius: thumbSize / 2,
89
+ backgroundColor: currentThumb,
90
+ boxShadow: '0 1px 2px rgba(0,0,0,0.2), 0 1px 1px rgba(0,0,0,0.1)',
91
+ transition: 'left 150ms ease, background-color 150ms ease',
92
+ }}
93
+ />
94
+ </span>
95
+ </button>
96
+ )
97
+ }
@@ -0,0 +1,12 @@
1
+ import { Switch as RNSwitch } from 'react-native'
2
+
3
+ export function AbsSwitch({ height, style, ...props }) {
4
+ const baseHeight = 31
5
+ let transform = undefined
6
+ if (!!height) {
7
+ const scale = height / baseHeight
8
+ transform = [{ scaleX: scale }, { scaleY: scale }]
9
+ }
10
+
11
+ return <RNSwitch style={{ transform, ...style }} {...props} />
12
+ }
@@ -1,12 +1,4 @@
1
- import React from 'react'
2
-
3
- let AbsTouchableOpacity
4
-
5
- try {
6
- const { Platform, TouchableOpacity: RNTouchableOpacity } = require('react-native')
7
- AbsTouchableOpacity = (props) => <RNTouchableOpacity {...props} />
8
- } catch {
9
- AbsTouchableOpacity = (props) => <button {...props} />
1
+ export function AbsTouchableOpacity({ link, onPress, onClick, ...props }) {
2
+ const Component = link ? 'a' : 'button'
3
+ return <Component onClick={onClick || onPress} {...props} />
10
4
  }
11
-
12
- export { AbsTouchableOpacity }
@@ -0,0 +1,3 @@
1
+ import { TouchableOpacity as RNTouchableOpacity } from 'react-native'
2
+
3
+ export const AbsTouchableOpacity = RNTouchableOpacity
@@ -0,0 +1,3 @@
1
+ import { TouchableOpacity as RNTouchableOpacity } from 'react-native'
2
+
3
+ export const AbsTouchableOpacity = RNTouchableOpacity
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+
3
+ export function useWindowWidth() {
4
+ const [width, setWidth] = React.useState(window.innerWidth)
5
+
6
+ React.useEffect(() => {
7
+ const handleResize = () => setWidth(window.innerWidth)
8
+ window.addEventListener('resize', handleResize)
9
+ return () => window.removeEventListener('resize', handleResize)
10
+ }, [])
11
+
12
+ return width
13
+ }
@@ -0,0 +1,6 @@
1
+ import { useWindowDimensions } from 'react-native'
2
+
3
+ export function useWindowWidth() {
4
+ const { width } = useWindowDimensions()
5
+ return width
6
+ }
@@ -0,0 +1,6 @@
1
+ import { useWindowDimensions } from 'react-native'
2
+
3
+ export function useWindowWidth() {
4
+ const { width } = useWindowDimensions()
5
+ return width
6
+ }
@@ -0,0 +1,62 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsTouchableOpacity } from '../../abstractions/TouchableOpacity'
4
+ import { IconLabel } from '../presentation/IconLabel'
5
+ import { useBackgroundModifier } from '../../modifiers/background'
6
+ import { useBorderModifier } from '../../modifiers/border'
7
+ import { useColorConverter } from '../../modifiers/colorConverter'
8
+ import { useDefaultModifier } from '../../modifiers/default'
9
+ import { useFlexModifier } from '../../modifiers/flex'
10
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
11
+ import { useFullColorModifier } from '../../modifiers/fullColor'
12
+ import { useMarginModifier } from '../../modifiers/margin'
13
+ import { usePaddingModifier } from '../../modifiers/padding'
14
+ import { usePositionModifier } from '../../modifiers/position'
15
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
16
+ import { useSizeModifier } from '../../modifiers/size'
17
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
18
+
19
+ const DEFAULT_PROPS = ([{ sizeCode }]) => ({
20
+ paddingH: sizeCode,
21
+ paddingV: 2,
22
+ height: sizeCode,
23
+ br: sizeCode,
24
+ borderWidth: 1,
25
+ center: true,
26
+ })
27
+
28
+ export function Button(rootProps) {
29
+ const [{ fontColor, sizeCode }, formattedProps] = pipe(
30
+ useColorConverter('primary'),
31
+ useSizeConverter('elementHeights', 'md'),
32
+ useThemeComponentModifier('Button'),
33
+ useDefaultModifier(DEFAULT_PROPS),
34
+ useFullColorModifier,
35
+ useSizeModifier,
36
+ usePositionModifier,
37
+ usePaddingModifier,
38
+ useMarginModifier,
39
+ useFlexModifier,
40
+ useFlexWrapperModifier,
41
+ useBackgroundModifier,
42
+ useBorderModifier
43
+ )([{}, rootProps])
44
+
45
+ const { label, icon, textProps, iconProps, gap, invert, size, ...props } = formattedProps
46
+
47
+ return (
48
+ <AbsTouchableOpacity className="neko-button neko-wave-click-effect" {...props}>
49
+ <IconLabel
50
+ center
51
+ color={fontColor}
52
+ size={sizeCode}
53
+ label={label}
54
+ icon={icon}
55
+ gap={gap}
56
+ invert={invert}
57
+ textProps={{ strong: true, ...textProps }}
58
+ iconProps={iconProps}
59
+ />
60
+ </AbsTouchableOpacity>
61
+ )
62
+ }
@@ -0,0 +1,39 @@
1
+ import { pipe, is } from 'ramda'
2
+
3
+ import { AbsTouchableOpacity } from '../../abstractions/TouchableOpacity'
4
+ import { Text } from '../text/Text'
5
+ import { useDisplayModifier } from '../../modifiers/display'
6
+ import { useFlexModifier } from '../../modifiers/flex'
7
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
8
+ import { useMarginModifier } from '../../modifiers/margin'
9
+ import { usePaddingModifier } from '../../modifiers/padding'
10
+ import { usePositionModifier } from '../../modifiers/position'
11
+ import { useSizeModifier } from '../../modifiers/size'
12
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
13
+
14
+ export function Link({ label, children, onPress, ...rootProps }) {
15
+ const [_, props] = pipe(
16
+ useThemeComponentModifier('Link'),
17
+ useSizeModifier, //
18
+ useDisplayModifier, //
19
+ usePositionModifier,
20
+ usePaddingModifier,
21
+ useMarginModifier,
22
+ useFlexWrapperModifier,
23
+ useFlexModifier
24
+ )([{}, rootProps])
25
+
26
+ if (!!label || is(String, children)) {
27
+ children = (
28
+ <Text primary {...props}>
29
+ {label || children}
30
+ </Text>
31
+ )
32
+ }
33
+
34
+ return (
35
+ <AbsTouchableOpacity className="neko-link" link onPress={!!props.disabled ? undefined : onPress} {...props}>
36
+ {children}
37
+ </AbsTouchableOpacity>
38
+ )
39
+ }
@@ -1 +1,2 @@
1
1
  export * from './Button'
2
+ export * from './Link'
@@ -1,7 +1,7 @@
1
- import { Text } from 'react-native'
2
1
  import React from 'react'
3
2
 
4
3
  import { FormGroup, useRelativePath } from './FormGroup'
4
+ import { Text } from '../text/Text'
5
5
  import { useFormInstance } from './Form'
6
6
 
7
7
  export function FormItem({ name, relative, children }) {
@@ -28,7 +28,7 @@ export function FormItem({ name, relative, children }) {
28
28
  return (
29
29
  <FormGroup name={listPath}>
30
30
  {childWithProps}
31
- {error && <Text style={{ color: 'red' }}>{error}</Text>}
31
+ {error && <Text color="red">{error}</Text>}
32
32
  </FormGroup>
33
33
  )
34
34
  }
@@ -1,7 +1,7 @@
1
- import { Text } from 'react-native'
2
1
  import React from 'react'
3
2
 
4
3
  import { FormGroup, useRelativePath } from './FormGroup'
4
+ import { Text } from '../text/Text'
5
5
  import { useFormInstance } from './Form'
6
6
 
7
7
  const FormListContext = React.createContext(null)
@@ -81,7 +81,7 @@ export function FormList({ name, relative, children }) {
81
81
  {typeof children === 'function'
82
82
  ? children(fields, actions)
83
83
  : React.cloneElement(React.Children.only(children), { fields, ...actions })}
84
- {error && <Text style={{ color: 'red' }}>{error}</Text>}
84
+ {error && <Text color="red">{error}</Text>}
85
85
  </FormListContext.Provider>
86
86
  </FormGroup>
87
87
  )
@@ -4,3 +4,4 @@ export * from './FormList'
4
4
  export * from './FormWrapperComponent'
5
5
  export * from './FormGroup'
6
6
  export * from './useForm'
7
+ export * from './inputs'
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,44 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Checkbox'
2
+ export * from './Radio'
3
+ export * from './Switch'
@@ -0,0 +1,18 @@
1
+ import { useResponsiveValue } from '../../helpers/responsive'
2
+
3
+ export function ResponsiveRender(props) {
4
+ const value = useResponsiveValue(props) || props.df
5
+ return typeof value === 'function' ? value() : value
6
+ }
7
+
8
+ export function HideOn({ children, ...props }) {
9
+ const hide = useResponsiveValue(props)
10
+ if (!!hide) return false
11
+ return children
12
+ }
13
+
14
+ export function ShowOn({ children, ...props }) {
15
+ const show = useResponsiveValue(props)
16
+ if (!show) return false
17
+ return children
18
+ }
@@ -0,0 +1,49 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsView } from '../../abstractions/View'
4
+ import { View } from '../structure/View'
5
+ import { useColorConverter } from '../../modifiers/colorConverter'
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 { useSizeConverter } from '../../modifiers/sizeConverter'
11
+ import { useSizeModifier } from '../../modifiers/size'
12
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
13
+
14
+ const DEFAULT_PROPS = ([{ size, sizeCode }, { withLine }]) => ({
15
+ height: withLine ? 2 * size : size,
16
+ br: sizeCode,
17
+ center: true,
18
+ })
19
+
20
+ export function Separator(rootProps) {
21
+ const [{ color }, formattedProps] = pipe(
22
+ useColorConverter('divider'),
23
+ useSizeConverter('spaces', 'md'),
24
+ useThemeComponentModifier('Separator'),
25
+ useDefaultModifier(DEFAULT_PROPS),
26
+ useSizeModifier,
27
+ useMarginModifier,
28
+ useFlexModifier,
29
+ useFlexWrapperModifier
30
+ )([{}, rootProps])
31
+
32
+ const { withLine, lineProps, lineWidth, lineHeight = 1, ...props } = formattedProps
33
+
34
+ return (
35
+ <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
+ />
46
+ )}
47
+ </AbsView>
48
+ )
49
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Separator'
2
+ export * from './Responsive'
@@ -0,0 +1,6 @@
1
+ export * from './actions'
2
+ export * from './form'
3
+ export * from './presentation'
4
+ export * from './structure'
5
+ export * from './text'
6
+ export * from './helpers'
@@ -0,0 +1,25 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { Text } from '../text/Text'
4
+ import { View } from '../structure/View'
5
+ import { useColorConverter } from '../../modifiers/colorConverter'
6
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
7
+
8
+ export function ContentLabel(rootProps) {
9
+ const [{ color }, formattedProps] = pipe(
10
+ useColorConverter(),
11
+ useThemeComponentModifier('ContentLabel') //
12
+ )([{}, rootProps])
13
+
14
+ const { label, content, textProps, size = 'md', invert, gap = 5, ...props } = formattedProps
15
+
16
+ return (
17
+ <View className="neko-content-label" row gap={gap} centerV {...props}>
18
+ {!invert && content}
19
+ <Text color={color} size={size} {...textProps}>
20
+ {label}
21
+ </Text>
22
+ {!!invert && content}
23
+ </View>
24
+ )
25
+ }
@@ -0,0 +1,20 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsIcon } from '../../abstractions/Icon'
4
+ import { useColorConverter } from '../../modifiers/colorConverter'
5
+ import { useMarginModifier } from '../../modifiers/margin'
6
+ import { usePositionModifier } from '../../modifiers/position'
7
+ import { useSizeConverter } from '../../modifiers/sizeConverter'
8
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
9
+
10
+ export function Icon({ name, ...rootProps }) {
11
+ const [{ size, color }, props] = pipe(
12
+ useSizeConverter('icons', 'md'),
13
+ useColorConverter('text'),
14
+ useThemeComponentModifier('Icon'),
15
+ usePositionModifier, //
16
+ useMarginModifier
17
+ )([{}, rootProps])
18
+
19
+ return <AbsIcon className="neko-icon" name={name} color={color} size={size} {...props} />
20
+ }