@neko-os/ui 0.0.7 → 0.0.8

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 (217) hide show
  1. package/dist/NekoUI.js +1 -1
  2. package/dist/abstractions/AnimatedView.js +1 -1
  3. package/dist/abstractions/BlurView.js +1 -0
  4. package/dist/abstractions/BlurView.native.js +1 -0
  5. package/dist/abstractions/GradientView.js +1 -0
  6. package/dist/abstractions/GradientView.native.js +1 -0
  7. package/dist/abstractions/Icon.native.js +1 -1
  8. package/dist/abstractions/ImageBackground.js +1 -0
  9. package/dist/abstractions/ImageBackground.native.js +1 -0
  10. package/dist/abstractions/ImageBackground.web.js +1 -0
  11. package/dist/abstractions/Pressable.js +1 -0
  12. package/dist/abstractions/Pressable.native.js +1 -0
  13. package/dist/abstractions/Pressable.web.js +1 -0
  14. package/dist/abstractions/ScrollView.js +1 -0
  15. package/dist/abstractions/ScrollView.native.js +1 -0
  16. package/dist/abstractions/TextInput.js +1 -1
  17. package/dist/components/actions/Button.js +1 -1
  18. package/dist/components/actions/Dropdown.js +1 -1
  19. package/dist/components/actions/Link.js +1 -1
  20. package/dist/components/actions/Pressable.js +1 -0
  21. package/dist/components/actions/index.js +1 -1
  22. package/dist/components/actions/menu/HorizontalMenu.js +1 -1
  23. package/dist/components/actions/menu/VerticalMenu.js +1 -1
  24. package/dist/components/animations/ReanimatedView.js +1 -0
  25. package/dist/components/calendar/CalendarNav.js +1 -0
  26. package/dist/components/calendar/WeekDaysBar.js +1 -0
  27. package/dist/components/calendar/_helpers/calendarDays.js +1 -1
  28. package/dist/components/calendar/_helpers/dateDisabled.js +1 -0
  29. package/dist/components/calendar/index.js +0 -1
  30. package/dist/components/feedback/alerter.js +1 -0
  31. package/dist/components/feedback/confirmer.js +1 -0
  32. package/dist/components/feedback/index.js +1 -1
  33. package/dist/components/feedback/notifications/Notification.js +1 -1
  34. package/dist/components/feedback/notifications/NotificationsHandler.js +1 -1
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/inputs/DateInput.js +1 -0
  37. package/dist/components/inputs/InputWrapper.js +1 -1
  38. package/dist/components/inputs/LinkInput.js +1 -0
  39. package/dist/components/inputs/MaskInput.js +1 -0
  40. package/dist/components/inputs/TextInput.js +1 -1
  41. package/dist/components/inputs/_DateInput.native.js +1 -0
  42. package/dist/components/inputs/datePicker/DatePicker.js +1 -0
  43. package/dist/components/inputs/datePicker/DayPicker.js +1 -0
  44. package/dist/components/inputs/datePicker/MonthPicker.js +1 -0
  45. package/dist/components/inputs/datePicker/QuarterPicker.js +1 -0
  46. package/dist/components/inputs/datePicker/WeekPicker.js +1 -0
  47. package/dist/components/inputs/datePicker/YearPicker.js +1 -0
  48. package/dist/components/inputs/index.js +1 -1
  49. package/dist/components/list/ScrollView.js +1 -0
  50. package/dist/components/list/index.js +1 -0
  51. package/dist/components/presentation/ImageBackground.js +1 -0
  52. package/dist/components/presentation/Result.js +1 -1
  53. package/dist/components/presentation/index.js +1 -1
  54. package/dist/components/structure/Accordion.js +1 -1
  55. package/dist/components/structure/BlurView.js +1 -0
  56. package/dist/components/structure/GradientView.js +1 -0
  57. package/dist/components/structure/bottomDrawer/index.js +1 -0
  58. package/dist/components/structure/bottomDrawer/index.native.js +1 -0
  59. package/dist/components/structure/bottomDrawer/index.web.js +1 -0
  60. package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -0
  61. package/dist/components/structure/bottomDrawer/native/DrawerContext.js +1 -0
  62. package/dist/components/structure/bottomDrawer/native/DrawerHandle.js +1 -0
  63. package/dist/components/structure/bottomDrawer/native/DrawerScrollView.js +1 -0
  64. package/dist/components/structure/bottomDrawer/native/utils.js +1 -0
  65. package/dist/components/structure/bottomDrawer/web/BottomDrawer.js +1 -0
  66. package/dist/components/structure/drawer/Drawer.js +1 -0
  67. package/dist/components/structure/drawer/Drawer.native.js +1 -0
  68. package/dist/components/structure/drawer/index.js +1 -0
  69. package/dist/components/structure/index.js +1 -1
  70. package/dist/components/structure/modal/Modal.js +1 -0
  71. package/dist/components/structure/modal/Modal.native.js +1 -0
  72. package/dist/components/structure/modal/ModalBackdrop.js +1 -0
  73. package/dist/components/structure/modal/ModalContent.js +1 -0
  74. package/dist/components/structure/modal/ModalFooter.js +1 -0
  75. package/dist/components/structure/modal/ModalHeader.js +1 -0
  76. package/dist/components/structure/modal/handler/ModalsHandler.js +1 -0
  77. package/dist/components/structure/modal/index.js +1 -0
  78. package/dist/components/structure/overlay/OverlayWrapper.js +1 -1
  79. package/dist/components/structure/popover/Popover.js +1 -1
  80. package/dist/components/structure/popover/Popover.native.js +1 -1
  81. package/dist/modifiers/animations/animatedEffects.js +1 -1
  82. package/dist/modifiers/animations/animatedEffects.native.js +1 -1
  83. package/dist/modifiers/animations/fadeEffect.js +1 -1
  84. package/dist/modifiers/animations/scaleEffect.js +1 -0
  85. package/dist/modifiers/animations/scaleEffect.native.js +1 -0
  86. package/dist/modifiers/animations/slideEffect.js +1 -1
  87. package/dist/modifiers/background.js +1 -1
  88. package/dist/modifiers/cursor.js +1 -0
  89. package/dist/modifiers/display.js +1 -1
  90. package/dist/modifiers/hover.js +1 -0
  91. package/dist/modifiers/position.js +1 -1
  92. package/dist/modifiers/size.js +1 -1
  93. package/dist/modifiers/state.js +1 -1
  94. package/dist/responsive/responsiveHooks.js +1 -1
  95. package/dist/theme/default/blackTheme.js +1 -0
  96. package/dist/theme/default/cyberpunkTheme.js +1 -1
  97. package/dist/theme/default/darkTheme.js +1 -1
  98. package/dist/theme/default/deepWoodsTheme.js +1 -1
  99. package/dist/theme/default/forestTheme.js +1 -1
  100. package/dist/theme/default/hackerTheme.js +1 -1
  101. package/dist/theme/default/lightTheme.js +1 -1
  102. package/dist/theme/default/midnightTheme.js +1 -1
  103. package/dist/theme/default/msdosTheme.js +1 -1
  104. package/dist/theme/default/oceanTheme.js +1 -1
  105. package/dist/theme/default/pastelTheme.js +1 -1
  106. package/dist/theme/default/sunsetTheme.js +1 -1
  107. package/dist/theme/default/themes.js +1 -1
  108. package/package.json +8 -3
  109. package/src/NekoUI.js +6 -3
  110. package/src/abstractions/AnimatedView.js +3 -3
  111. package/src/abstractions/BlurView.js +43 -0
  112. package/src/abstractions/BlurView.native.js +39 -0
  113. package/src/abstractions/GradientView.js +5 -0
  114. package/src/abstractions/GradientView.native.js +32 -0
  115. package/src/abstractions/Icon.native.js +4 -2
  116. package/src/abstractions/ImageBackground.js +17 -0
  117. package/src/abstractions/ImageBackground.native.js +27 -0
  118. package/src/abstractions/ImageBackground.web.js +7 -0
  119. package/src/abstractions/Pressable.js +4 -0
  120. package/src/abstractions/Pressable.native.js +3 -0
  121. package/src/abstractions/Pressable.web.js +3 -0
  122. package/src/abstractions/ScrollView.js +3 -0
  123. package/src/abstractions/ScrollView.native.js +5 -0
  124. package/src/abstractions/TextInput.js +2 -2
  125. package/src/components/actions/Button.js +7 -0
  126. package/src/components/actions/Dropdown.js +2 -1
  127. package/src/components/actions/Link.js +16 -2
  128. package/src/components/actions/Pressable.js +38 -0
  129. package/src/components/actions/index.js +1 -0
  130. package/src/components/actions/menu/HorizontalMenu.js +2 -1
  131. package/src/components/actions/menu/VerticalMenu.js +4 -3
  132. package/src/components/animations/ReanimatedView.js +40 -0
  133. package/src/components/calendar/CalendarNav.js +67 -0
  134. package/src/components/calendar/WeekDaysBar.js +18 -0
  135. package/src/components/calendar/_helpers/calendarDays.js +1 -3
  136. package/src/components/calendar/_helpers/dateDisabled.js +24 -0
  137. package/src/components/calendar/index.js +1 -1
  138. package/src/components/feedback/alerter.js +31 -0
  139. package/src/components/feedback/confirmer.js +70 -0
  140. package/src/components/feedback/index.js +2 -0
  141. package/src/components/feedback/notifications/Notification.js +1 -1
  142. package/src/components/feedback/notifications/NotificationsHandler.js +3 -3
  143. package/src/components/index.js +1 -0
  144. package/src/components/inputs/DateInput.js +111 -0
  145. package/src/components/inputs/InputWrapper.js +18 -6
  146. package/src/components/inputs/LinkInput.js +17 -0
  147. package/src/components/inputs/MaskInput.js +67 -0
  148. package/src/components/inputs/TextInput.js +2 -2
  149. package/src/components/inputs/_DateInput.native.js +89 -0
  150. package/src/components/inputs/datePicker/DatePicker.js +24 -0
  151. package/src/components/inputs/datePicker/DayPicker.js +65 -0
  152. package/src/components/inputs/datePicker/MonthPicker.js +62 -0
  153. package/src/components/inputs/datePicker/QuarterPicker.js +65 -0
  154. package/src/components/inputs/datePicker/WeekPicker.js +74 -0
  155. package/src/components/inputs/datePicker/YearPicker.js +67 -0
  156. package/src/components/inputs/index.js +4 -0
  157. package/src/components/list/ScrollView.js +58 -0
  158. package/src/components/list/index.js +1 -0
  159. package/src/components/presentation/ImageBackground.js +38 -0
  160. package/src/components/presentation/Result.js +2 -2
  161. package/src/components/presentation/index.js +1 -0
  162. package/src/components/structure/Accordion.js +1 -1
  163. package/src/components/structure/BlurView.js +58 -0
  164. package/src/components/structure/GradientView.js +42 -0
  165. package/src/components/structure/bottomDrawer/index.js +1 -0
  166. package/src/components/structure/bottomDrawer/index.native.js +4 -0
  167. package/src/components/structure/bottomDrawer/index.web.js +4 -0
  168. package/src/components/structure/bottomDrawer/native/BottomDrawer.js +229 -0
  169. package/src/components/structure/bottomDrawer/native/DrawerContext.js +21 -0
  170. package/src/components/structure/bottomDrawer/native/DrawerHandle.js +12 -0
  171. package/src/components/structure/bottomDrawer/native/DrawerScrollView.js +83 -0
  172. package/src/components/structure/bottomDrawer/native/utils.js +58 -0
  173. package/src/components/structure/bottomDrawer/web/BottomDrawer.js +3 -0
  174. package/src/components/structure/drawer/Drawer.js +5 -0
  175. package/src/components/structure/drawer/Drawer.native.js +3 -0
  176. package/src/components/structure/drawer/index.js +1 -0
  177. package/src/components/structure/index.js +5 -0
  178. package/src/components/structure/modal/Modal.js +84 -0
  179. package/src/components/structure/modal/Modal.native.js +83 -0
  180. package/src/components/structure/modal/ModalBackdrop.js +58 -0
  181. package/src/components/structure/modal/ModalContent.js +28 -0
  182. package/src/components/structure/modal/ModalFooter.js +31 -0
  183. package/src/components/structure/modal/ModalHeader.js +50 -0
  184. package/src/components/structure/modal/handler/ModalsHandler.js +61 -0
  185. package/src/components/structure/modal/index.js +6 -0
  186. package/src/components/structure/overlay/OverlayWrapper.js +1 -1
  187. package/src/components/structure/popover/Popover.js +28 -2
  188. package/src/components/structure/popover/Popover.native.js +44 -15
  189. package/src/modifiers/animations/animatedEffects.js +2 -0
  190. package/src/modifiers/animations/animatedEffects.native.js +3 -1
  191. package/src/modifiers/animations/fadeEffect.js +4 -2
  192. package/src/modifiers/animations/scaleEffect.js +45 -0
  193. package/src/modifiers/animations/scaleEffect.native.js +33 -0
  194. package/src/modifiers/animations/slideEffect.js +3 -1
  195. package/src/modifiers/background.js +16 -4
  196. package/src/modifiers/cursor.js +21 -0
  197. package/src/modifiers/display.js +2 -2
  198. package/src/modifiers/hover.js +28 -0
  199. package/src/modifiers/position.js +24 -3
  200. package/src/modifiers/size.js +2 -1
  201. package/src/modifiers/state.js +1 -1
  202. package/src/responsive/responsiveHooks.js +7 -0
  203. package/src/theme/default/blackTheme.js +32 -0
  204. package/src/theme/default/cyberpunkTheme.js +1 -0
  205. package/src/theme/default/darkTheme.js +1 -0
  206. package/src/theme/default/deepWoodsTheme.js +1 -0
  207. package/src/theme/default/forestTheme.js +1 -0
  208. package/src/theme/default/hackerTheme.js +1 -0
  209. package/src/theme/default/lightTheme.js +1 -0
  210. package/src/theme/default/midnightTheme.js +1 -0
  211. package/src/theme/default/msdosTheme.js +1 -0
  212. package/src/theme/default/oceanTheme.js +1 -0
  213. package/src/theme/default/pastelTheme.js +2 -1
  214. package/src/theme/default/sunsetTheme.js +2 -1
  215. package/src/theme/default/themes.js +2 -0
  216. package/dist/components/calendar/DayPicker.js +0 -1
  217. package/src/components/calendar/DayPicker.js +0 -94
@@ -0,0 +1,67 @@
1
+ import { range } from 'ramda'
2
+ import React from 'react'
3
+ import dayjs from 'dayjs'
4
+
5
+ import { CalendarNav } from '../../calendar/CalendarNav'
6
+ import { Col } from '../../structure/Col'
7
+ import { Divider } from '../../helpers'
8
+ import { Grid } from '../../structure/Row'
9
+ import { Link } from '../../actions/Link'
10
+ import { Text } from '../../text/Text'
11
+ import { View } from '../../structure/View'
12
+ import { isDateDisabled } from '../../calendar/_helpers/dateDisabled'
13
+
14
+ export function YearPicker({ value, onChange, min, max, onCheckDisabled, ...props }) {
15
+ const [localValue, setLocalValue] = React.useState(value)
16
+ value = value === undefined ? localValue : value
17
+
18
+ React.useEffect(() => {
19
+ setLocalValue(value)
20
+ }, [value?.year?.()])
21
+
22
+ const handleChange = (v) => {
23
+ const newValue = v.startOf('year')
24
+ setLocalValue(newValue)
25
+ onChange?.(newValue)
26
+ }
27
+
28
+ const [currentDecade, setCurrentDecade] = React.useState(() => {
29
+ const year = dayjs(value).year()
30
+ const decadeStartYear = Math.floor(year / 10) * 10
31
+ return dayjs().year(decadeStartYear).startOf('year')
32
+ })
33
+
34
+ const years = range(currentDecade.year(), currentDecade.year() + 10)
35
+
36
+ return (
37
+ <View className="neko-day-picker" width={275} {...props}>
38
+ <CalendarNav value={currentDecade} onChange={setCurrentDecade} level="decade" />
39
+ <Divider />
40
+
41
+ <Grid colSpan={12} gap="xs">
42
+ {years.map((year) => {
43
+ const dateVal = currentDecade.year(year)
44
+ const isActive = !!value && dateVal.isSame(value, 'week')
45
+ const disabled = isDateDisabled(dateVal, { min, max, onCheckDisabled })
46
+
47
+ return (
48
+ <Col key={year}>
49
+ <Link
50
+ fullW
51
+ br="md"
52
+ padding="sm"
53
+ onPress={() => handleChange(dateVal)}
54
+ bg={isActive && 'primary'}
55
+ disabled={disabled}
56
+ >
57
+ <Text text2={!isActive} strong={isActive} center>
58
+ {dateVal.year()}
59
+ </Text>
60
+ </Link>
61
+ </Col>
62
+ )
63
+ })}
64
+ </Grid>
65
+ </View>
66
+ )
67
+ }
@@ -3,4 +3,8 @@ export * from './Radio'
3
3
  export * from './Switch'
4
4
  export * from './InputWrapper'
5
5
  export * from './TextInput'
6
+ export * from './LinkInput'
7
+ export * from './MaskInput'
8
+ export * from './DateInput'
9
+ export * from './datePicker/DatePicker'
6
10
  export * from './Picker'
@@ -0,0 +1,58 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsScrollView } from '../../abstractions/ScrollView'
4
+ import { View } from '../structure/View'
5
+ import { useAnimationModifier } from '../../modifiers/animation'
6
+ import { useBackgroundModifier } from '../../modifiers/background'
7
+ import { useBorderModifier } from '../../modifiers/border'
8
+ import { useDefaultModifier } from '../../modifiers/default'
9
+ import { useDisplayModifier } from '../../modifiers/display'
10
+ import { useFlexModifier } from '../../modifiers/flex'
11
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
12
+ import { useMarginModifier } from '../../modifiers/margin'
13
+ import { useOverflowModifier } from '../../modifiers/overflow'
14
+ import { usePaddingModifier } from '../../modifiers/padding'
15
+ import { usePositionModifier } from '../../modifiers/position'
16
+ import { useResponsiveValue } from '../../responsive'
17
+ import { useShadowModifier } from '../../modifiers/shadow'
18
+ import { useSizeModifier } from '../../modifiers/size'
19
+ import { useStateModifier } from '../../modifiers/state'
20
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
21
+
22
+ const DEFAULT_PROPS = ([_, { horizontal }]) => {
23
+ const overflowKey = horizontal ? 'scrollX' : 'scrollY'
24
+
25
+ return {
26
+ [overflowKey]: true,
27
+ row: !!horizontal,
28
+ }
29
+ }
30
+
31
+ export function ScrollView({ children, useNormalView, ...rootProps }) {
32
+ const [_, props] = pipe(
33
+ useThemeComponentModifier('ScrollView'),
34
+ useDefaultModifier(DEFAULT_PROPS),
35
+ useFlexWrapperModifier,
36
+ useDisplayModifier,
37
+ useAnimationModifier,
38
+ useStateModifier,
39
+ useSizeModifier,
40
+ usePositionModifier,
41
+ useOverflowModifier,
42
+ usePaddingModifier,
43
+ useMarginModifier,
44
+ useFlexModifier,
45
+ useBackgroundModifier,
46
+ useBorderModifier,
47
+ useShadowModifier
48
+ )([{}, rootProps])
49
+ useNormalView = useResponsiveValue(useNormalView)
50
+
51
+ if (useNormalView) return <View {...rootProps}>{children}</View>
52
+
53
+ return (
54
+ <AbsScrollView className="neko-scroll-view" {...props}>
55
+ {children}
56
+ </AbsScrollView>
57
+ )
58
+ }
@@ -0,0 +1 @@
1
+ export * from './ScrollView'
@@ -0,0 +1,38 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsImageBackground } from '../../abstractions/ImageBackground'
4
+ import { useAnimationModifier } from '../../modifiers/animation'
5
+ import { useBackgroundModifier } from '../../modifiers/background'
6
+ import { useBorderModifier } from '../../modifiers/border'
7
+ import { useDisplayModifier } from '../../modifiers/display'
8
+ import { useFlexModifier } from '../../modifiers/flex'
9
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
10
+ import { useMarginModifier } from '../../modifiers/margin'
11
+ import { useOverflowModifier } from '../../modifiers/overflow'
12
+ import { usePaddingModifier } from '../../modifiers/padding'
13
+ import { usePositionModifier } from '../../modifiers/position'
14
+ import { useShadowModifier } from '../../modifiers/shadow'
15
+ import { useSizeModifier } from '../../modifiers/size'
16
+ import { useStateModifier } from '../../modifiers/state'
17
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
18
+
19
+ export function ImageBackground({ ...rootProps }) {
20
+ const [_, props] = pipe(
21
+ useThemeComponentModifier('ImageBackground'),
22
+ useFlexWrapperModifier,
23
+ useDisplayModifier,
24
+ useAnimationModifier,
25
+ useStateModifier,
26
+ useSizeModifier,
27
+ usePositionModifier,
28
+ useOverflowModifier,
29
+ usePaddingModifier,
30
+ useMarginModifier,
31
+ useFlexModifier,
32
+ useBackgroundModifier,
33
+ useBorderModifier,
34
+ useShadowModifier
35
+ )([{}, rootProps])
36
+
37
+ return <AbsImageBackground className="neko-image-background" {...props} />
38
+ }
@@ -44,8 +44,8 @@ export function Result({
44
44
 
45
45
  return (
46
46
  <View className="neko-result" center padding="lg" {...props}>
47
- <Icon name={icon} color={iconColor} size={42} primary {...iconProps} />
48
- <Divider height={10} />
47
+ {!!icon && <Icon name={icon} color={iconColor} size={42} primary {...iconProps} />}
48
+ {!!icon && <Divider height={10} />}
49
49
  <Text h3 {...textProps} {...titleProps}>
50
50
  {title}
51
51
  </Text>
@@ -8,4 +8,5 @@ export * from './Badge'
8
8
  export * from './Avatar'
9
9
  export * from './AvatarLabel'
10
10
  export * from './Image'
11
+ export * from './ImageBackground'
11
12
  export * from './LabelValue'
@@ -43,7 +43,7 @@ export function Accordion({ children, title, open, onChange, ...rootProps }) {
43
43
  row
44
44
  gap={moveScale(sizeCode, -2)}
45
45
  borderB={open ? props.border || true : open}
46
- borderColor={props.borderColor}
46
+ borderColor={props.borderColor || 'bg'}
47
47
  centerV
48
48
  {...headerProps}
49
49
  onPress={toggle}
@@ -0,0 +1,58 @@
1
+ import tinycolor from 'tinycolor2'
2
+ import { pipe } from 'ramda'
3
+
4
+ import { AbsBlurView } from '../../abstractions/BlurView'
5
+ import { useAnimationModifier } from '../../modifiers/animation'
6
+ import { useBackgroundModifier } from '../../modifiers/background'
7
+ import { useBorderModifier } from '../../modifiers/border'
8
+ import { useColors } from '../../theme'
9
+ import { useDefaultModifier } from '../../modifiers/default'
10
+ import { useDisplayModifier } from '../../modifiers/display'
11
+ import { useFlexModifier } from '../../modifiers/flex'
12
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
13
+ import { useMarginModifier } from '../../modifiers/margin'
14
+ import { useOverflowModifier } from '../../modifiers/overflow'
15
+ import { usePaddingModifier } from '../../modifiers/padding'
16
+ import { usePositionModifier } from '../../modifiers/position'
17
+ import { useShadowModifier } from '../../modifiers/shadow'
18
+ import { useSizeModifier } from '../../modifiers/size'
19
+ import { useStateModifier } from '../../modifiers/state'
20
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
21
+
22
+ const DEFAULT_PROPS =
23
+ (colors) =>
24
+ ([{}, {}]) => {
25
+ const isDark = tinycolor(colors?.overlayBG || colors?.bg).isDark()
26
+
27
+ return {
28
+ tint: isDark ? 'dark' : 'light',
29
+ }
30
+ }
31
+
32
+ export function BlurView({ children, ...rootProps }) {
33
+ const colors = useColors()
34
+
35
+ const [{}, props] = pipe(
36
+ useThemeComponentModifier('BlurView'),
37
+ useDefaultModifier(DEFAULT_PROPS(colors)),
38
+ useFlexWrapperModifier,
39
+ useDisplayModifier,
40
+ useAnimationModifier,
41
+ useStateModifier,
42
+ useSizeModifier,
43
+ usePositionModifier,
44
+ useOverflowModifier,
45
+ usePaddingModifier,
46
+ useMarginModifier,
47
+ useFlexModifier,
48
+ useBackgroundModifier,
49
+ useBorderModifier,
50
+ useShadowModifier
51
+ )([{}, rootProps])
52
+
53
+ return (
54
+ <AbsBlurView className="neko-blur-view" {...props}>
55
+ {children}
56
+ </AbsBlurView>
57
+ )
58
+ }
@@ -0,0 +1,42 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsGradientView } from '../../abstractions/GradientView'
4
+ import { useAnimationModifier } from '../../modifiers/animation'
5
+ import { useBackgroundModifier } from '../../modifiers/background'
6
+ import { useBorderModifier } from '../../modifiers/border'
7
+ import { useDisplayModifier } from '../../modifiers/display'
8
+ import { useFlexModifier } from '../../modifiers/flex'
9
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
10
+ import { useMarginModifier } from '../../modifiers/margin'
11
+ import { useOverflowModifier } from '../../modifiers/overflow'
12
+ import { usePaddingModifier } from '../../modifiers/padding'
13
+ import { usePositionModifier } from '../../modifiers/position'
14
+ import { useShadowModifier } from '../../modifiers/shadow'
15
+ import { useSizeModifier } from '../../modifiers/size'
16
+ import { useStateModifier } from '../../modifiers/state'
17
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
18
+
19
+ export function GradientView({ children, ...rootProps }) {
20
+ const [{ gradientColors }, props] = pipe(
21
+ useThemeComponentModifier('GradientView'),
22
+ useFlexWrapperModifier,
23
+ useDisplayModifier,
24
+ useAnimationModifier,
25
+ useStateModifier,
26
+ useSizeModifier,
27
+ usePositionModifier,
28
+ useOverflowModifier,
29
+ usePaddingModifier,
30
+ useMarginModifier,
31
+ useFlexModifier,
32
+ useBackgroundModifier,
33
+ useBorderModifier,
34
+ useShadowModifier
35
+ )([{}, rootProps])
36
+
37
+ return (
38
+ <AbsGradientView className="neko-gradient-view" colors={gradientColors} {...props}>
39
+ {children}
40
+ </AbsGradientView>
41
+ )
42
+ }
@@ -0,0 +1 @@
1
+ export { BottomDrawer } from './web/BottomDrawer'
@@ -0,0 +1,4 @@
1
+ export { BottomDrawer } from './native/BottomDrawer'
2
+ export { DrawerScrollView } from './native/DrawerScrollView'
3
+ export { DrawerHandle } from './native/DrawerHandle'
4
+ export { DrawerProvider, useDrawerContext } from './native/DrawerContext'
@@ -0,0 +1,4 @@
1
+ export { BottomDrawer } from './native/BottomDrawer'
2
+ export { DrawerScrollView } from './native/DrawerScrollView'
3
+ export { DrawerHandle } from './native/DrawerHandle'
4
+ export { DrawerProvider, useDrawerContext } from './native/DrawerContext'
@@ -0,0 +1,229 @@
1
+ import { GestureDetector, Gesture, GestureHandlerRootView } from 'react-native-gesture-handler'
2
+ import { Modal, Dimensions, StyleSheet, BackHandler, Platform } from 'react-native'
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
+ import Animated, {
5
+ useSharedValue,
6
+ useAnimatedStyle,
7
+ withSpring,
8
+ runOnJS,
9
+ useAnimatedReaction,
10
+ } from 'react-native-reanimated'
11
+ import React from 'react'
12
+
13
+ import { DrawerHandle } from './DrawerHandle'
14
+ import { DrawerProvider } from './DrawerContext'
15
+ import { Pressable } from '../../../actions/Pressable'
16
+ import { View } from '../../View'
17
+ import { normalizeSnapPoints, findClosestSnapPoint } from './utils'
18
+ import { useColors } from '../../../../theme/ThemeHandler'
19
+
20
+ function InnerContent({
21
+ children,
22
+ render,
23
+ setRender,
24
+ open,
25
+ onClose,
26
+ snapPoints = ['50%'],
27
+ useSafeArea = true,
28
+ enableOverScroll = true,
29
+ enableHandlePanningGesture = true,
30
+ enableContentPanningGesture = true,
31
+ animationConfig = {
32
+ damping: 50,
33
+ stiffness: 500,
34
+ mass: 0.3,
35
+ overshootClamping: true,
36
+ restDisplacementThreshold: 10,
37
+ restSpeedThreshold: 10,
38
+ },
39
+ hideHandle,
40
+ contentProps,
41
+ ...props
42
+ }) {
43
+ const { height: SCREEN_HEIGHT } = Dimensions.get('window')
44
+ const insets = useSafeAreaInsets()
45
+ const bottomInset = useSafeArea ? insets.bottom : 0
46
+
47
+ const colors = useColors()
48
+
49
+ const translateY = useSharedValue(SCREEN_HEIGHT)
50
+ const scrollOffset = useSharedValue(0)
51
+ const scrollEnabled = useSharedValue(false)
52
+ const isScrolling = useSharedValue(false)
53
+ const snapIndex = useSharedValue(0)
54
+ const velocityY = useSharedValue(0)
55
+
56
+ const normalizedSnapPoints = React.useMemo(() => normalizeSnapPoints(snapPoints, SCREEN_HEIGHT), [snapPoints])
57
+ const maxSnapPoint = React.useMemo(() => Math.max(...normalizedSnapPoints), [normalizedSnapPoints])
58
+ const minSnapPoint = React.useMemo(() => Math.min(...normalizedSnapPoints), [normalizedSnapPoints])
59
+
60
+ React.useEffect(() => {
61
+ if (open) {
62
+ const targetY = SCREEN_HEIGHT - normalizedSnapPoints[0]
63
+ translateY.value = withSpring(targetY, animationConfig)
64
+ snapIndex.value = 0
65
+ } else {
66
+ translateY.value = withSpring(SCREEN_HEIGHT, animationConfig, () => {
67
+ scrollOffset.value = 0
68
+ scrollEnabled.value = false
69
+ runOnJS(setRender)(false)
70
+ })
71
+ snapIndex.value = -1
72
+ }
73
+ }, [open])
74
+
75
+ React.useEffect(() => {
76
+ if (!onClose || !open || Platform.OS !== 'android') return
77
+ const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
78
+ onClose()
79
+ return true
80
+ })
81
+ return () => backHandler.remove()
82
+ }, [open, onClose])
83
+
84
+ useAnimatedReaction(
85
+ () => translateY.value,
86
+ (currentY) => {
87
+ const atMaxSnapPoint = currentY <= SCREEN_HEIGHT - maxSnapPoint
88
+ scrollEnabled.value = atMaxSnapPoint
89
+ },
90
+ []
91
+ )
92
+
93
+ let handleClose = React.useCallback(() => {
94
+ onClose?.()
95
+ }, [onClose])
96
+ if (!onClose) handleClose = false
97
+
98
+ const snapTo = React.useCallback(
99
+ (index) => {
100
+ 'worklet'
101
+ const snapPoint = normalizedSnapPoints[index]
102
+ if (snapPoint !== undefined) {
103
+ translateY.value = withSpring(SCREEN_HEIGHT - snapPoint, animationConfig)
104
+ snapIndex.value = index
105
+ }
106
+ },
107
+ [normalizedSnapPoints]
108
+ )
109
+
110
+ // contexto manual para gesto
111
+ const gestureStartTranslateY = useSharedValue(0)
112
+
113
+ const panGesture = React.useMemo(() => {
114
+ return Gesture.Pan()
115
+ .enabled(enableHandlePanningGesture || enableContentPanningGesture)
116
+ .onStart(() => {
117
+ gestureStartTranslateY.value = translateY.value
118
+ })
119
+ .onUpdate((event) => {
120
+ const newTranslateY = gestureStartTranslateY.value + event.translationY
121
+ const maxPosition = SCREEN_HEIGHT - maxSnapPoint
122
+
123
+ if (enableOverScroll && newTranslateY >= maxPosition) {
124
+ translateY.value = newTranslateY
125
+ } else {
126
+ translateY.value = Math.max(maxPosition, Math.min(SCREEN_HEIGHT, newTranslateY))
127
+ }
128
+
129
+ velocityY.value = event.velocityY
130
+ })
131
+ .onEnd(() => {
132
+ const currentPosition = SCREEN_HEIGHT - translateY.value
133
+ const shouldClose =
134
+ !!handleClose &&
135
+ ((velocityY.value > 2000 && currentPosition < minSnapPoint * 0.75) || currentPosition < minSnapPoint * 0.25)
136
+
137
+ if (shouldClose) {
138
+ runOnJS(handleClose)()
139
+ } else {
140
+ const closestSnapIndex = findClosestSnapPoint(currentPosition, normalizedSnapPoints, velocityY.value)
141
+ const targetSnapPoint = normalizedSnapPoints[closestSnapIndex]
142
+ translateY.value = withSpring(SCREEN_HEIGHT - targetSnapPoint, animationConfig)
143
+ snapIndex.value = closestSnapIndex
144
+ }
145
+ })
146
+ }, [
147
+ enableHandlePanningGesture,
148
+ enableContentPanningGesture,
149
+ enableOverScroll,
150
+ maxSnapPoint,
151
+ minSnapPoint,
152
+ normalizedSnapPoints,
153
+ animationConfig,
154
+ handleClose,
155
+ ])
156
+
157
+ const animatedSheetStyle = useAnimatedStyle(() => {
158
+ const currentHeight = SCREEN_HEIGHT - translateY.value
159
+ return {
160
+ transform: [{ translateY: translateY.value }],
161
+ maxHeight: currentHeight,
162
+ }
163
+ })
164
+
165
+ const contextValue = React.useMemo(
166
+ () => ({
167
+ translateY,
168
+ scrollOffset,
169
+ scrollEnabled,
170
+ isScrolling,
171
+ snapIndex,
172
+ maxSnapPoint,
173
+ snapTo,
174
+ animationConfig,
175
+ }),
176
+ [maxSnapPoint]
177
+ )
178
+
179
+ return (
180
+ <GestureHandlerRootView style={{ flex: 1 }}>
181
+ <Pressable
182
+ absoluteFill
183
+ bg="backdrop_op70"
184
+ onPress={() => {
185
+ if (!handleClose) return
186
+ runOnJS(handleClose)()
187
+ }}
188
+ />
189
+
190
+ <DrawerProvider value={contextValue}>
191
+ <GestureDetector gesture={panGesture}>
192
+ <Animated.View style={[styles.container, { height: SCREEN_HEIGHT }, animatedSheetStyle]}>
193
+ <View flex bg="overlayBG" shadow paddingB={useSafeArea && bottomInset} borderRadiusT="xxxl" {...props}>
194
+ <DrawerHandle hide={hideHandle} />
195
+ <View flex {...contentProps}>
196
+ {children}
197
+ </View>
198
+ </View>
199
+ </Animated.View>
200
+ </GestureDetector>
201
+ </DrawerProvider>
202
+ </GestureHandlerRootView>
203
+ )
204
+ }
205
+
206
+ const styles = StyleSheet.create({
207
+ container: {
208
+ position: 'absolute',
209
+ left: 0,
210
+ right: 0,
211
+ top: 0,
212
+ },
213
+ })
214
+
215
+ export function BottomDrawer({ open, ...props }) {
216
+ const [render, setRender] = React.useState(open)
217
+
218
+ React.useEffect(() => {
219
+ if (open) {
220
+ setRender(true)
221
+ }
222
+ }, [open])
223
+
224
+ return (
225
+ <Modal visible={render} transparent statusBarTranslucent navigationBarTranslucent animationType="none">
226
+ <InnerContent {...props} open={open} render={render} setRender={setRender} />
227
+ </Modal>
228
+ )
229
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+
3
+ const DrawerContext = React.createContext(null);
4
+
5
+ export function DrawerProvider({ children, value }) {
6
+ return (
7
+ <DrawerContext.Provider value={value}>
8
+ {children}
9
+ </DrawerContext.Provider>
10
+ );
11
+ }
12
+
13
+ export function useDrawerContext() {
14
+ const context = React.useContext(DrawerContext);
15
+
16
+ if (!context) {
17
+ throw new Error('useDrawerContext must be used within a DrawerProvider');
18
+ }
19
+
20
+ return context;
21
+ }
@@ -0,0 +1,12 @@
1
+ import { Divider } from '../../../helpers/Separator'
2
+ import { View } from '../../View'
3
+
4
+ export function DrawerHandle({ hide }) {
5
+ if (!!hide) return false
6
+
7
+ return (
8
+ <View center padding="sm">
9
+ <Divider maxWidth={35} line={4} color="text4_op30" height={4} />
10
+ </View>
11
+ )
12
+ }
@@ -0,0 +1,83 @@
1
+ import React from 'react'
2
+ import { ScrollView } from 'react-native'
3
+ import Animated, { useAnimatedScrollHandler, useAnimatedReaction, runOnJS } from 'react-native-reanimated'
4
+ import { useDrawerContext } from './DrawerContext'
5
+
6
+ const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView)
7
+
8
+ export const DrawerScrollView = React.forwardRef((props, ref) => {
9
+ const {
10
+ children,
11
+ onScroll,
12
+ scrollEventThrottle = 16,
13
+ showsVerticalScrollIndicator = true,
14
+ bounces = true,
15
+ ...scrollViewProps
16
+ } = props
17
+
18
+ const { scrollOffset, scrollEnabled, isScrolling } = useDrawerContext()
19
+
20
+ const scrollRef = React.useRef(null)
21
+
22
+ // Convert shared value to React state for the component
23
+ const [isScrollEnabled, setIsScrollEnabled] = React.useState(true)
24
+
25
+ React.useImperativeHandle(ref, () => scrollRef.current)
26
+
27
+ // Handle scroll lock/unlock based on drawer position
28
+ useAnimatedReaction(
29
+ () => scrollEnabled.value,
30
+ (enabled) => {
31
+ if (!enabled && scrollOffset.value > 0) {
32
+ runOnJS(() => {
33
+ scrollRef.current?.scrollTo({ y: 0, animated: false })
34
+ })()
35
+ scrollOffset.value = 0
36
+ }
37
+ // Update React state
38
+ runOnJS(setIsScrollEnabled)(enabled)
39
+ },
40
+ []
41
+ )
42
+
43
+ const handleScrollBeginDrag = React.useCallback(() => {
44
+ isScrolling.value = true
45
+ }, [isScrolling])
46
+
47
+ const handleScrollEndDrag = React.useCallback(() => {
48
+ isScrolling.value = false
49
+ }, [isScrolling])
50
+
51
+ const animatedScrollHandler = useAnimatedScrollHandler({
52
+ onScroll: (event) => {
53
+ scrollOffset.value = event.contentOffset.y
54
+
55
+ if (onScroll) {
56
+ runOnJS(onScroll)(event)
57
+ }
58
+ },
59
+ onBeginDrag: () => {
60
+ runOnJS(handleScrollBeginDrag)()
61
+ },
62
+ onEndDrag: () => {
63
+ runOnJS(handleScrollEndDrag)()
64
+ },
65
+ })
66
+
67
+ return (
68
+ <AnimatedScrollView
69
+ ref={scrollRef}
70
+ style={{ flex: 1 }}
71
+ scrollEnabled={isScrollEnabled}
72
+ onScroll={animatedScrollHandler}
73
+ scrollEventThrottle={scrollEventThrottle}
74
+ showsVerticalScrollIndicator={showsVerticalScrollIndicator}
75
+ bounces={bounces}
76
+ {...scrollViewProps}
77
+ >
78
+ {children}
79
+ </AnimatedScrollView>
80
+ )
81
+ })
82
+
83
+ DrawerScrollView.displayName = 'DrawerScrollView'