@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.
- package/dist/NekoUI.js +1 -1
- package/dist/abstractions/ActivityIndicator.native.js +1 -1
- package/dist/abstractions/ActivityIndicator.web.js +1 -0
- package/dist/abstractions/AnimatedView.js +1 -1
- package/dist/abstractions/BlurView.js +1 -0
- package/dist/abstractions/BlurView.native.js +1 -0
- package/dist/abstractions/BlurView.web.js +1 -0
- package/dist/abstractions/FlatList.js +1 -0
- package/dist/abstractions/FlatList.native.js +1 -0
- package/dist/abstractions/FlatList.web.js +1 -0
- package/dist/abstractions/GradientView.js +1 -0
- package/dist/abstractions/GradientView.native.js +1 -0
- package/dist/abstractions/Icon.native.js +1 -1
- package/dist/abstractions/ImageBackground.js +1 -0
- package/dist/abstractions/ImageBackground.native.js +1 -0
- package/dist/abstractions/ImageBackground.web.js +1 -0
- package/dist/abstractions/Pressable.js +1 -0
- package/dist/abstractions/Pressable.native.js +1 -0
- package/dist/abstractions/Pressable.web.js +1 -0
- package/dist/abstractions/ScrollView.js +1 -0
- package/dist/abstractions/ScrollView.native.js +1 -0
- package/dist/abstractions/ScrollView.web.js +1 -0
- package/dist/abstractions/TextInput.js +1 -1
- package/dist/abstractions/helpers/storage.js +1 -0
- package/dist/abstractions/helpers/storage.native.js +1 -0
- package/dist/components/actions/Button.js +1 -1
- package/dist/components/actions/Dropdown.js +1 -1
- package/dist/components/actions/Link.js +1 -1
- package/dist/components/actions/Pressable.js +1 -0
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/menu/HorizontalMenu.js +1 -1
- package/dist/components/actions/menu/VerticalMenu.js +1 -1
- package/dist/components/animations/ReanimatedView.js +1 -0
- package/dist/components/calendar/CalendarNav.js +1 -0
- package/dist/components/calendar/WeekDaysBar.js +1 -0
- package/dist/components/calendar/_helpers/calendarDays.js +1 -1
- package/dist/components/calendar/_helpers/dateDisabled.js +1 -0
- package/dist/components/calendar/index.js +0 -1
- package/dist/components/feedback/alerter.js +1 -0
- package/dist/components/feedback/confirmer.js +1 -0
- package/dist/components/feedback/index.js +1 -1
- package/dist/components/feedback/notifications/Notification.js +1 -1
- package/dist/components/feedback/notifications/NotificationsHandler.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/inputs/DateInput.js +1 -0
- package/dist/components/inputs/InputWrapper.js +1 -1
- package/dist/components/inputs/LinkInput.js +1 -0
- package/dist/components/inputs/MaskInput.js +1 -0
- package/dist/components/inputs/TextInput.js +1 -1
- package/dist/components/inputs/_DateInput.native.js +1 -0
- package/dist/components/inputs/datePicker/DatePicker.js +1 -0
- package/dist/components/inputs/datePicker/DayPicker.js +1 -0
- package/dist/components/inputs/datePicker/MonthPicker.js +1 -0
- package/dist/components/inputs/datePicker/QuarterPicker.js +1 -0
- package/dist/components/inputs/datePicker/WeekPicker.js +1 -0
- package/dist/components/inputs/datePicker/YearPicker.js +1 -0
- package/dist/components/inputs/index.js +1 -1
- package/dist/components/layout/Layout.js +1 -1
- package/dist/components/list/FlatList.js +1 -0
- package/dist/components/list/ScrollView.js +1 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/presentation/ImageBackground.js +1 -0
- package/dist/components/presentation/Result.js +1 -1
- package/dist/components/presentation/index.js +1 -1
- package/dist/components/state/LoadingView.js +1 -1
- package/dist/components/structure/Accordion.js +1 -1
- package/dist/components/structure/BlurView.js +1 -0
- package/dist/components/structure/GradientView.js +1 -0
- package/dist/components/structure/View.js +1 -1
- package/dist/components/structure/bottomDrawer/index.js +1 -0
- package/dist/components/structure/bottomDrawer/index.native.js +1 -0
- package/dist/components/structure/bottomDrawer/index.web.js +1 -0
- package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -0
- package/dist/components/structure/bottomDrawer/native/DrawerContext.js +1 -0
- package/dist/components/structure/bottomDrawer/native/DrawerHandle.js +1 -0
- package/dist/components/structure/bottomDrawer/native/DrawerScrollView.js +1 -0
- package/dist/components/structure/bottomDrawer/native/utils.js +1 -0
- package/dist/components/structure/bottomDrawer/web/BottomDrawer.js +1 -0
- package/dist/components/structure/drawer/Drawer.js +1 -0
- package/dist/components/structure/drawer/Drawer.native.js +1 -0
- package/dist/components/structure/drawer/index.js +1 -0
- package/dist/components/structure/index.js +1 -1
- package/dist/components/structure/modal/Modal.js +1 -0
- package/dist/components/structure/modal/Modal.native.js +1 -0
- package/dist/components/structure/modal/ModalBackdrop.js +1 -0
- package/dist/components/structure/modal/ModalContent.js +1 -0
- package/dist/components/structure/modal/ModalFooter.js +1 -0
- package/dist/components/structure/modal/ModalHeader.js +1 -0
- package/dist/components/structure/modal/handler/ModalsHandler.js +1 -0
- package/dist/components/structure/modal/index.js +1 -0
- package/dist/components/structure/overlay/OverlayWrapper.js +1 -1
- package/dist/components/structure/popover/Popover.js +1 -1
- package/dist/components/structure/popover/Popover.native.js +1 -1
- package/dist/components/theme/ThemePicker.js +1 -0
- package/dist/components/theme/ThemePickerDrawer.js +1 -0
- package/dist/components/theme/ThemeStatusBar.js +1 -0
- package/dist/components/theme/ThemeStatusBar.native.js +1 -0
- package/dist/components/theme/ThemeThumb.js +1 -0
- package/dist/components/theme/index.js +1 -0
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/storage.js +1 -0
- package/dist/modifiers/animations/animatedEffects.js +1 -1
- package/dist/modifiers/animations/animatedEffects.native.js +1 -1
- package/dist/modifiers/animations/fadeEffect.js +1 -1
- package/dist/modifiers/animations/scaleEffect.js +1 -0
- package/dist/modifiers/animations/scaleEffect.native.js +1 -0
- package/dist/modifiers/animations/slideEffect.js +1 -1
- package/dist/modifiers/background.js +1 -1
- package/dist/modifiers/cursor.js +1 -0
- package/dist/modifiers/display.js +1 -1
- package/dist/modifiers/fullColor.js +1 -1
- package/dist/modifiers/hover.js +1 -0
- package/dist/modifiers/position.js +1 -1
- package/dist/modifiers/size.js +1 -1
- package/dist/modifiers/state.js +1 -1
- package/dist/responsive/responsiveHooks.js +1 -1
- package/dist/theme/ThemeHandler.js +1 -1
- package/dist/theme/default/base.js +1 -1
- package/dist/theme/default/blackTheme.js +1 -0
- 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 -1
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/midnightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -1
- package/dist/theme/default/oceanTheme.js +1 -1
- package/dist/theme/default/paperTheme.js +1 -0
- 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/format/formatTheme.js +1 -1
- package/dist/theme/helpers/contrastColor.js +1 -1
- package/package.json +8 -3
- package/src/NekoUI.js +18 -3
- package/src/abstractions/ActivityIndicator.native.js +3 -4
- package/src/abstractions/ActivityIndicator.web.js +43 -0
- package/src/abstractions/AnimatedView.js +3 -3
- package/src/abstractions/BlurView.js +43 -0
- package/src/abstractions/BlurView.native.js +39 -0
- package/src/abstractions/BlurView.web.js +39 -0
- package/src/abstractions/FlatList.js +39 -0
- package/src/abstractions/FlatList.native.js +32 -0
- package/src/abstractions/FlatList.web.js +3 -0
- package/src/abstractions/GradientView.js +5 -0
- package/src/abstractions/GradientView.native.js +32 -0
- package/src/abstractions/Icon.native.js +4 -2
- package/src/abstractions/ImageBackground.js +17 -0
- package/src/abstractions/ImageBackground.native.js +27 -0
- package/src/abstractions/ImageBackground.web.js +7 -0
- package/src/abstractions/Pressable.js +4 -0
- package/src/abstractions/Pressable.native.js +3 -0
- package/src/abstractions/Pressable.web.js +3 -0
- package/src/abstractions/ScrollView.js +3 -0
- package/src/abstractions/ScrollView.native.js +5 -0
- package/src/abstractions/ScrollView.web.js +3 -0
- package/src/abstractions/Text.web.js +15 -0
- package/src/abstractions/TextInput.js +2 -2
- package/src/abstractions/helpers/storage.js +32 -0
- package/src/abstractions/helpers/storage.native.js +34 -0
- package/src/components/actions/Button.js +8 -0
- package/src/components/actions/Dropdown.js +18 -2
- package/src/components/actions/Link.js +16 -2
- package/src/components/actions/Pressable.js +38 -0
- package/src/components/actions/index.js +1 -0
- package/src/components/actions/menu/HorizontalMenu.js +2 -1
- package/src/components/actions/menu/VerticalMenu.js +5 -4
- package/src/components/animations/ReanimatedView.js +40 -0
- package/src/components/calendar/CalendarNav.js +67 -0
- package/src/components/calendar/WeekDaysBar.js +18 -0
- package/src/components/calendar/_helpers/calendarDays.js +1 -3
- package/src/components/calendar/_helpers/dateDisabled.js +24 -0
- package/src/components/calendar/index.js +1 -1
- package/src/components/feedback/alerter.js +31 -0
- package/src/components/feedback/confirmer.js +70 -0
- package/src/components/feedback/index.js +2 -0
- package/src/components/feedback/notifications/Notification.js +1 -1
- package/src/components/feedback/notifications/NotificationsHandler.js +3 -3
- package/src/components/index.js +2 -0
- package/src/components/inputs/DateInput.js +111 -0
- package/src/components/inputs/InputWrapper.js +18 -6
- package/src/components/inputs/LinkInput.js +17 -0
- package/src/components/inputs/MaskInput.js +67 -0
- package/src/components/inputs/TextInput.js +2 -2
- package/src/components/inputs/_DateInput.native.js +89 -0
- package/src/components/inputs/datePicker/DatePicker.js +24 -0
- package/src/components/inputs/datePicker/DayPicker.js +65 -0
- package/src/components/inputs/datePicker/MonthPicker.js +62 -0
- package/src/components/inputs/datePicker/QuarterPicker.js +65 -0
- package/src/components/inputs/datePicker/WeekPicker.js +74 -0
- package/src/components/inputs/datePicker/YearPicker.js +67 -0
- package/src/components/inputs/index.js +4 -0
- package/src/components/layout/Layout.js +1 -1
- package/src/components/list/FlatList.js +54 -0
- package/src/components/list/ScrollView.js +58 -0
- package/src/components/list/index.js +2 -0
- package/src/components/presentation/ImageBackground.js +38 -0
- package/src/components/presentation/Result.js +2 -2
- package/src/components/presentation/index.js +1 -0
- package/src/components/state/LoadingView.js +10 -1
- package/src/components/structure/Accordion.js +1 -1
- package/src/components/structure/BlurView.js +58 -0
- package/src/components/structure/GradientView.js +42 -0
- package/src/components/structure/View.js +2 -0
- package/src/components/structure/bottomDrawer/index.js +1 -0
- package/src/components/structure/bottomDrawer/index.native.js +4 -0
- package/src/components/structure/bottomDrawer/index.web.js +4 -0
- package/src/components/structure/bottomDrawer/native/BottomDrawer.js +242 -0
- package/src/components/structure/bottomDrawer/native/DrawerContext.js +21 -0
- package/src/components/structure/bottomDrawer/native/DrawerHandle.js +12 -0
- package/src/components/structure/bottomDrawer/native/DrawerScrollView.js +83 -0
- package/src/components/structure/bottomDrawer/native/utils.js +58 -0
- package/src/components/structure/bottomDrawer/web/BottomDrawer.js +3 -0
- package/src/components/structure/drawer/Drawer.js +5 -0
- package/src/components/structure/drawer/Drawer.native.js +3 -0
- package/src/components/structure/drawer/index.js +1 -0
- package/src/components/structure/index.js +5 -0
- package/src/components/structure/modal/Modal.js +84 -0
- package/src/components/structure/modal/Modal.native.js +83 -0
- package/src/components/structure/modal/ModalBackdrop.js +58 -0
- package/src/components/structure/modal/ModalContent.js +28 -0
- package/src/components/structure/modal/ModalFooter.js +31 -0
- package/src/components/structure/modal/ModalHeader.js +50 -0
- package/src/components/structure/modal/handler/ModalsHandler.js +61 -0
- package/src/components/structure/modal/index.js +6 -0
- package/src/components/structure/overlay/OverlayWrapper.js +1 -1
- package/src/components/structure/popover/Popover.js +37 -2
- package/src/components/structure/popover/Popover.native.js +46 -16
- package/src/components/theme/ThemePicker.js +49 -0
- package/src/components/theme/ThemePickerDrawer.js +13 -0
- package/src/components/theme/ThemeStatusBar.js +3 -0
- package/src/components/theme/ThemeStatusBar.native.js +9 -0
- package/src/components/theme/ThemeThumb.js +98 -0
- package/src/components/theme/index.js +3 -0
- package/src/helpers/index.js +1 -0
- package/src/helpers/storage.js +54 -0
- package/src/modifiers/animations/animatedEffects.js +2 -0
- package/src/modifiers/animations/animatedEffects.native.js +3 -1
- package/src/modifiers/animations/fadeEffect.js +4 -2
- package/src/modifiers/animations/scaleEffect.js +45 -0
- package/src/modifiers/animations/scaleEffect.native.js +33 -0
- package/src/modifiers/animations/slideEffect.js +3 -1
- package/src/modifiers/background.js +16 -4
- package/src/modifiers/cursor.js +21 -0
- package/src/modifiers/display.js +2 -2
- package/src/modifiers/fullColor.js +2 -2
- package/src/modifiers/hover.js +28 -0
- package/src/modifiers/position.js +24 -3
- package/src/modifiers/size.js +2 -1
- package/src/modifiers/state.js +1 -1
- package/src/responsive/responsiveHooks.js +7 -0
- package/src/theme/ThemeHandler.js +18 -2
- package/src/theme/default/base.js +6 -6
- package/src/theme/default/blackTheme.js +35 -0
- package/src/theme/default/cyberpunkTheme.js +4 -1
- package/src/theme/default/darkTheme.js +4 -1
- package/src/theme/default/deepWoodsTheme.js +5 -2
- package/src/theme/default/forestTheme.js +4 -1
- package/src/theme/default/hackerTheme.js +4 -1
- package/src/theme/default/lightTheme.js +4 -1
- package/src/theme/default/midnightTheme.js +4 -1
- package/src/theme/default/msdosTheme.js +19 -4
- package/src/theme/default/oceanTheme.js +5 -2
- package/src/theme/default/paperTheme.js +35 -0
- package/src/theme/default/pastelTheme.js +5 -2
- package/src/theme/default/sunsetTheme.js +7 -4
- package/src/theme/default/themes.js +9 -10
- package/src/theme/format/formatTheme.js +9 -3
- package/src/theme/helpers/contrastColor.js +49 -11
- package/dist/abstractions/TouchableOpacity.web.js +0 -1
- package/dist/components/calendar/DayPicker.js +0 -1
- package/src/abstractions/TouchableOpacity.web.js +0 -3
- 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({
|
|
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}
|
|
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="
|
|
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
|
+
}
|