@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.
- package/dist/abstractions/BKTouchableOpacity.js +0 -0
- package/dist/abstractions/HiddenInput.js +1 -0
- package/dist/abstractions/HiddenInput.native.js +1 -0
- package/dist/abstractions/Icon.js +1 -1
- package/dist/abstractions/Icon.native.js +1 -1
- package/dist/abstractions/Icon.web.js +1 -1
- package/dist/abstractions/Switch.js +1 -0
- package/dist/abstractions/Switch.native.js +1 -0
- package/dist/abstractions/TouchableOpacity.js +1 -1
- package/dist/abstractions/TouchableOpacity.native.js +1 -0
- package/dist/abstractions/TouchableOpacity.web.js +1 -0
- package/dist/abstractions/windowWidth.js +1 -0
- package/dist/abstractions/windowWidth.native.js +1 -0
- package/dist/abstractions/windowWidth.web.js +1 -0
- package/dist/components/actions/Button.js +1 -0
- package/dist/components/actions/Link.js +1 -0
- package/dist/components/actions/index.js +1 -0
- package/dist/components/form/Form.js +1 -0
- package/dist/components/form/FormGroup.js +1 -0
- package/dist/components/form/FormItem.js +1 -0
- package/dist/components/form/FormList.js +1 -0
- package/dist/components/form/FormWrapperComponent.js +1 -0
- package/dist/{form → components/form}/index.js +1 -1
- package/dist/components/form/inputs/Checkbox.js +1 -0
- package/dist/components/form/inputs/Radio.js +1 -0
- package/dist/components/form/inputs/Switch.js +1 -0
- package/dist/components/form/inputs/index.js +1 -0
- package/dist/components/helpers/Responsive.js +1 -0
- package/dist/components/helpers/Separator.js +1 -0
- package/dist/components/helpers/index.js +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/presentation/ContentLabel.js +1 -0
- package/dist/components/presentation/Icon.js +1 -0
- package/dist/components/presentation/IconLabel.js +1 -0
- package/dist/components/presentation/Tag.js +1 -0
- package/dist/components/presentation/index.js +1 -0
- package/dist/components/structure/Card.js +1 -0
- package/dist/components/structure/View.js +1 -0
- package/dist/components/text/Text.js +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/responsive.js +1 -0
- package/dist/index.css +5 -0
- package/dist/index.js +1 -1
- package/dist/modifiers/background.js +1 -1
- package/dist/modifiers/border.js +1 -1
- package/dist/modifiers/colorConverter.js +1 -0
- package/dist/modifiers/default.js +1 -0
- package/dist/modifiers/display.js +1 -0
- package/dist/modifiers/flex.js +1 -1
- package/dist/modifiers/flexWrapper.js +1 -1
- package/dist/modifiers/fullColor.js +1 -0
- package/dist/modifiers/logger.js +1 -0
- package/dist/modifiers/margin.js +1 -1
- package/dist/modifiers/padding.js +1 -1
- package/dist/modifiers/position.js +1 -1
- package/dist/modifiers/shadow.js +1 -1
- package/dist/modifiers/size.js +1 -1
- package/dist/modifiers/sizeConverter.js +1 -0
- package/dist/modifiers/text.js +1 -1
- package/dist/modifiers/textConverter.js +1 -0
- package/dist/modifiers/themeComponent.js +1 -0
- package/dist/theme/ThemeHandler.js +1 -1
- package/dist/theme/default/base.js +1 -1
- package/dist/theme/default/cyberpunkTheme.js +1 -1
- package/dist/theme/default/darkTheme.js +1 -1
- package/dist/theme/default/deepWoodsTheme.js +1 -1
- package/dist/theme/default/forestTheme.js +1 -1
- package/dist/theme/default/hackerTheme.js +1 -0
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/midnightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -0
- package/dist/theme/default/oceanTheme.js +1 -1
- package/dist/theme/default/pastelTheme.js +1 -1
- package/dist/theme/default/sunsetTheme.js +1 -1
- package/dist/theme/default/themes.js +1 -1
- package/dist/theme/helpers/colorScale.js +1 -0
- package/dist/theme/helpers/mergePreset.js +1 -0
- package/dist/theme/helpers/relatedScales.js +1 -0
- package/dist/theme/helpers/sizeScale.js +1 -1
- package/dist/theme/helpers/textScale.js +1 -0
- package/package.json +1 -1
- package/src/abstractions/BKTouchableOpacity.js +12 -0
- package/src/abstractions/HiddenInput.js +3 -0
- package/src/abstractions/HiddenInput.native.js +3 -0
- package/src/abstractions/Icon.js +23 -1
- package/src/abstractions/Icon.native.js +11 -2
- package/src/abstractions/Icon.web.js +11 -2
- package/src/abstractions/Switch.js +97 -0
- package/src/abstractions/Switch.native.js +12 -0
- package/src/abstractions/TouchableOpacity.js +3 -11
- package/src/abstractions/TouchableOpacity.native.js +3 -0
- package/src/abstractions/TouchableOpacity.web.js +3 -0
- package/src/abstractions/windowWidth.js +13 -0
- package/src/abstractions/windowWidth.native.js +6 -0
- package/src/abstractions/windowWidth.web.js +6 -0
- package/src/components/actions/Button.js +62 -0
- package/src/components/actions/Link.js +39 -0
- package/src/{actions → components/actions}/index.js +1 -0
- package/src/{form → components/form}/FormItem.js +2 -2
- package/src/{form → components/form}/FormList.js +2 -2
- package/src/{form → components/form}/index.js +1 -0
- package/src/components/form/inputs/Checkbox.js +42 -0
- package/src/components/form/inputs/Radio.js +42 -0
- package/src/components/form/inputs/Switch.js +44 -0
- package/src/components/form/inputs/index.js +3 -0
- package/src/components/helpers/Responsive.js +18 -0
- package/src/components/helpers/Separator.js +49 -0
- package/src/components/helpers/index.js +2 -0
- package/src/components/index.js +6 -0
- package/src/components/presentation/ContentLabel.js +25 -0
- package/src/components/presentation/Icon.js +20 -0
- package/src/components/presentation/IconLabel.js +29 -0
- package/src/components/presentation/Tag.js +72 -0
- package/src/{presentation → components/presentation}/index.js +1 -0
- package/src/components/structure/Card.js +42 -0
- package/src/components/structure/View.js +36 -0
- package/src/components/text/Text.js +28 -0
- package/src/helpers/index.js +2 -0
- package/src/helpers/responsive.js +54 -0
- package/src/index.css +5 -0
- package/src/index.js +2 -5
- package/src/modifiers/background.js +10 -7
- package/src/modifiers/border.js +10 -7
- package/src/modifiers/colorConverter.js +13 -0
- package/src/modifiers/default.js +9 -0
- package/src/modifiers/display.js +24 -0
- package/src/modifiers/flex.js +10 -7
- package/src/modifiers/flexWrapper.js +12 -9
- package/src/modifiers/{fullColor.js.js → fullColor.js} +8 -9
- package/src/modifiers/logger.js +6 -0
- package/src/modifiers/margin.js +10 -7
- package/src/modifiers/padding.js +10 -7
- package/src/modifiers/position.js +10 -7
- package/src/modifiers/shadow.js +10 -7
- package/src/modifiers/size.js +8 -5
- package/src/modifiers/sizeConverter.js +12 -0
- package/src/modifiers/text.js +14 -13
- package/src/modifiers/textConverter.js +12 -0
- package/src/modifiers/themeComponent.js +11 -0
- package/src/theme/ThemeHandler.js +31 -33
- package/src/theme/default/base.js +13 -1
- package/src/theme/default/cyberpunkTheme.js +1 -0
- package/src/theme/default/darkTheme.js +1 -0
- package/src/theme/default/deepWoodsTheme.js +1 -0
- package/src/theme/default/forestTheme.js +1 -0
- package/src/theme/default/hackerTheme.js +32 -0
- package/src/theme/default/lightTheme.js +1 -0
- package/src/theme/default/midnightTheme.js +1 -0
- package/src/theme/default/msdosTheme.js +40 -0
- package/src/theme/default/oceanTheme.js +1 -0
- package/src/theme/default/pastelTheme.js +1 -0
- package/src/theme/default/sunsetTheme.js +1 -0
- package/src/theme/default/themes.js +4 -0
- package/src/theme/helpers/colorScale.js +11 -0
- package/src/theme/helpers/mergePreset.js +7 -0
- package/src/theme/helpers/relatedScales.js +34 -0
- package/src/theme/helpers/sizeScale.js +12 -4
- package/src/theme/helpers/textScale.js +15 -0
- package/dist/actions/Button.js +0 -1
- package/dist/actions/index.js +0 -1
- package/dist/form/Form.js +0 -1
- package/dist/form/FormGroup.js +0 -1
- package/dist/form/FormItem.js +0 -1
- package/dist/form/FormList.js +0 -1
- package/dist/form/FormWrapperComponent.js +0 -1
- package/dist/modifiers/fullColor.js.js +0 -1
- package/dist/presentation/Icon.js +0 -1
- package/dist/presentation/Tag.js +0 -1
- package/dist/presentation/index.js +0 -1
- package/dist/structure/Card.js +0 -1
- package/dist/structure/View.js +0 -1
- package/dist/text/Text.js +0 -1
- package/dist/theme/default/base.native.js +0 -1
- package/dist/theme/default/base.web.js +0 -1
- package/src/actions/Button.js +0 -48
- package/src/presentation/Icon.js +0 -14
- package/src/presentation/Tag.js +0 -32
- package/src/structure/Card.js +0 -36
- package/src/structure/View.js +0 -34
- package/src/text/Text.js +0 -20
- package/src/theme/default/base.native.js +0 -58
- package/src/theme/default/base.web.js +0 -3
- /package/dist/{form → components/form}/FormWrapperComponent.native.js +0 -0
- /package/dist/{form → components/form}/useForm.js +0 -0
- /package/dist/{structure → components/structure}/index.js +0 -0
- /package/dist/{text → components/text}/index.js +0 -0
- /package/src/{form → components/form}/Form.js +0 -0
- /package/src/{form → components/form}/FormGroup.js +0 -0
- /package/src/{form → components/form}/FormWrapperComponent.js +0 -0
- /package/src/{form → components/form}/FormWrapperComponent.native.js +0 -0
- /package/src/{form → components/form}/useForm.js +0 -0
- /package/src/{structure → components/structure}/index.js +0 -0
- /package/src/{text → components/text}/index.js +0 -0
package/src/abstractions/Icon.js
CHANGED
|
@@ -20,7 +20,29 @@ export function AbsIcon({ name, ...props }) {
|
|
|
20
20
|
}
|
|
21
21
|
}, [])
|
|
22
22
|
|
|
23
|
-
if (loading)
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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,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,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,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
|
|
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
|
|
84
|
+
{error && <Text color="red">{error}</Text>}
|
|
85
85
|
</FormListContext.Provider>
|
|
86
86
|
</FormGroup>
|
|
87
87
|
)
|
|
@@ -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,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,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
|
+
}
|