@neko-os/ui 0.0.5 → 0.0.6
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.js +1 -0
- package/dist/abstractions/ActivityIndicator.native.js +1 -0
- package/dist/abstractions/AnimatedView.js +1 -0
- package/dist/abstractions/AnimatedView.native.js +1 -0
- package/dist/abstractions/DraggableSlideView.js +1 -0
- package/dist/abstractions/DraggableSlideView.native.js +1 -0
- package/dist/abstractions/Icon.js +1 -1
- package/dist/abstractions/Image.js +1 -0
- package/dist/abstractions/Image.native.js +1 -0
- package/dist/abstractions/Image.web.js +1 -0
- package/dist/abstractions/Platform.js +1 -0
- package/dist/abstractions/Platform.native.js +1 -0
- package/dist/abstractions/Platform.web.js +1 -0
- package/dist/abstractions/SafeAreaView.js +1 -0
- package/dist/abstractions/SafeAreaView.native.js +1 -0
- package/dist/abstractions/Table.js +1 -0
- package/dist/abstractions/Table.native.js +1 -0
- package/dist/abstractions/Text.js +1 -1
- package/dist/abstractions/TextInput.js +1 -0
- package/dist/abstractions/TextInput.native.js +1 -0
- package/dist/abstractions/TextInput.web.js +1 -0
- package/dist/abstractions/View.js +1 -1
- package/dist/abstractions/helpers/componentSize.js +1 -0
- package/dist/abstractions/helpers/componentSize.native.js +1 -0
- package/dist/abstractions/helpers/transformStyle.js +1 -0
- package/dist/abstractions/helpers/transformStyle.native.js +1 -0
- package/dist/components/actions/Breadcrumb.js +1 -0
- package/dist/components/actions/Button.js +1 -1
- package/dist/components/actions/Dropdown.js +1 -0
- package/dist/components/actions/Link.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/menu/HorizontalMenu.js +1 -0
- package/dist/components/actions/menu/Menu.js +1 -0
- package/dist/components/actions/menu/SubmenuWrapper.js +1 -0
- package/dist/components/actions/menu/VerticalMenu.js +1 -0
- package/dist/components/animations/AnimatedView.js +1 -0
- package/dist/components/animations/DraggableSlideView.js +1 -0
- package/dist/components/animations/index.js +1 -0
- package/dist/components/calendar/DayPicker.js +1 -0
- package/dist/components/calendar/_helpers/calendarDays.js +1 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/feedback/index.js +1 -0
- package/dist/components/feedback/notifications/Notification.js +1 -0
- package/dist/components/feedback/notifications/NotificationsHandler.js +1 -0
- package/dist/components/form/Form.js +1 -1
- package/dist/components/form/FormGroup.js +1 -1
- package/dist/components/form/FormItem.js +1 -1
- package/dist/components/form/FormList.js +1 -1
- package/dist/components/form/FormWrapperComponent.js +1 -1
- package/dist/components/form/FormWrapperComponent.native.js +1 -1
- package/dist/components/form/SubmitButton.js +1 -0
- package/dist/components/form/index.js +1 -1
- package/dist/components/form/useNewForm.js +1 -0
- package/dist/components/form/useWatch.js +1 -0
- package/dist/components/helpers/LazyRender.js +1 -0
- package/dist/components/helpers/LazyRender.native.js +1 -0
- package/dist/components/helpers/Portal.js +1 -0
- package/dist/components/helpers/PortalHandler.js +1 -0
- package/dist/components/helpers/Responsive.js +1 -1
- package/dist/components/helpers/Separator.js +1 -1
- package/dist/components/helpers/VerticalView.js +1 -0
- package/dist/components/helpers/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/inputs/Checkbox.js +1 -0
- package/dist/components/inputs/InputWrapper.js +1 -0
- package/dist/components/inputs/Picker.js +1 -0
- package/dist/components/inputs/Radio.js +1 -0
- package/dist/components/inputs/Switch.js +1 -0
- package/dist/components/inputs/TextInput.js +1 -0
- package/dist/components/inputs/index.js +1 -0
- package/dist/components/layout/Layout.js +1 -0
- package/dist/components/layout/LayoutContent.js +1 -0
- package/dist/components/layout/LayoutHeader.js +1 -0
- package/dist/components/layout/LayoutSider.js +1 -0
- package/dist/components/layout/index.js +1 -0
- package/dist/components/presentation/Avatar.js +1 -0
- package/dist/components/presentation/AvatarLabel.js +1 -0
- package/dist/components/presentation/Badge.js +1 -0
- package/dist/components/presentation/ContentLabel.js +1 -1
- package/dist/components/presentation/IconLabel.js +1 -1
- package/dist/components/presentation/Image.js +1 -0
- package/dist/components/presentation/LabelValue.js +1 -0
- package/dist/components/presentation/Result.js +1 -0
- package/dist/components/presentation/ResultBar.js +1 -0
- package/dist/components/presentation/Tag.js +1 -1
- package/dist/components/presentation/Tooltip.js +1 -0
- package/dist/components/presentation/index.js +1 -1
- package/dist/components/state/Loading.js +1 -0
- package/dist/components/state/LoadingView.js +1 -0
- package/dist/components/state/index.js +1 -0
- package/dist/components/structure/Accordion.js +1 -0
- package/dist/components/structure/AccordionGroup.js +1 -0
- package/dist/components/structure/Card.js +1 -1
- package/dist/components/structure/Col.js +1 -0
- package/dist/components/structure/Row.js +1 -0
- package/dist/components/structure/SafeAreaView.js +1 -0
- package/dist/components/structure/View.js +1 -1
- package/dist/components/structure/index.js +1 -1
- package/dist/components/structure/overlay/OverlayHandler.js +1 -0
- package/dist/components/structure/overlay/OverlayHandler.native.js +1 -0
- package/dist/components/structure/overlay/OverlayWrapper.js +1 -0
- package/dist/components/structure/overlay/calculatePosition.js +1 -0
- package/dist/components/structure/overlay/smartPlacement.js +1 -0
- package/dist/components/structure/popover/Popover.js +1 -0
- package/dist/components/structure/popover/Popover.native.js +1 -0
- package/dist/components/structure/popover/PopoverContent.js +1 -0
- package/dist/components/table/DataTable.js +1 -0
- package/dist/components/table/Pagination.js +1 -0
- package/dist/components/table/Table.js +1 -0
- package/dist/components/table/TableCol.js +1 -0
- package/dist/components/table/TableHeader.js +1 -0
- package/dist/components/table/TableHeaderRow.js +1 -0
- package/dist/components/table/TableRow.js +1 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/text/Text.js +1 -1
- package/dist/components/text/VerticalText.js +1 -0
- package/dist/components/text/index.js +1 -1
- package/dist/helpers/debounce.js +1 -0
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/options.js +1 -0
- package/dist/helpers/random.js +1 -0
- package/dist/index.css +10 -0
- package/dist/index.js +1 -1
- package/dist/modifiers/alignConverter.js +1 -0
- package/dist/modifiers/animation.js +1 -0
- package/dist/modifiers/animations/animatedEffects.js +1 -0
- package/dist/modifiers/animations/animatedEffects.native.js +1 -0
- package/dist/modifiers/animations/animatedEffects.web.js +1 -0
- package/dist/modifiers/animations/fadeEffect.js +1 -0
- package/dist/modifiers/animations/fadeEffect.native.js +1 -0
- package/dist/modifiers/animations/slideEffect.js +1 -0
- package/dist/modifiers/animations/slideEffect.native.js +1 -0
- package/dist/modifiers/applyStyles.js +1 -0
- package/dist/modifiers/border.js +1 -1
- package/dist/modifiers/display.js +1 -1
- package/dist/modifiers/flex.js +1 -1
- package/dist/modifiers/flexWrapper.js +1 -1
- package/dist/modifiers/fullColor.js +1 -1
- package/dist/modifiers/grid.js +1 -0
- package/dist/modifiers/overflow.js +1 -0
- package/dist/modifiers/position.js +1 -1
- package/dist/modifiers/responsiveConverter.js +1 -0
- package/dist/modifiers/size.js +1 -1
- package/dist/modifiers/state.js +1 -0
- package/dist/responsive/ResponsiveHandler.js +1 -0
- package/dist/responsive/index.js +1 -0
- package/dist/responsive/responsiveHooks.js +1 -0
- package/dist/theme/ThemeHandler.js +1 -1
- package/dist/theme/default/base.js +1 -1
- package/dist/theme/default/darkTheme.js +1 -1
- package/dist/theme/default/hackerTheme.js +1 -1
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -1
- package/dist/theme/helpers/contrastColor.js +1 -0
- package/dist/theme/helpers/dynamicColor.js +1 -0
- package/dist/theme/helpers/relatedScales.js +1 -1
- package/dist/theme/helpers/sizeScale.js +1 -1
- package/dist/theme/helpers/textScale.js +1 -1
- package/package.json +8 -4
- package/src/NekoUI.js +15 -1
- package/src/abstractions/ActivityIndicator.js +31 -0
- package/src/abstractions/ActivityIndicator.native.js +44 -0
- package/src/abstractions/AnimatedView.js +3 -0
- package/src/abstractions/AnimatedView.native.js +6 -0
- package/src/abstractions/DraggableSlideView.js +85 -0
- package/src/abstractions/DraggableSlideView.native.js +62 -0
- package/src/abstractions/Icon.js +4 -42
- package/src/abstractions/Image.js +12 -0
- package/src/abstractions/Image.native.js +7 -0
- package/src/abstractions/Image.web.js +7 -0
- package/src/abstractions/Platform.js +1 -0
- package/src/abstractions/Platform.native.js +3 -0
- package/src/abstractions/Platform.web.js +3 -0
- package/src/abstractions/SafeAreaView.js +3 -0
- package/src/abstractions/SafeAreaView.native.js +3 -0
- package/src/abstractions/Table.js +29 -0
- package/src/abstractions/Table.native.js +19 -0
- package/src/abstractions/Text.js +13 -2
- package/src/abstractions/TextInput.js +3 -0
- package/src/abstractions/TextInput.native.js +5 -0
- package/src/abstractions/TextInput.web.js +5 -0
- package/src/abstractions/View.js +2 -2
- package/src/abstractions/helpers/componentSize.js +13 -0
- package/src/abstractions/helpers/componentSize.native.js +12 -0
- package/src/abstractions/helpers/transformStyle.js +8 -0
- package/src/abstractions/helpers/transformStyle.native.js +3 -0
- package/src/components/actions/Breadcrumb.js +47 -0
- package/src/components/actions/Button.js +8 -3
- package/src/components/actions/Dropdown.js +68 -0
- package/src/components/actions/Link.js +21 -8
- package/src/components/actions/index.js +3 -0
- package/src/components/actions/menu/HorizontalMenu.js +96 -0
- package/src/components/actions/menu/Menu.js +7 -0
- package/src/components/actions/menu/SubmenuWrapper.js +16 -0
- package/src/components/actions/menu/VerticalMenu.js +107 -0
- package/src/components/animations/AnimatedView.js +45 -0
- package/src/components/animations/DraggableSlideView.js +42 -0
- package/src/components/animations/index.js +2 -0
- package/src/components/calendar/DayPicker.js +91 -0
- package/src/components/calendar/_helpers/calendarDays.js +16 -0
- package/src/components/calendar/index.js +1 -0
- package/src/components/feedback/index.js +1 -0
- package/src/components/feedback/notifications/Notification.js +37 -0
- package/src/components/feedback/notifications/NotificationsHandler.js +65 -0
- package/src/components/form/Form.js +15 -4
- package/src/components/form/FormGroup.js +4 -4
- package/src/components/form/FormItem.js +30 -8
- package/src/components/form/FormList.js +45 -9
- package/src/components/form/FormWrapperComponent.js +37 -2
- package/src/components/form/FormWrapperComponent.native.js +2 -2
- package/src/components/form/SubmitButton.js +20 -0
- package/src/components/form/index.js +3 -2
- package/src/components/form/useNewForm.js +67 -0
- package/src/components/form/useWatch.js +70 -0
- package/src/components/helpers/LazyRender.js +55 -0
- package/src/components/helpers/LazyRender.native.js +58 -0
- package/src/components/helpers/Portal.js +21 -0
- package/src/components/helpers/PortalHandler.js +32 -0
- package/src/components/helpers/Responsive.js +1 -1
- package/src/components/helpers/Separator.js +10 -14
- package/src/components/helpers/VerticalView.js +34 -0
- package/src/components/helpers/index.js +4 -0
- package/src/components/index.js +7 -0
- package/src/components/inputs/Checkbox.js +56 -0
- package/src/components/inputs/InputWrapper.js +79 -0
- package/src/components/inputs/Picker.js +116 -0
- package/src/components/inputs/Radio.js +55 -0
- package/src/components/inputs/Switch.js +60 -0
- package/src/components/inputs/TextInput.js +22 -0
- package/src/components/inputs/index.js +6 -0
- package/src/components/layout/Layout.js +40 -0
- package/src/components/layout/LayoutContent.js +42 -0
- package/src/components/layout/LayoutHeader.js +69 -0
- package/src/components/layout/LayoutSider.js +64 -0
- package/src/components/layout/index.js +4 -0
- package/src/components/presentation/Avatar.js +79 -0
- package/src/components/presentation/AvatarLabel.js +58 -0
- package/src/components/presentation/Badge.js +90 -0
- package/src/components/presentation/ContentLabel.js +24 -6
- package/src/components/presentation/IconLabel.js +12 -2
- package/src/components/presentation/Image.js +33 -0
- package/src/components/presentation/LabelValue.js +49 -0
- package/src/components/presentation/Result.js +60 -0
- package/src/components/presentation/ResultBar.js +56 -0
- package/src/components/presentation/Tag.js +8 -11
- package/src/components/presentation/Tooltip.js +43 -0
- package/src/components/presentation/index.js +8 -0
- package/src/components/state/Loading.js +20 -0
- package/src/components/state/LoadingView.js +28 -0
- package/src/components/state/index.js +2 -0
- package/src/components/structure/Accordion.js +69 -0
- package/src/components/structure/AccordionGroup.js +35 -0
- package/src/components/structure/Card.js +4 -1
- package/src/components/structure/Col.js +22 -0
- package/src/components/structure/Row.js +42 -0
- package/src/components/structure/SafeAreaView.js +42 -0
- package/src/components/structure/View.js +9 -3
- package/src/components/structure/index.js +6 -0
- package/src/components/structure/overlay/OverlayHandler.js +70 -0
- package/src/components/structure/overlay/OverlayHandler.native.js +6 -0
- package/src/components/structure/overlay/OverlayWrapper.js +52 -0
- package/src/components/structure/overlay/calculatePosition.js +29 -0
- package/src/components/structure/overlay/smartPlacement.js +32 -0
- package/src/components/structure/popover/Popover.js +69 -0
- package/src/components/structure/popover/Popover.native.js +75 -0
- package/src/components/structure/popover/PopoverContent.js +18 -0
- package/src/components/table/DataTable.js +57 -0
- package/src/components/table/Pagination.js +128 -0
- package/src/components/table/Table.js +65 -0
- package/src/components/table/TableCol.js +67 -0
- package/src/components/table/TableHeader.js +69 -0
- package/src/components/table/TableHeaderRow.js +31 -0
- package/src/components/table/TableRow.js +30 -0
- package/src/components/table/index.js +7 -0
- package/src/components/text/Text.js +4 -0
- package/src/components/text/VerticalText.js +29 -0
- package/src/components/text/index.js +1 -0
- package/src/helpers/debounce.js +9 -0
- package/src/helpers/index.js +2 -1
- package/src/helpers/options.js +65 -0
- package/src/helpers/random.js +5 -0
- package/src/index.css +10 -0
- package/src/index.js +1 -0
- package/src/modifiers/alignConverter.js +11 -0
- package/src/modifiers/animation.js +18 -0
- package/src/modifiers/animations/animatedEffects.js +63 -0
- package/src/modifiers/animations/animatedEffects.native.js +53 -0
- package/src/modifiers/animations/animatedEffects.web.js +3 -0
- package/src/modifiers/animations/fadeEffect.js +43 -0
- package/src/modifiers/animations/fadeEffect.native.js +33 -0
- package/src/modifiers/animations/slideEffect.js +61 -0
- package/src/modifiers/animations/slideEffect.native.js +53 -0
- package/src/modifiers/applyStyles.js +7 -0
- package/src/modifiers/border.js +30 -6
- package/src/modifiers/display.js +3 -5
- package/src/modifiers/flex.js +1 -1
- package/src/modifiers/flexWrapper.js +48 -7
- package/src/modifiers/fullColor.js +5 -5
- package/src/modifiers/grid.js +27 -0
- package/src/modifiers/overflow.js +23 -0
- package/src/modifiers/position.js +10 -2
- package/src/modifiers/responsiveConverter.js +19 -0
- package/src/modifiers/size.js +10 -4
- package/src/modifiers/state.js +33 -0
- package/src/responsive/ResponsiveHandler.js +28 -0
- package/src/responsive/index.js +2 -0
- package/src/responsive/responsiveHooks.js +54 -0
- package/src/theme/ThemeHandler.js +1 -1
- package/src/theme/default/base.js +22 -22
- package/src/theme/default/darkTheme.js +2 -2
- package/src/theme/default/hackerTheme.js +8 -0
- package/src/theme/default/lightTheme.js +1 -1
- package/src/theme/default/msdosTheme.js +1 -1
- package/src/theme/helpers/contrastColor.js +20 -0
- package/src/theme/helpers/dynamicColor.js +32 -0
- package/src/theme/helpers/relatedScales.js +6 -6
- package/src/theme/helpers/sizeScale.js +7 -2
- package/src/theme/helpers/textScale.js +1 -1
- package/dist/components/form/inputs/Checkbox.js +0 -1
- package/dist/components/form/inputs/Radio.js +0 -1
- package/dist/components/form/inputs/Switch.js +0 -1
- package/dist/components/form/inputs/index.js +0 -1
- package/dist/components/form/useForm.js +0 -1
- package/dist/helpers/responsive.js +0 -1
- package/src/components/form/inputs/Checkbox.js +0 -42
- package/src/components/form/inputs/Radio.js +0 -42
- package/src/components/form/inputs/Switch.js +0 -44
- package/src/components/form/inputs/index.js +0 -3
- package/src/components/form/useForm.js +0 -65
- package/src/helpers/responsive.js +0 -54
- /package/dist/abstractions/{windowWidth.js → helpers/windowWidth.js} +0 -0
- /package/dist/abstractions/{windowWidth.native.js → helpers/windowWidth.native.js} +0 -0
- /package/dist/abstractions/{windowWidth.web.js → helpers/windowWidth.web.js} +0 -0
- /package/src/abstractions/{windowWidth.js → helpers/windowWidth.js} +0 -0
- /package/src/abstractions/{windowWidth.native.js → helpers/windowWidth.native.js} +0 -0
- /package/src/abstractions/{windowWidth.web.js → helpers/windowWidth.web.js} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { pipe, omit } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { IconLabel } from '../presentation/IconLabel'
|
|
4
|
+
import { Link } from './Link'
|
|
5
|
+
import { Text } from '../text/Text'
|
|
6
|
+
import { View } from '../structure/View'
|
|
7
|
+
import { moveScale } from '../../theme/helpers/sizeScale'
|
|
8
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
9
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
10
|
+
|
|
11
|
+
export function Breadcrumb({ items, onChange, ...rootProps }) {
|
|
12
|
+
const [{ sizeCode }, props] = pipe(
|
|
13
|
+
useSizeConverter('elementHeights', 'md'),
|
|
14
|
+
useThemeComponentModifier('Breadcrumb')
|
|
15
|
+
)([{}, rootProps])
|
|
16
|
+
|
|
17
|
+
const gap = 'sm'
|
|
18
|
+
|
|
19
|
+
const handlePress = (item, index) => {
|
|
20
|
+
onChange?.(item, index)
|
|
21
|
+
item.onPress?.(index)
|
|
22
|
+
item.onClick?.(index)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View className="neko-breadcrumb" row gap={gap} centerV {...props}>
|
|
27
|
+
{items.map((item, index) => {
|
|
28
|
+
const active = index === items.length - 1
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View row gap={gap} centerV key={item.key || index}>
|
|
32
|
+
<Link onPress={!active ? () => handlePress(item, index) : undefined}>
|
|
33
|
+
<IconLabel
|
|
34
|
+
color={active ? 'text' : 'text3'}
|
|
35
|
+
size={sizeCode}
|
|
36
|
+
moveIconSizeScale={-2}
|
|
37
|
+
strong={active}
|
|
38
|
+
{...omit(['onPress', 'onClick'], item)}
|
|
39
|
+
/>
|
|
40
|
+
</Link>
|
|
41
|
+
{!active && <Text text4 label="/" size={moveScale(sizeCode, -1)} />}
|
|
42
|
+
</View>
|
|
43
|
+
)
|
|
44
|
+
})}
|
|
45
|
+
</View>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -6,6 +6,7 @@ import { useBackgroundModifier } from '../../modifiers/background'
|
|
|
6
6
|
import { useBorderModifier } from '../../modifiers/border'
|
|
7
7
|
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
8
8
|
import { useDefaultModifier } from '../../modifiers/default'
|
|
9
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
9
10
|
import { useFlexModifier } from '../../modifiers/flex'
|
|
10
11
|
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
11
12
|
import { useFullColorModifier } from '../../modifiers/fullColor'
|
|
@@ -14,6 +15,7 @@ import { usePaddingModifier } from '../../modifiers/padding'
|
|
|
14
15
|
import { usePositionModifier } from '../../modifiers/position'
|
|
15
16
|
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
16
17
|
import { useSizeModifier } from '../../modifiers/size'
|
|
18
|
+
import { useStateModifier } from '../../modifiers/state'
|
|
17
19
|
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
18
20
|
|
|
19
21
|
const DEFAULT_PROPS = ([{ sizeCode }]) => ({
|
|
@@ -21,17 +23,19 @@ const DEFAULT_PROPS = ([{ sizeCode }]) => ({
|
|
|
21
23
|
paddingV: 2,
|
|
22
24
|
height: sizeCode,
|
|
23
25
|
br: sizeCode,
|
|
24
|
-
|
|
26
|
+
border: 1,
|
|
25
27
|
center: true,
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
export function Button(rootProps) {
|
|
29
|
-
const [{ fontColor, sizeCode }, formattedProps] = pipe(
|
|
31
|
+
const [{ loading, fontColor, sizeCode }, formattedProps] = pipe(
|
|
30
32
|
useColorConverter('primary'),
|
|
31
33
|
useSizeConverter('elementHeights', 'md'),
|
|
32
34
|
useThemeComponentModifier('Button'),
|
|
33
35
|
useDefaultModifier(DEFAULT_PROPS),
|
|
34
36
|
useFullColorModifier,
|
|
37
|
+
useDisplayModifier,
|
|
38
|
+
useStateModifier,
|
|
35
39
|
useSizeModifier,
|
|
36
40
|
usePositionModifier,
|
|
37
41
|
usePaddingModifier,
|
|
@@ -45,7 +49,7 @@ export function Button(rootProps) {
|
|
|
45
49
|
const { label, icon, textProps, iconProps, gap, invert, size, ...props } = formattedProps
|
|
46
50
|
|
|
47
51
|
return (
|
|
48
|
-
<AbsTouchableOpacity className="neko-button neko-wave-click-effect" {...props}>
|
|
52
|
+
<AbsTouchableOpacity className="neko-button neko-wave-click-effect" type="button" {...props}>
|
|
49
53
|
<IconLabel
|
|
50
54
|
center
|
|
51
55
|
color={fontColor}
|
|
@@ -56,6 +60,7 @@ export function Button(rootProps) {
|
|
|
56
60
|
invert={invert}
|
|
57
61
|
textProps={{ strong: true, ...textProps }}
|
|
58
62
|
iconProps={iconProps}
|
|
63
|
+
loading={loading}
|
|
59
64
|
/>
|
|
60
65
|
</AbsTouchableOpacity>
|
|
61
66
|
)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { IconLabel } from '../presentation/IconLabel'
|
|
4
|
+
import { Link } from './Link'
|
|
5
|
+
import { Menu } from './menu/Menu'
|
|
6
|
+
import { Popover } from '../structure/popover/Popover'
|
|
7
|
+
import { View } from '../structure/View'
|
|
8
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
9
|
+
|
|
10
|
+
export function Dropdown({ items, ...rootProps }) {
|
|
11
|
+
const [_, formattedProps] = pipe(
|
|
12
|
+
useThemeComponentModifier('Dropdown')
|
|
13
|
+
// useColorConverter('primary'),
|
|
14
|
+
// useSizeModifier, //
|
|
15
|
+
// useFlexWrapperModifier,
|
|
16
|
+
// useDisplayModifier,
|
|
17
|
+
// useStateModifier,
|
|
18
|
+
// usePositionModifier,
|
|
19
|
+
// usePaddingModifier,
|
|
20
|
+
// useMarginModifier,
|
|
21
|
+
// useFlexModifier
|
|
22
|
+
)([{}, rootProps])
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
onChange,
|
|
26
|
+
label,
|
|
27
|
+
trigger = 'click',
|
|
28
|
+
icon,
|
|
29
|
+
strong,
|
|
30
|
+
color,
|
|
31
|
+
popoverProps,
|
|
32
|
+
iconLabelProps,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
} = formattedProps
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View className="neko-dropdown" {...props}>
|
|
39
|
+
<Popover
|
|
40
|
+
useParentMinWidth
|
|
41
|
+
placement="bottomLeft"
|
|
42
|
+
trigger={trigger}
|
|
43
|
+
padding="xs"
|
|
44
|
+
{...popoverProps}
|
|
45
|
+
renderContent={({ onClose }) => {
|
|
46
|
+
const handleChange = (...params) => {
|
|
47
|
+
if (onChange) onChange(...params)
|
|
48
|
+
onClose()
|
|
49
|
+
}
|
|
50
|
+
return <Menu vertical items={items} gap={0} onChange={handleChange} linkPaddingH="xs" />
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{children || (
|
|
54
|
+
<Link>
|
|
55
|
+
<IconLabel
|
|
56
|
+
label={label || '---'}
|
|
57
|
+
icon={icon || 'arrow-down-s-fill'}
|
|
58
|
+
strong={strong}
|
|
59
|
+
color={color}
|
|
60
|
+
invert
|
|
61
|
+
{...iconLabelProps}
|
|
62
|
+
/>
|
|
63
|
+
</Link>
|
|
64
|
+
)}
|
|
65
|
+
</Popover>
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { pipe, is } from 'ramda'
|
|
2
2
|
|
|
3
3
|
import { AbsTouchableOpacity } from '../../abstractions/TouchableOpacity'
|
|
4
|
+
import { LoadingView } from '../state/LoadingView'
|
|
4
5
|
import { Text } from '../text/Text'
|
|
6
|
+
import { useAnimationModifier } from '../../modifiers/animation'
|
|
7
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
8
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
9
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
5
10
|
import { useDisplayModifier } from '../../modifiers/display'
|
|
6
11
|
import { useFlexModifier } from '../../modifiers/flex'
|
|
7
12
|
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
@@ -9,31 +14,39 @@ import { useMarginModifier } from '../../modifiers/margin'
|
|
|
9
14
|
import { usePaddingModifier } from '../../modifiers/padding'
|
|
10
15
|
import { usePositionModifier } from '../../modifiers/position'
|
|
11
16
|
import { useSizeModifier } from '../../modifiers/size'
|
|
17
|
+
import { useStateModifier } from '../../modifiers/state'
|
|
12
18
|
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
13
19
|
|
|
14
|
-
export function Link({ label, children,
|
|
15
|
-
const [
|
|
20
|
+
export function Link({ label, children, href, target, ...rootProps }) {
|
|
21
|
+
const [{ loading, color: color }, props] = pipe(
|
|
16
22
|
useThemeComponentModifier('Link'),
|
|
23
|
+
useBackgroundModifier,
|
|
24
|
+
useColorConverter('primary'),
|
|
25
|
+
useAnimationModifier,
|
|
17
26
|
useSizeModifier, //
|
|
18
|
-
|
|
27
|
+
useFlexWrapperModifier,
|
|
28
|
+
useDisplayModifier,
|
|
29
|
+
useStateModifier,
|
|
30
|
+
useBorderModifier,
|
|
19
31
|
usePositionModifier,
|
|
20
32
|
usePaddingModifier,
|
|
21
33
|
useMarginModifier,
|
|
22
|
-
useFlexWrapperModifier,
|
|
23
34
|
useFlexModifier
|
|
24
35
|
)([{}, rootProps])
|
|
25
36
|
|
|
26
37
|
if (!!label || is(String, children)) {
|
|
27
38
|
children = (
|
|
28
|
-
<Text
|
|
39
|
+
<Text color={color} {...props}>
|
|
29
40
|
{label || children}
|
|
30
41
|
</Text>
|
|
31
42
|
)
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
return (
|
|
35
|
-
<
|
|
36
|
-
{
|
|
37
|
-
|
|
46
|
+
<LoadingView active={loading} noWrapper replaceChildren>
|
|
47
|
+
<AbsTouchableOpacity className="neko-link" link target={target} href={!props.disabled && href} {...props}>
|
|
48
|
+
{children}
|
|
49
|
+
</AbsTouchableOpacity>
|
|
50
|
+
</LoadingView>
|
|
38
51
|
)
|
|
39
52
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { omit, pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { IconText } from '../../presentation/IconLabel'
|
|
5
|
+
import { Link } from '../Link'
|
|
6
|
+
import { SubmenuWrapper } from './SubmenuWrapper'
|
|
7
|
+
import { View } from '../../structure/View'
|
|
8
|
+
import { useColorConverter } from '../../../modifiers/colorConverter'
|
|
9
|
+
import { useSizeConverter } from '../../../modifiers/sizeConverter'
|
|
10
|
+
import { useThemeComponentModifier } from '../../../modifiers/themeComponent'
|
|
11
|
+
|
|
12
|
+
function Item({
|
|
13
|
+
item,
|
|
14
|
+
linkPaddingH = 'md',
|
|
15
|
+
handlePress,
|
|
16
|
+
linkProps,
|
|
17
|
+
activeIndex,
|
|
18
|
+
activeKey,
|
|
19
|
+
activeColor = 'primary',
|
|
20
|
+
color,
|
|
21
|
+
sizeCode,
|
|
22
|
+
index,
|
|
23
|
+
...props
|
|
24
|
+
}) {
|
|
25
|
+
activeColor = activeColor || 'primary'
|
|
26
|
+
let { active, key, ...childProps } = omit(['onClick', 'onPress'], item)
|
|
27
|
+
if (!active && activeIndex >= 0) active = activeIndex === index
|
|
28
|
+
if (!active && activeKey !== undefined) active = activeKey === item.key
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<SubmenuWrapper
|
|
32
|
+
item={item}
|
|
33
|
+
onChange={handlePress}
|
|
34
|
+
activeKey={activeKey}
|
|
35
|
+
color={color}
|
|
36
|
+
placement="bottomRight"
|
|
37
|
+
hideIcon
|
|
38
|
+
>
|
|
39
|
+
<Link
|
|
40
|
+
key={key || index}
|
|
41
|
+
fullH
|
|
42
|
+
center
|
|
43
|
+
paddingH={linkPaddingH}
|
|
44
|
+
{...linkProps}
|
|
45
|
+
onPress={() => handlePress(item, index)}
|
|
46
|
+
>
|
|
47
|
+
<IconText
|
|
48
|
+
color={active ? activeColor : color}
|
|
49
|
+
fullH
|
|
50
|
+
marginT={3}
|
|
51
|
+
borderB={3}
|
|
52
|
+
borderColor={active ? activeColor : 'transparent'}
|
|
53
|
+
transition="border-color 0.6s ease"
|
|
54
|
+
size={sizeCode}
|
|
55
|
+
{...childProps}
|
|
56
|
+
/>
|
|
57
|
+
</Link>
|
|
58
|
+
</SubmenuWrapper>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function HorizontalMenu(rootProps) {
|
|
63
|
+
const [{ sizeCode, color }, formattedProps] = pipe(
|
|
64
|
+
useColorConverter(),
|
|
65
|
+
useSizeConverter('icons', 'md'),
|
|
66
|
+
useThemeComponentModifier('HorizontalMenu') //
|
|
67
|
+
)([{}, rootProps])
|
|
68
|
+
|
|
69
|
+
let { gap = 'sm', height = 50, items, onChange, onChangeIndex, ...props } = formattedProps
|
|
70
|
+
|
|
71
|
+
const handlePress = React.useCallback(
|
|
72
|
+
(item, index) => {
|
|
73
|
+
if (!!onChange) onChange(item, index)
|
|
74
|
+
if (!!onChangeIndex) onChangeIndex(index)
|
|
75
|
+
if (!!item.onPress) item.onPress()
|
|
76
|
+
if (!!item.onClick) item.onClick()
|
|
77
|
+
},
|
|
78
|
+
[onChange, onChangeIndex]
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<View className="neko-horizontal-menu" row gap={gap} height={height} centerV {...props}>
|
|
83
|
+
{items.map((item, index) => (
|
|
84
|
+
<Item
|
|
85
|
+
key={item.key || index}
|
|
86
|
+
item={item}
|
|
87
|
+
handlePress={handlePress}
|
|
88
|
+
color={color}
|
|
89
|
+
sizeCode={sizeCode}
|
|
90
|
+
index={index}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
))}
|
|
94
|
+
</View>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Dropdown } from '../Dropdown'
|
|
2
|
+
import { Icon } from '../../presentation/Icon'
|
|
3
|
+
import { View } from '../../structure/View'
|
|
4
|
+
|
|
5
|
+
export function SubmenuWrapper({ item, children, placement, hideIcon, ...props }) {
|
|
6
|
+
if (!item.subItems?.length) return children
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Dropdown popoverProps={{ placement: placement || 'rightTop' }} items={item.subItems} trigger="hover" {...props}>
|
|
10
|
+
<View flex row gap="xxs" center fullH>
|
|
11
|
+
{children}
|
|
12
|
+
{!hideIcon && <Icon name="arrow-right-s-line" />}
|
|
13
|
+
</View>
|
|
14
|
+
</Dropdown>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { omit, pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import tinycolor from 'tinycolor2'
|
|
4
|
+
|
|
5
|
+
import { Divider } from '../../helpers/Separator'
|
|
6
|
+
import { IconText } from '../../presentation/IconLabel'
|
|
7
|
+
import { Link } from '../Link'
|
|
8
|
+
import { SubmenuWrapper } from './SubmenuWrapper'
|
|
9
|
+
import { Text } from '../../text/Text'
|
|
10
|
+
import { View } from '../../structure/View'
|
|
11
|
+
import { useColorConverter } from '../../../modifiers/colorConverter'
|
|
12
|
+
import { useSizeConverter } from '../../../modifiers/sizeConverter'
|
|
13
|
+
import { useThemeComponentModifier } from '../../../modifiers/themeComponent'
|
|
14
|
+
|
|
15
|
+
function LinkItem({
|
|
16
|
+
item,
|
|
17
|
+
linkPaddingH = 'md',
|
|
18
|
+
linkPaddingV = 'xs',
|
|
19
|
+
handlePress,
|
|
20
|
+
linkProps,
|
|
21
|
+
activeIndex,
|
|
22
|
+
activeKey,
|
|
23
|
+
activeColor = 'primary',
|
|
24
|
+
color,
|
|
25
|
+
sizeCode,
|
|
26
|
+
index,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
activeColor = activeColor || 'primary'
|
|
30
|
+
let { active, key, ...childProps } = omit(['onClick', 'onPress'], item)
|
|
31
|
+
if (!active && activeIndex >= 0) active = activeIndex === index
|
|
32
|
+
if (!active && activeKey !== undefined) active = activeKey === item.key
|
|
33
|
+
const bg = active && tinycolor(color).setAlpha(0.03).toString()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<SubmenuWrapper item={item} onChange={handlePress} activeKey={activeKey} color={color}>
|
|
37
|
+
<Link
|
|
38
|
+
fullW
|
|
39
|
+
center
|
|
40
|
+
paddingH={linkPaddingH}
|
|
41
|
+
paddingV={linkPaddingV}
|
|
42
|
+
marginR={3}
|
|
43
|
+
borderL={3}
|
|
44
|
+
marginV={!!active && -4}
|
|
45
|
+
borderColor={active ? activeColor : 'transparent'}
|
|
46
|
+
bg={bg}
|
|
47
|
+
transition="border-color 0.5s ease, background 0.3s ease"
|
|
48
|
+
{...linkProps}
|
|
49
|
+
onPress={() => handlePress(item, index)}
|
|
50
|
+
>
|
|
51
|
+
<IconText paddingV={active && 4} color={active ? activeColor : color} fullW size={sizeCode} {...childProps} />
|
|
52
|
+
</Link>
|
|
53
|
+
</SubmenuWrapper>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function DividerItem({ linkPaddingH = 'md', item }) {
|
|
58
|
+
let content = <Divider height="xxs" line {...item} />
|
|
59
|
+
if (!item.label) return content
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{content}
|
|
63
|
+
<Text size="xs" color="text4" paddingH={linkPaddingH || 'md'} strong {...item} />
|
|
64
|
+
</>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Item({ item, ...props }) {
|
|
69
|
+
if (item.type === 'divider') return <DividerItem item={item} {...props} />
|
|
70
|
+
return <LinkItem item={item} {...props} />
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function VerticalMenu(rootProps) {
|
|
74
|
+
const [{ sizeCode, color }, formattedProps] = pipe(
|
|
75
|
+
useColorConverter('text'),
|
|
76
|
+
useSizeConverter('icons', 'md'),
|
|
77
|
+
useThemeComponentModifier('VerticalMenu') //
|
|
78
|
+
)([{}, rootProps])
|
|
79
|
+
|
|
80
|
+
let { gap = 'sm', items, onChange, onChangeIndex, ...props } = formattedProps
|
|
81
|
+
|
|
82
|
+
const handlePress = React.useCallback(
|
|
83
|
+
(item, index) => {
|
|
84
|
+
if (!!onChange) onChange(item, index)
|
|
85
|
+
if (!!onChangeIndex) onChangeIndex(index)
|
|
86
|
+
if (!!item.onPress) item.onPress()
|
|
87
|
+
if (!!item.onClick) item.onClick()
|
|
88
|
+
},
|
|
89
|
+
[onChange, onChangeIndex]
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<View className="neko-vertical-menu" gap={gap} width="100%" {...props}>
|
|
94
|
+
{items.map((item, index) => (
|
|
95
|
+
<Item
|
|
96
|
+
key={item.key || index}
|
|
97
|
+
item={item}
|
|
98
|
+
handlePress={handlePress}
|
|
99
|
+
color={color}
|
|
100
|
+
sizeCode={sizeCode}
|
|
101
|
+
index={index}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
))}
|
|
105
|
+
</View>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsAnimatedView } from '../../abstractions/AnimatedView'
|
|
4
|
+
import { useAnimatedEffects } from '../../modifiers/animations/animatedEffects'
|
|
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 AnimatedView({ children, ...rootProps }) {
|
|
20
|
+
const [{ lazy, render, hasOpened }, props] = pipe(
|
|
21
|
+
useAnimatedEffects,
|
|
22
|
+
useThemeComponentModifier('AnimatedView'),
|
|
23
|
+
useFlexWrapperModifier,
|
|
24
|
+
useDisplayModifier,
|
|
25
|
+
useStateModifier,
|
|
26
|
+
useSizeModifier,
|
|
27
|
+
usePositionModifier,
|
|
28
|
+
useOverflowModifier,
|
|
29
|
+
usePaddingModifier,
|
|
30
|
+
useMarginModifier,
|
|
31
|
+
useFlexModifier,
|
|
32
|
+
useBackgroundModifier,
|
|
33
|
+
useBorderModifier,
|
|
34
|
+
useShadowModifier
|
|
35
|
+
)([{}, rootProps])
|
|
36
|
+
|
|
37
|
+
if (lazy && !hasOpened) return null
|
|
38
|
+
if (!render) return null
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<AbsAnimatedView className="neko-animated-view" {...props}>
|
|
42
|
+
{children}
|
|
43
|
+
</AbsAnimatedView>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsDraggableSlideView } from '../../abstractions/DraggableSlideView'
|
|
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 DraggableSlideView({ children, ...rootProps }) {
|
|
20
|
+
const [_, props] = pipe(
|
|
21
|
+
useThemeComponentModifier('DraggableSlideView'),
|
|
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
|
+
<AbsDraggableSlideView className="neko-draggable-slide-view" {...props}>
|
|
39
|
+
{children}
|
|
40
|
+
</AbsDraggableSlideView>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import dayjs from 'dayjs'
|
|
3
|
+
|
|
4
|
+
import { Col } from '../structure/Col'
|
|
5
|
+
import { Grid } from '../structure/Row'
|
|
6
|
+
import { Icon } from '../presentation/Icon'
|
|
7
|
+
import { Link } from '../actions/Link'
|
|
8
|
+
import { Text } from '../text/Text'
|
|
9
|
+
import { View } from '../structure/View'
|
|
10
|
+
import { useCalendarDays } from './_helpers/calendarDays'
|
|
11
|
+
|
|
12
|
+
export function DayPicker({ initialValue, value, onChange, ...props }) {
|
|
13
|
+
const [localValue, setLocalValue] = React.useState(dayjs(initialValue))
|
|
14
|
+
value = value === undefined ? localValue : value
|
|
15
|
+
const handleChange = (v) => {
|
|
16
|
+
setLocalValue(v)
|
|
17
|
+
onChange?.(v)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const [currentMonth, setCurrentMonth] = React.useState(() =>
|
|
21
|
+
initialValue ? dayjs(initialValue).startOf('month') : dayjs().startOf('month')
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const prevMonth = () => setCurrentMonth((m) => m.subtract(1, 'month'))
|
|
25
|
+
const nextMonth = () => setCurrentMonth((m) => m.add(1, 'month'))
|
|
26
|
+
|
|
27
|
+
const prevYear = () => setCurrentMonth((m) => m.subtract(1, 'year'))
|
|
28
|
+
const nextYear = () => setCurrentMonth((m) => m.add(1, 'year'))
|
|
29
|
+
|
|
30
|
+
const { weekdayLabels, cells } = useCalendarDays(currentMonth)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<View className="neko-day-picker" width={250} {...props}>
|
|
34
|
+
<View className="neko-date-picker-header" row centerV gap="xxs" height={30}>
|
|
35
|
+
<Link onPress={prevYear} aria-label="Previous year" padding="xxs" paddingL={0}>
|
|
36
|
+
<Icon name="arrow-left-double-line" />
|
|
37
|
+
</Link>
|
|
38
|
+
|
|
39
|
+
<Link onPress={prevMonth} aria-label="Previous month" padding="xxs">
|
|
40
|
+
<Icon name="arrow-left-s-line" />
|
|
41
|
+
</Link>
|
|
42
|
+
|
|
43
|
+
<Text center flex>
|
|
44
|
+
{currentMonth.format('MMM YYYY')}
|
|
45
|
+
</Text>
|
|
46
|
+
|
|
47
|
+
<Link onPress={nextMonth} aria-label="Next month" padding="xxs">
|
|
48
|
+
<Icon name="arrow-right-s-line" />
|
|
49
|
+
</Link>
|
|
50
|
+
|
|
51
|
+
<Link onPress={nextYear} aria-label="Next year" padding="xxs" paddingR={0}>
|
|
52
|
+
<Icon name="arrow-right-double-line" />
|
|
53
|
+
</Link>
|
|
54
|
+
</View>
|
|
55
|
+
|
|
56
|
+
<View className="neko-day-picker-week" row center gap="sm">
|
|
57
|
+
{weekdayLabels.map((w) => (
|
|
58
|
+
<View key={w} flex height={30} center>
|
|
59
|
+
<Text center sm text4>
|
|
60
|
+
{w}
|
|
61
|
+
</Text>
|
|
62
|
+
</View>
|
|
63
|
+
))}
|
|
64
|
+
</View>
|
|
65
|
+
|
|
66
|
+
<Grid className="neko-day-picker-days" colSpan={24 / 7} gap="sm">
|
|
67
|
+
{cells.map((val, idx) => {
|
|
68
|
+
const dateVal = currentMonth.date(val)
|
|
69
|
+
const isActive = dateVal.isSame(value, 'day')
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<Col key={idx} className="day-cell" center>
|
|
73
|
+
<Link
|
|
74
|
+
ratio={1}
|
|
75
|
+
width={30}
|
|
76
|
+
center
|
|
77
|
+
br="md"
|
|
78
|
+
onPress={() => !!val && handleChange(dateVal)}
|
|
79
|
+
bg={isActive && 'primary'}
|
|
80
|
+
>
|
|
81
|
+
<Text sm text2 center strong={isActive}>
|
|
82
|
+
{val != null ? val : ''}
|
|
83
|
+
</Text>
|
|
84
|
+
</Link>
|
|
85
|
+
</Col>
|
|
86
|
+
)
|
|
87
|
+
})}
|
|
88
|
+
</Grid>
|
|
89
|
+
</View>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export function useCalendarDays(currentMonth) {
|
|
4
|
+
return React.useMemo(() => {
|
|
5
|
+
const startWeekday = currentMonth.startOf('month').day()
|
|
6
|
+
const daysInMonth = currentMonth.daysInMonth()
|
|
7
|
+
|
|
8
|
+
const blanks = Array.from({ length: startWeekday }, () => null)
|
|
9
|
+
const days = Array.from({ length: daysInMonth }, (_, i) => i + 1)
|
|
10
|
+
const cells = [...blanks, ...days]
|
|
11
|
+
|
|
12
|
+
const weekdayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
13
|
+
|
|
14
|
+
return { weekdayLabels, cells }
|
|
15
|
+
}, [currentMonth.month(), currentMonth.year()])
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DayPicker'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notifications/NotificationsHandler'
|