@neko-os/ui 0.0.7 → 0.0.9

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 (274) hide show
  1. package/dist/NekoUI.js +1 -1
  2. package/dist/abstractions/ActivityIndicator.native.js +1 -1
  3. package/dist/abstractions/ActivityIndicator.web.js +1 -0
  4. package/dist/abstractions/AnimatedView.js +1 -1
  5. package/dist/abstractions/BlurView.js +1 -0
  6. package/dist/abstractions/BlurView.native.js +1 -0
  7. package/dist/abstractions/BlurView.web.js +1 -0
  8. package/dist/abstractions/FlatList.js +1 -0
  9. package/dist/abstractions/FlatList.native.js +1 -0
  10. package/dist/abstractions/FlatList.web.js +1 -0
  11. package/dist/abstractions/GradientView.js +1 -0
  12. package/dist/abstractions/GradientView.native.js +1 -0
  13. package/dist/abstractions/Icon.native.js +1 -1
  14. package/dist/abstractions/ImageBackground.js +1 -0
  15. package/dist/abstractions/ImageBackground.native.js +1 -0
  16. package/dist/abstractions/ImageBackground.web.js +1 -0
  17. package/dist/abstractions/Pressable.js +1 -0
  18. package/dist/abstractions/Pressable.native.js +1 -0
  19. package/dist/abstractions/Pressable.web.js +1 -0
  20. package/dist/abstractions/ScrollView.js +1 -0
  21. package/dist/abstractions/ScrollView.native.js +1 -0
  22. package/dist/abstractions/ScrollView.web.js +1 -0
  23. package/dist/abstractions/TextInput.js +1 -1
  24. package/dist/abstractions/helpers/storage.js +1 -0
  25. package/dist/abstractions/helpers/storage.native.js +1 -0
  26. package/dist/components/actions/Button.js +1 -1
  27. package/dist/components/actions/Dropdown.js +1 -1
  28. package/dist/components/actions/Link.js +1 -1
  29. package/dist/components/actions/Pressable.js +1 -0
  30. package/dist/components/actions/index.js +1 -1
  31. package/dist/components/actions/menu/HorizontalMenu.js +1 -1
  32. package/dist/components/actions/menu/VerticalMenu.js +1 -1
  33. package/dist/components/animations/ReanimatedView.js +1 -0
  34. package/dist/components/calendar/CalendarNav.js +1 -0
  35. package/dist/components/calendar/WeekDaysBar.js +1 -0
  36. package/dist/components/calendar/_helpers/calendarDays.js +1 -1
  37. package/dist/components/calendar/_helpers/dateDisabled.js +1 -0
  38. package/dist/components/calendar/index.js +0 -1
  39. package/dist/components/feedback/alerter.js +1 -0
  40. package/dist/components/feedback/confirmer.js +1 -0
  41. package/dist/components/feedback/index.js +1 -1
  42. package/dist/components/feedback/notifications/Notification.js +1 -1
  43. package/dist/components/feedback/notifications/NotificationsHandler.js +1 -1
  44. package/dist/components/index.js +1 -1
  45. package/dist/components/inputs/DateInput.js +1 -0
  46. package/dist/components/inputs/InputWrapper.js +1 -1
  47. package/dist/components/inputs/LinkInput.js +1 -0
  48. package/dist/components/inputs/MaskInput.js +1 -0
  49. package/dist/components/inputs/TextInput.js +1 -1
  50. package/dist/components/inputs/_DateInput.native.js +1 -0
  51. package/dist/components/inputs/datePicker/DatePicker.js +1 -0
  52. package/dist/components/inputs/datePicker/DayPicker.js +1 -0
  53. package/dist/components/inputs/datePicker/MonthPicker.js +1 -0
  54. package/dist/components/inputs/datePicker/QuarterPicker.js +1 -0
  55. package/dist/components/inputs/datePicker/WeekPicker.js +1 -0
  56. package/dist/components/inputs/datePicker/YearPicker.js +1 -0
  57. package/dist/components/inputs/index.js +1 -1
  58. package/dist/components/layout/Layout.js +1 -1
  59. package/dist/components/list/FlatList.js +1 -0
  60. package/dist/components/list/ScrollView.js +1 -0
  61. package/dist/components/list/index.js +1 -0
  62. package/dist/components/presentation/ImageBackground.js +1 -0
  63. package/dist/components/presentation/Result.js +1 -1
  64. package/dist/components/presentation/index.js +1 -1
  65. package/dist/components/state/LoadingView.js +1 -1
  66. package/dist/components/structure/Accordion.js +1 -1
  67. package/dist/components/structure/BlurView.js +1 -0
  68. package/dist/components/structure/GradientView.js +1 -0
  69. package/dist/components/structure/View.js +1 -1
  70. package/dist/components/structure/bottomDrawer/index.js +1 -0
  71. package/dist/components/structure/bottomDrawer/index.native.js +1 -0
  72. package/dist/components/structure/bottomDrawer/index.web.js +1 -0
  73. package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -0
  74. package/dist/components/structure/bottomDrawer/native/DrawerContext.js +1 -0
  75. package/dist/components/structure/bottomDrawer/native/DrawerHandle.js +1 -0
  76. package/dist/components/structure/bottomDrawer/native/DrawerScrollView.js +1 -0
  77. package/dist/components/structure/bottomDrawer/native/utils.js +1 -0
  78. package/dist/components/structure/bottomDrawer/web/BottomDrawer.js +1 -0
  79. package/dist/components/structure/drawer/Drawer.js +1 -0
  80. package/dist/components/structure/drawer/Drawer.native.js +1 -0
  81. package/dist/components/structure/drawer/index.js +1 -0
  82. package/dist/components/structure/index.js +1 -1
  83. package/dist/components/structure/modal/Modal.js +1 -0
  84. package/dist/components/structure/modal/Modal.native.js +1 -0
  85. package/dist/components/structure/modal/ModalBackdrop.js +1 -0
  86. package/dist/components/structure/modal/ModalContent.js +1 -0
  87. package/dist/components/structure/modal/ModalFooter.js +1 -0
  88. package/dist/components/structure/modal/ModalHeader.js +1 -0
  89. package/dist/components/structure/modal/handler/ModalsHandler.js +1 -0
  90. package/dist/components/structure/modal/index.js +1 -0
  91. package/dist/components/structure/overlay/OverlayWrapper.js +1 -1
  92. package/dist/components/structure/popover/Popover.js +1 -1
  93. package/dist/components/structure/popover/Popover.native.js +1 -1
  94. package/dist/components/theme/ThemePicker.js +1 -0
  95. package/dist/components/theme/ThemePickerDrawer.js +1 -0
  96. package/dist/components/theme/ThemeStatusBar.js +1 -0
  97. package/dist/components/theme/ThemeStatusBar.native.js +1 -0
  98. package/dist/components/theme/ThemeThumb.js +1 -0
  99. package/dist/components/theme/index.js +1 -0
  100. package/dist/helpers/index.js +1 -1
  101. package/dist/helpers/storage.js +1 -0
  102. package/dist/modifiers/animations/animatedEffects.js +1 -1
  103. package/dist/modifiers/animations/animatedEffects.native.js +1 -1
  104. package/dist/modifiers/animations/fadeEffect.js +1 -1
  105. package/dist/modifiers/animations/scaleEffect.js +1 -0
  106. package/dist/modifiers/animations/scaleEffect.native.js +1 -0
  107. package/dist/modifiers/animations/slideEffect.js +1 -1
  108. package/dist/modifiers/background.js +1 -1
  109. package/dist/modifiers/cursor.js +1 -0
  110. package/dist/modifiers/display.js +1 -1
  111. package/dist/modifiers/fullColor.js +1 -1
  112. package/dist/modifiers/hover.js +1 -0
  113. package/dist/modifiers/position.js +1 -1
  114. package/dist/modifiers/size.js +1 -1
  115. package/dist/modifiers/state.js +1 -1
  116. package/dist/responsive/responsiveHooks.js +1 -1
  117. package/dist/theme/ThemeHandler.js +1 -1
  118. package/dist/theme/default/base.js +1 -1
  119. package/dist/theme/default/blackTheme.js +1 -0
  120. package/dist/theme/default/cyberpunkTheme.js +1 -1
  121. package/dist/theme/default/darkTheme.js +1 -1
  122. package/dist/theme/default/deepWoodsTheme.js +1 -1
  123. package/dist/theme/default/forestTheme.js +1 -1
  124. package/dist/theme/default/hackerTheme.js +1 -1
  125. package/dist/theme/default/lightTheme.js +1 -1
  126. package/dist/theme/default/midnightTheme.js +1 -1
  127. package/dist/theme/default/msdosTheme.js +1 -1
  128. package/dist/theme/default/oceanTheme.js +1 -1
  129. package/dist/theme/default/paperTheme.js +1 -0
  130. package/dist/theme/default/pastelTheme.js +1 -1
  131. package/dist/theme/default/sunsetTheme.js +1 -1
  132. package/dist/theme/default/themes.js +1 -1
  133. package/dist/theme/format/formatTheme.js +1 -1
  134. package/dist/theme/helpers/contrastColor.js +1 -1
  135. package/package.json +8 -3
  136. package/src/NekoUI.js +18 -3
  137. package/src/abstractions/ActivityIndicator.native.js +3 -4
  138. package/src/abstractions/ActivityIndicator.web.js +43 -0
  139. package/src/abstractions/AnimatedView.js +3 -3
  140. package/src/abstractions/BlurView.js +43 -0
  141. package/src/abstractions/BlurView.native.js +39 -0
  142. package/src/abstractions/BlurView.web.js +39 -0
  143. package/src/abstractions/FlatList.js +39 -0
  144. package/src/abstractions/FlatList.native.js +32 -0
  145. package/src/abstractions/FlatList.web.js +3 -0
  146. package/src/abstractions/GradientView.js +5 -0
  147. package/src/abstractions/GradientView.native.js +32 -0
  148. package/src/abstractions/Icon.native.js +4 -2
  149. package/src/abstractions/ImageBackground.js +17 -0
  150. package/src/abstractions/ImageBackground.native.js +27 -0
  151. package/src/abstractions/ImageBackground.web.js +7 -0
  152. package/src/abstractions/Pressable.js +4 -0
  153. package/src/abstractions/Pressable.native.js +3 -0
  154. package/src/abstractions/Pressable.web.js +3 -0
  155. package/src/abstractions/ScrollView.js +3 -0
  156. package/src/abstractions/ScrollView.native.js +5 -0
  157. package/src/abstractions/ScrollView.web.js +3 -0
  158. package/src/abstractions/Text.web.js +15 -0
  159. package/src/abstractions/TextInput.js +2 -2
  160. package/src/abstractions/helpers/storage.js +32 -0
  161. package/src/abstractions/helpers/storage.native.js +34 -0
  162. package/src/components/actions/Button.js +8 -0
  163. package/src/components/actions/Dropdown.js +18 -2
  164. package/src/components/actions/Link.js +16 -2
  165. package/src/components/actions/Pressable.js +38 -0
  166. package/src/components/actions/index.js +1 -0
  167. package/src/components/actions/menu/HorizontalMenu.js +2 -1
  168. package/src/components/actions/menu/VerticalMenu.js +5 -4
  169. package/src/components/animations/ReanimatedView.js +40 -0
  170. package/src/components/calendar/CalendarNav.js +67 -0
  171. package/src/components/calendar/WeekDaysBar.js +18 -0
  172. package/src/components/calendar/_helpers/calendarDays.js +1 -3
  173. package/src/components/calendar/_helpers/dateDisabled.js +24 -0
  174. package/src/components/calendar/index.js +1 -1
  175. package/src/components/feedback/alerter.js +31 -0
  176. package/src/components/feedback/confirmer.js +70 -0
  177. package/src/components/feedback/index.js +2 -0
  178. package/src/components/feedback/notifications/Notification.js +1 -1
  179. package/src/components/feedback/notifications/NotificationsHandler.js +3 -3
  180. package/src/components/index.js +2 -0
  181. package/src/components/inputs/DateInput.js +111 -0
  182. package/src/components/inputs/InputWrapper.js +18 -6
  183. package/src/components/inputs/LinkInput.js +17 -0
  184. package/src/components/inputs/MaskInput.js +67 -0
  185. package/src/components/inputs/TextInput.js +2 -2
  186. package/src/components/inputs/_DateInput.native.js +89 -0
  187. package/src/components/inputs/datePicker/DatePicker.js +24 -0
  188. package/src/components/inputs/datePicker/DayPicker.js +65 -0
  189. package/src/components/inputs/datePicker/MonthPicker.js +62 -0
  190. package/src/components/inputs/datePicker/QuarterPicker.js +65 -0
  191. package/src/components/inputs/datePicker/WeekPicker.js +74 -0
  192. package/src/components/inputs/datePicker/YearPicker.js +67 -0
  193. package/src/components/inputs/index.js +4 -0
  194. package/src/components/layout/Layout.js +1 -1
  195. package/src/components/list/FlatList.js +54 -0
  196. package/src/components/list/ScrollView.js +58 -0
  197. package/src/components/list/index.js +2 -0
  198. package/src/components/presentation/ImageBackground.js +38 -0
  199. package/src/components/presentation/Result.js +2 -2
  200. package/src/components/presentation/index.js +1 -0
  201. package/src/components/state/LoadingView.js +10 -1
  202. package/src/components/structure/Accordion.js +1 -1
  203. package/src/components/structure/BlurView.js +58 -0
  204. package/src/components/structure/GradientView.js +42 -0
  205. package/src/components/structure/View.js +2 -0
  206. package/src/components/structure/bottomDrawer/index.js +1 -0
  207. package/src/components/structure/bottomDrawer/index.native.js +4 -0
  208. package/src/components/structure/bottomDrawer/index.web.js +4 -0
  209. package/src/components/structure/bottomDrawer/native/BottomDrawer.js +242 -0
  210. package/src/components/structure/bottomDrawer/native/DrawerContext.js +21 -0
  211. package/src/components/structure/bottomDrawer/native/DrawerHandle.js +12 -0
  212. package/src/components/structure/bottomDrawer/native/DrawerScrollView.js +83 -0
  213. package/src/components/structure/bottomDrawer/native/utils.js +58 -0
  214. package/src/components/structure/bottomDrawer/web/BottomDrawer.js +3 -0
  215. package/src/components/structure/drawer/Drawer.js +5 -0
  216. package/src/components/structure/drawer/Drawer.native.js +3 -0
  217. package/src/components/structure/drawer/index.js +1 -0
  218. package/src/components/structure/index.js +5 -0
  219. package/src/components/structure/modal/Modal.js +84 -0
  220. package/src/components/structure/modal/Modal.native.js +83 -0
  221. package/src/components/structure/modal/ModalBackdrop.js +58 -0
  222. package/src/components/structure/modal/ModalContent.js +28 -0
  223. package/src/components/structure/modal/ModalFooter.js +31 -0
  224. package/src/components/structure/modal/ModalHeader.js +50 -0
  225. package/src/components/structure/modal/handler/ModalsHandler.js +61 -0
  226. package/src/components/structure/modal/index.js +6 -0
  227. package/src/components/structure/overlay/OverlayWrapper.js +1 -1
  228. package/src/components/structure/popover/Popover.js +37 -2
  229. package/src/components/structure/popover/Popover.native.js +46 -16
  230. package/src/components/theme/ThemePicker.js +49 -0
  231. package/src/components/theme/ThemePickerDrawer.js +13 -0
  232. package/src/components/theme/ThemeStatusBar.js +3 -0
  233. package/src/components/theme/ThemeStatusBar.native.js +9 -0
  234. package/src/components/theme/ThemeThumb.js +98 -0
  235. package/src/components/theme/index.js +3 -0
  236. package/src/helpers/index.js +1 -0
  237. package/src/helpers/storage.js +54 -0
  238. package/src/modifiers/animations/animatedEffects.js +2 -0
  239. package/src/modifiers/animations/animatedEffects.native.js +3 -1
  240. package/src/modifiers/animations/fadeEffect.js +4 -2
  241. package/src/modifiers/animations/scaleEffect.js +45 -0
  242. package/src/modifiers/animations/scaleEffect.native.js +33 -0
  243. package/src/modifiers/animations/slideEffect.js +3 -1
  244. package/src/modifiers/background.js +16 -4
  245. package/src/modifiers/cursor.js +21 -0
  246. package/src/modifiers/display.js +2 -2
  247. package/src/modifiers/fullColor.js +2 -2
  248. package/src/modifiers/hover.js +28 -0
  249. package/src/modifiers/position.js +24 -3
  250. package/src/modifiers/size.js +2 -1
  251. package/src/modifiers/state.js +1 -1
  252. package/src/responsive/responsiveHooks.js +7 -0
  253. package/src/theme/ThemeHandler.js +18 -2
  254. package/src/theme/default/base.js +6 -6
  255. package/src/theme/default/blackTheme.js +35 -0
  256. package/src/theme/default/cyberpunkTheme.js +4 -1
  257. package/src/theme/default/darkTheme.js +4 -1
  258. package/src/theme/default/deepWoodsTheme.js +5 -2
  259. package/src/theme/default/forestTheme.js +4 -1
  260. package/src/theme/default/hackerTheme.js +4 -1
  261. package/src/theme/default/lightTheme.js +4 -1
  262. package/src/theme/default/midnightTheme.js +4 -1
  263. package/src/theme/default/msdosTheme.js +19 -4
  264. package/src/theme/default/oceanTheme.js +5 -2
  265. package/src/theme/default/paperTheme.js +35 -0
  266. package/src/theme/default/pastelTheme.js +5 -2
  267. package/src/theme/default/sunsetTheme.js +7 -4
  268. package/src/theme/default/themes.js +9 -10
  269. package/src/theme/format/formatTheme.js +9 -3
  270. package/src/theme/helpers/contrastColor.js +49 -11
  271. package/dist/abstractions/TouchableOpacity.web.js +0 -1
  272. package/dist/components/calendar/DayPicker.js +0 -1
  273. package/src/abstractions/TouchableOpacity.web.js +0 -3
  274. package/src/components/calendar/DayPicker.js +0 -94
@@ -0,0 +1,67 @@
1
+ import React from 'react'
2
+
3
+ import { TextInput } from './TextInput'
4
+
5
+ function removeMask(value, mask = '') {
6
+ let result = ''
7
+
8
+ for (let i = 0; i < mask.length; i++) {
9
+ const maskChar = mask[i]
10
+ const valueChar = value[i]
11
+
12
+ if (!valueChar) break
13
+
14
+ if (maskChar === 'A' && /[A-Za-z]/.test(valueChar)) {
15
+ result += valueChar
16
+ } else if (maskChar === '9' && /\d/.test(valueChar)) {
17
+ result += valueChar
18
+ }
19
+ }
20
+
21
+ return result
22
+ }
23
+
24
+ function applyMask(value, mask) {
25
+ const clean = value.replace(/[^0-9A-Za-z]/g, '')
26
+ let result = ''
27
+ let index = 0
28
+
29
+ for (let i = 0; i < mask.length; i++) {
30
+ if (index >= clean.length) break
31
+ const char = mask[i]
32
+
33
+ if (char === '9' && /[0-9]/.test(clean[index])) {
34
+ result += clean[index]
35
+ index++
36
+ } else if (char === 'A' && /[A-Za-z]/.test(clean[index])) {
37
+ result += clean[index].toUpperCase()
38
+ index++
39
+ } else if (char === '9' || char === 'A') {
40
+ index++
41
+ i--
42
+ } else {
43
+ result += char
44
+ }
45
+ }
46
+
47
+ return result
48
+ }
49
+
50
+ export function MaskInput({ value = '', onChange, mask = '', useRawValue, ...props }) {
51
+ const [localValue, setLocalValue] = React.useState(applyMask(value, mask))
52
+
53
+ const handleChange = React.useCallback(
54
+ (text) => {
55
+ const masked = applyMask(text, mask)
56
+ onChange?.(useRawValue ? removeMask(masked, mask) : masked)
57
+ setLocalValue(masked)
58
+ },
59
+ [mask, onChange]
60
+ )
61
+
62
+ React.useEffect(() => {
63
+ setLocalValue(applyMask(value, mask))
64
+ }, [value])
65
+
66
+ return <TextInput value={localValue} onChange={handleChange} {...props} />
67
+ }
@@ -2,7 +2,7 @@ import { AbsTextInput } from '../../abstractions/TextInput'
2
2
  import { InputWrapper } from './InputWrapper'
3
3
  import { useColors } from '../../theme/ThemeHandler'
4
4
 
5
- export function TextInput({ value, ...props }) {
5
+ export function TextInput({ onChange, ...props }) {
6
6
  const colors = useColors()
7
7
 
8
8
  const STYLE = {
@@ -16,7 +16,7 @@ export function TextInput({ value, ...props }) {
16
16
 
17
17
  return (
18
18
  <InputWrapper {...props}>
19
- <AbsTextInput style={STYLE} placeholderTextColor={colors.text_op30} {...props} value={value} />
19
+ <AbsTextInput style={STYLE} placeholderTextColor={colors.text_op30} {...props} onChange={onChange} />
20
20
  </InputWrapper>
21
21
  )
22
22
  }
@@ -0,0 +1,89 @@
1
+ import React from 'react'
2
+ import advancedFormat from 'dayjs/esm/plugin/advancedFormat'
3
+ import dayjs from 'dayjs'
4
+ import weekOfYear from 'dayjs/esm/plugin/weekOfYear'
5
+
6
+ dayjs.extend(advancedFormat)
7
+ dayjs.extend(weekOfYear)
8
+
9
+ import { DatePicker } from './datePicker/DatePicker'
10
+ import { MaskInput } from './MaskInput'
11
+ import { Popover } from '../structure/popover/Popover'
12
+ import { isValidDate } from '../calendar/_helpers/dateDisabled'
13
+
14
+ export function getDateInputDefaultFormat(type) {
15
+ switch (type) {
16
+ case 'year':
17
+ return 'YYYY'
18
+ case 'quarter':
19
+ return 'YYYY-Q'
20
+ case 'month':
21
+ return 'YYYY-MM'
22
+ case 'week':
23
+ return 'YYYY-ww'
24
+ default:
25
+ return 'YYYY-MM-DD'
26
+ }
27
+ }
28
+
29
+ export function DateInput({ value, onChange, min, max, onCheckDisabled, placement, type = 'day', format, ...props }) {
30
+ format = format || getDateInputDefaultFormat(type)
31
+ const [inputValue, setInputValue] = React.useState('')
32
+ const [localValue, setLocalValue] = React.useState(value)
33
+
34
+ value = value || localValue
35
+
36
+ const validations = { min, max, onCheckDisabled }
37
+
38
+ const handleChange = (v) => {
39
+ if (!isValidDate(v, format, validations)) return
40
+ v = !!v ? dayjs(v) : null
41
+ setLocalValue(v)
42
+ onChange?.(v)
43
+ }
44
+
45
+ const handleChangeInput = (v) => {
46
+ setInputValue(v)
47
+ if (!isValidDate(v, format, validations)) return
48
+ handleChange(v)
49
+ }
50
+
51
+ const onBlur = () => {
52
+ if (isValidDate(inputValue, format, validations)) return
53
+ handleChange(null)
54
+ setInputValue('')
55
+ }
56
+
57
+ React.useEffect(() => {
58
+ setInputValue(!!value ? dayjs(value).format(format) : '')
59
+ }, [value])
60
+
61
+ return false
62
+ return (
63
+ <Popover
64
+ trigger="click"
65
+ placement={placement || 'bottomLeft'}
66
+ renderContent={({ onClose }) => (
67
+ <DatePicker
68
+ value={value}
69
+ onChange={(v) => {
70
+ handleChange(v)
71
+ onClose()
72
+ }}
73
+ {...validations}
74
+ type={type}
75
+ />
76
+ )}
77
+ >
78
+ <MaskInput
79
+ value={inputValue}
80
+ onChange={handleChangeInput}
81
+ suffixIcon="calendar-line"
82
+ suffixIconColor="text4"
83
+ onBlur={onBlur}
84
+ mask={format.replace(/[DMYQwW]/gi, '9')}
85
+ {...props}
86
+ />
87
+ </Popover>
88
+ )
89
+ }
@@ -0,0 +1,24 @@
1
+ import { DayPicker } from './DayPicker'
2
+ import { MonthPicker } from './MonthPicker'
3
+ import { QuarterPicker } from './QuarterPicker'
4
+ import { WeekPicker } from './WeekPicker'
5
+ import { YearPicker } from './YearPicker'
6
+
7
+ export function DatePicker({ type, ...props }) {
8
+ switch (type) {
9
+ case 'year':
10
+ return <YearPicker {...props} />
11
+
12
+ case 'quarter':
13
+ return <QuarterPicker {...props} />
14
+
15
+ case 'month':
16
+ return <MonthPicker {...props} />
17
+
18
+ case 'week':
19
+ return <WeekPicker {...props} />
20
+
21
+ default:
22
+ return <DayPicker {...props} />
23
+ }
24
+ }
@@ -0,0 +1,65 @@
1
+ import React from 'react'
2
+ import dayjs from 'dayjs'
3
+
4
+ import { CalendarNav } from '../../calendar/CalendarNav'
5
+ import { Col } from '../../structure/Col'
6
+ import { Grid } from '../../structure/Row'
7
+ import { Link } from '../../actions/Link'
8
+ import { Text } from '../../text/Text'
9
+ import { View } from '../../structure/View'
10
+ import { WeekDaysBar } from '../../calendar/WeekDaysBar'
11
+ import { isDateDisabled } from '../../calendar/_helpers/dateDisabled'
12
+ import { useCalendarDays } from '../../calendar/_helpers/calendarDays'
13
+
14
+ export function DayPicker({ value, onChange, min, max, onCheckDisabled, ...props }) {
15
+ if (!!value) value = dayjs(value)
16
+ const [localValue, setLocalValue] = React.useState(value)
17
+
18
+ React.useEffect(() => {
19
+ setLocalValue(value)
20
+ }, [value])
21
+
22
+ value = value === undefined ? localValue : value
23
+
24
+ const handleChange = (v) => {
25
+ setLocalValue(v)
26
+ onChange?.(v)
27
+ }
28
+
29
+ const [currentMonth, setCurrentMonth] = React.useState(() => dayjs(value).startOf('month'))
30
+
31
+ const { cells } = useCalendarDays(currentMonth)
32
+
33
+ return (
34
+ <View className="neko-day-picker" width={275} {...props}>
35
+ <CalendarNav value={currentMonth} onChange={setCurrentMonth} />
36
+ <WeekDaysBar />
37
+
38
+ <Grid className="neko-day-picker-days" colSpan={24 / 7} gap="sm">
39
+ {cells.map((day, i) => {
40
+ const dateVal = currentMonth.date(day)
41
+ const isActive = !!value && !!day && dateVal.isSame(value, 'day')
42
+ const disabled = isDateDisabled(dateVal, { min, max, onCheckDisabled })
43
+
44
+ return (
45
+ <Col key={day ? dateVal.format('YYYYMMDD') : i} className="day-cell" center>
46
+ <Link
47
+ ratio={1}
48
+ fullW
49
+ center
50
+ br="md"
51
+ onPress={() => !!day && handleChange(dateVal)}
52
+ bg={isActive && 'primary'}
53
+ disabled={disabled}
54
+ >
55
+ <Text sm text2 center strong={isActive}>
56
+ {day || ''}
57
+ </Text>
58
+ </Link>
59
+ </Col>
60
+ )
61
+ })}
62
+ </Grid>
63
+ </View>
64
+ )
65
+ }
@@ -0,0 +1,62 @@
1
+ import React from 'react'
2
+ import dayjs from 'dayjs'
3
+
4
+ import { CalendarNav } from '../../calendar/CalendarNav'
5
+ import { Col } from '../../structure/Col'
6
+ import { Divider } from '../../helpers'
7
+ import { Grid } from '../../structure/Row'
8
+ import { Link } from '../../actions/Link'
9
+ import { Text } from '../../text/Text'
10
+ import { View } from '../../structure/View'
11
+ import { isDateDisabled } from '../../calendar/_helpers/dateDisabled'
12
+
13
+ const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
14
+
15
+ export function MonthPicker({ value, onChange, min, max, onCheckDisabled, ...props }) {
16
+ const [localValue, setLocalValue] = React.useState(value)
17
+ value = value === undefined ? localValue : value
18
+
19
+ React.useEffect(() => {
20
+ setLocalValue(value)
21
+ }, [value?.month?.(), value?.year?.()])
22
+
23
+ const handleChange = (v) => {
24
+ const newValue = v.startOf('month')
25
+ setLocalValue(newValue)
26
+ onChange?.(newValue)
27
+ }
28
+
29
+ const [currentYear, setCurrentYear] = React.useState(() => dayjs(value).startOf('year'))
30
+
31
+ return (
32
+ <View className="neko-day-picker" width={275} {...props}>
33
+ <CalendarNav value={currentYear} onChange={setCurrentYear} level="year" />
34
+ <Divider />
35
+
36
+ <Grid colSpan={8} gap="xs">
37
+ {months.map((month) => {
38
+ const dateVal = currentYear.month(month)
39
+ const isActive = !!value && dateVal.isSame(value, 'week')
40
+ const disabled = isDateDisabled(dateVal, { min, max, onCheckDisabled })
41
+
42
+ return (
43
+ <Col key={month}>
44
+ <Link
45
+ fullW
46
+ br="md"
47
+ padding="sm"
48
+ onPress={() => handleChange(dateVal)}
49
+ bg={isActive && 'primary'}
50
+ disabled={disabled}
51
+ >
52
+ <Text text2={!isActive} strong={isActive} center>
53
+ {dateVal.format('MMM')}
54
+ </Text>
55
+ </Link>
56
+ </Col>
57
+ )
58
+ })}
59
+ </Grid>
60
+ </View>
61
+ )
62
+ }
@@ -0,0 +1,65 @@
1
+ import React from 'react'
2
+ import dayjs from 'dayjs'
3
+ import quarterOfYear from 'dayjs/esm/plugin/quarterOfYear'
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
+ dayjs.extend(quarterOfYear)
15
+
16
+ const quarters = [1, 2, 3, 4]
17
+
18
+ export function QuarterPicker({ value, onChange, min, max, onCheckDisabled, ...props }) {
19
+ const [localValue, setLocalValue] = React.useState(value)
20
+ value = value === undefined ? localValue : value
21
+
22
+ React.useEffect(() => {
23
+ setLocalValue(value)
24
+ }, [value?.quarter?.(), value?.year?.()])
25
+
26
+ const handleChange = (v) => {
27
+ const newValue = v.startOf('quarter')
28
+ setLocalValue(newValue)
29
+ onChange?.(newValue)
30
+ }
31
+
32
+ const [currentYear, setCurrentYear] = React.useState(() => dayjs(value).startOf('year'))
33
+
34
+ return (
35
+ <View className="neko-day-picker" width={275} {...props}>
36
+ <CalendarNav value={currentYear} onChange={setCurrentYear} level="year" />
37
+ <Divider />
38
+
39
+ <Grid colSpan={6} gap="xs">
40
+ {quarters.map((quarter) => {
41
+ const dateVal = currentYear.quarter(quarter)
42
+ const isActive = !!value && dateVal.isSame(value, 'week')
43
+ const disabled = isDateDisabled(dateVal, { min, max, onCheckDisabled })
44
+
45
+ return (
46
+ <Col key={quarter}>
47
+ <Link
48
+ fullW
49
+ br="md"
50
+ padding="sm"
51
+ onPress={() => handleChange(dateVal)}
52
+ bg={isActive && 'primary'}
53
+ disabled={disabled}
54
+ >
55
+ <Text text2={!isActive} strong={isActive} center>
56
+ Q{dateVal.quarter()}
57
+ </Text>
58
+ </Link>
59
+ </Col>
60
+ )
61
+ })}
62
+ </Grid>
63
+ </View>
64
+ )
65
+ }
@@ -0,0 +1,74 @@
1
+ import { splitEvery, identity } 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 { Link } from '../../actions/Link'
8
+ import { Row } from '../../structure/Row'
9
+ import { Text } from '../../text/Text'
10
+ import { View } from '../../structure/View'
11
+ import { WeekDaysBar } from '../../calendar/WeekDaysBar'
12
+ import { isDateDisabled } from '../../calendar/_helpers/dateDisabled'
13
+ import { useCalendarDays } from '../../calendar/_helpers/calendarDays'
14
+
15
+ export function WeekPicker({ value, onChange, min, max, onCheckDisabled, ...props }) {
16
+ const [localValue, setLocalValue] = React.useState(value)
17
+ value = value === undefined ? localValue : value
18
+
19
+ React.useEffect(() => {
20
+ setLocalValue(value)
21
+ }, [value?.day?.(), value?.month?.(), value?.year?.()])
22
+
23
+ const handleChange = (v) => {
24
+ const newValue = v.startOf('week')
25
+ setLocalValue(newValue)
26
+ onChange?.(newValue)
27
+ }
28
+
29
+ const [currentMonth, setCurrentMonth] = React.useState(() => dayjs(value).startOf('month'))
30
+
31
+ const { cells } = useCalendarDays(currentMonth)
32
+ const weeks = splitEvery(7, cells)
33
+
34
+ return (
35
+ <View className="neko-day-picker" width={275} {...props}>
36
+ <CalendarNav value={currentMonth} onChange={setCurrentMonth} />
37
+ <WeekDaysBar />
38
+
39
+ <View colSpan={24 / 7} gap="sm">
40
+ {weeks.map((week, wi) => {
41
+ const firstDay = week.find(identity)
42
+ const dateVal = currentMonth.date(firstDay)
43
+ const isActive = !!value && !!firstDay && dateVal.isSame(value, 'week')
44
+ const disabled = isDateDisabled(dateVal, { min, max, onCheckDisabled })
45
+
46
+ return (
47
+ <Link
48
+ key={firstDay ? dateVal.format('YYYYMMDD') : wi}
49
+ fullW
50
+ br="md"
51
+ onPress={() => !!firstDay && handleChange(dateVal)}
52
+ bg={isActive && 'primary'}
53
+ disabled={disabled}
54
+ >
55
+ <Row colSpan={24 / 7} gap="sm">
56
+ {week.map((day, i) => {
57
+ const dateVal = currentMonth.date(day)
58
+
59
+ return (
60
+ <Col key={day ? dateVal.format('YYYYMMDD') : i} className="day-cell" center ratio={1}>
61
+ <Text sm text2 center strong={isActive}>
62
+ {day || ''}
63
+ </Text>
64
+ </Col>
65
+ )
66
+ })}
67
+ </Row>
68
+ </Link>
69
+ )
70
+ })}
71
+ </View>
72
+ </View>
73
+ )
74
+ }
@@ -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'
@@ -32,7 +32,7 @@ export function Layout({ children, ...rootProps }) {
32
32
 
33
33
  return (
34
34
  <LayoutContext.Provider value={value}>
35
- <View className="neko-layout" bg="bg" flex relative {...rootProps} ref={layoutRef}>
35
+ <View className="neko-layout" bg="mainBG" flex relative {...rootProps} ref={layoutRef}>
36
36
  {children}
37
37
  </View>
38
38
  </LayoutContext.Provider>
@@ -0,0 +1,54 @@
1
+ import { pipe } from 'ramda'
2
+
3
+ import { AbsFlatList } from '../../abstractions/FlatList'
4
+ import { useAnimationModifier } from '../../modifiers/animation'
5
+ import { useBackgroundModifier } from '../../modifiers/background'
6
+ import { useBorderModifier } from '../../modifiers/border'
7
+ import { useDefaultModifier } from '../../modifiers/default'
8
+ import { useDisplayModifier } from '../../modifiers/display'
9
+ import { useFlexModifier } from '../../modifiers/flex'
10
+ import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
11
+ import { useMarginModifier } from '../../modifiers/margin'
12
+ import { useOverflowModifier } from '../../modifiers/overflow'
13
+ import { usePaddingModifier } from '../../modifiers/padding'
14
+ import { usePositionModifier } from '../../modifiers/position'
15
+ import { useShadowModifier } from '../../modifiers/shadow'
16
+ import { useSizeModifier } from '../../modifiers/size'
17
+ import { useStateModifier } from '../../modifiers/state'
18
+ import { useThemeComponentModifier } from '../../modifiers/themeComponent'
19
+
20
+ const DEFAULT_PROPS = ([_, { horizontal }]) => {
21
+ const overflowKey = horizontal ? 'scrollX' : 'scrollY'
22
+
23
+ return {
24
+ [overflowKey]: true,
25
+ row: !!horizontal,
26
+ }
27
+ }
28
+
29
+ export function FlatList({ children, ...rootProps }) {
30
+ const [_, props] = pipe(
31
+ useThemeComponentModifier('FlatList'),
32
+ useDefaultModifier(DEFAULT_PROPS),
33
+ useFlexWrapperModifier,
34
+ useDisplayModifier,
35
+ useAnimationModifier,
36
+ useStateModifier,
37
+ useSizeModifier,
38
+ usePositionModifier,
39
+ useOverflowModifier,
40
+ usePaddingModifier,
41
+ useMarginModifier,
42
+ useFlexModifier,
43
+ useBackgroundModifier,
44
+ useBorderModifier,
45
+ useShadowModifier
46
+ )([{}, rootProps])
47
+ // useNormalView = useResponsiveValue(useNormalView)
48
+
49
+ return (
50
+ <AbsFlatList className="neko-flat-list" {...props}>
51
+ {children}
52
+ </AbsFlatList>
53
+ )
54
+ }
@@ -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,2 @@
1
+ export * from './ScrollView'
2
+ export * from './FlatList'