@neko-os/ui 0.0.4 → 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/BKTouchableOpacity.js +0 -0
- package/dist/abstractions/DraggableSlideView.js +1 -0
- package/dist/abstractions/DraggableSlideView.native.js +1 -0
- package/dist/abstractions/HiddenInput.js +1 -0
- package/dist/abstractions/HiddenInput.native.js +1 -0
- package/dist/abstractions/Icon.js +1 -1
- package/dist/abstractions/Icon.native.js +1 -1
- package/dist/abstractions/Icon.web.js +1 -1
- package/dist/abstractions/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/Switch.js +1 -0
- package/dist/abstractions/Switch.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/TouchableOpacity.js +1 -1
- package/dist/abstractions/TouchableOpacity.native.js +1 -0
- package/dist/abstractions/TouchableOpacity.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/abstractions/helpers/windowWidth.js +1 -0
- package/dist/abstractions/helpers/windowWidth.native.js +1 -0
- package/dist/abstractions/helpers/windowWidth.web.js +1 -0
- package/dist/components/actions/Breadcrumb.js +1 -0
- package/dist/components/actions/Button.js +1 -0
- package/dist/components/actions/Dropdown.js +1 -0
- package/dist/components/actions/Link.js +1 -0
- package/dist/components/actions/index.js +1 -0
- 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 -0
- package/dist/components/form/FormGroup.js +1 -0
- package/dist/components/form/FormItem.js +1 -0
- package/dist/components/form/FormList.js +1 -0
- package/dist/components/form/FormWrapperComponent.js +1 -0
- package/dist/components/form/FormWrapperComponent.native.js +1 -0
- package/dist/components/form/SubmitButton.js +1 -0
- package/dist/{form → 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 -0
- package/dist/components/helpers/Separator.js +1 -0
- package/dist/components/helpers/VerticalView.js +1 -0
- package/dist/components/helpers/index.js +1 -0
- package/dist/components/index.js +1 -0
- 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 -0
- package/dist/components/presentation/Icon.js +1 -0
- package/dist/components/presentation/IconLabel.js +1 -0
- 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 -0
- package/dist/components/presentation/Tooltip.js +1 -0
- package/dist/components/presentation/index.js +1 -0
- 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 -0
- 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 -0
- package/dist/components/structure/index.js +1 -0
- 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 -0
- package/dist/components/text/VerticalText.js +1 -0
- package/dist/components/text/index.js +1 -0
- package/dist/helpers/debounce.js +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/options.js +1 -0
- package/dist/helpers/random.js +1 -0
- package/dist/index.css +15 -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/background.js +1 -1
- package/dist/modifiers/border.js +1 -1
- package/dist/modifiers/colorConverter.js +1 -0
- package/dist/modifiers/default.js +1 -0
- package/dist/modifiers/display.js +1 -0
- package/dist/modifiers/flex.js +1 -1
- package/dist/modifiers/flexWrapper.js +1 -1
- package/dist/modifiers/fullColor.js +1 -0
- package/dist/modifiers/grid.js +1 -0
- package/dist/modifiers/logger.js +1 -0
- package/dist/modifiers/margin.js +1 -1
- package/dist/modifiers/overflow.js +1 -0
- package/dist/modifiers/padding.js +1 -1
- package/dist/modifiers/position.js +1 -1
- package/dist/modifiers/responsiveConverter.js +1 -0
- package/dist/modifiers/shadow.js +1 -1
- package/dist/modifiers/size.js +1 -1
- package/dist/modifiers/sizeConverter.js +1 -0
- package/dist/modifiers/state.js +1 -0
- package/dist/modifiers/text.js +1 -1
- package/dist/modifiers/textConverter.js +1 -0
- package/dist/modifiers/themeComponent.js +1 -0
- package/dist/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/cyberpunkTheme.js +1 -1
- package/dist/theme/default/darkTheme.js +1 -1
- package/dist/theme/default/deepWoodsTheme.js +1 -1
- package/dist/theme/default/forestTheme.js +1 -1
- package/dist/theme/default/hackerTheme.js +1 -0
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/midnightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -0
- package/dist/theme/default/oceanTheme.js +1 -1
- package/dist/theme/default/pastelTheme.js +1 -1
- package/dist/theme/default/sunsetTheme.js +1 -1
- package/dist/theme/default/themes.js +1 -1
- package/dist/theme/helpers/colorScale.js +1 -0
- package/dist/theme/helpers/contrastColor.js +1 -0
- package/dist/theme/helpers/dynamicColor.js +1 -0
- package/dist/theme/helpers/mergePreset.js +1 -0
- package/dist/theme/helpers/relatedScales.js +1 -0
- package/dist/theme/helpers/sizeScale.js +1 -1
- package/dist/theme/helpers/textScale.js +1 -0
- package/package.json +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/BKTouchableOpacity.js +12 -0
- package/src/abstractions/DraggableSlideView.js +85 -0
- package/src/abstractions/DraggableSlideView.native.js +62 -0
- package/src/abstractions/HiddenInput.js +3 -0
- package/src/abstractions/HiddenInput.native.js +3 -0
- package/src/abstractions/Icon.js +4 -20
- package/src/abstractions/Icon.native.js +11 -2
- package/src/abstractions/Icon.web.js +11 -2
- 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/Switch.js +97 -0
- package/src/abstractions/Switch.native.js +12 -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/TouchableOpacity.js +3 -11
- package/src/abstractions/TouchableOpacity.native.js +3 -0
- package/src/abstractions/TouchableOpacity.web.js +3 -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/abstractions/helpers/windowWidth.js +13 -0
- package/src/abstractions/helpers/windowWidth.native.js +6 -0
- package/src/abstractions/helpers/windowWidth.web.js +6 -0
- package/src/components/actions/Breadcrumb.js +47 -0
- package/src/components/actions/Button.js +67 -0
- package/src/components/actions/Dropdown.js +68 -0
- package/src/components/actions/Link.js +52 -0
- package/src/components/actions/index.js +5 -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 +25 -0
- package/src/{form → components/form}/FormGroup.js +4 -4
- package/src/components/form/FormItem.js +56 -0
- package/src/{form → components/form}/FormList.js +47 -11
- package/src/components/form/FormWrapperComponent.js +43 -0
- package/src/components/form/FormWrapperComponent.native.js +5 -0
- package/src/components/form/SubmitButton.js +20 -0
- package/src/{form → components/form}/index.js +3 -1
- 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 +18 -0
- package/src/components/helpers/Separator.js +45 -0
- package/src/components/helpers/VerticalView.js +34 -0
- package/src/components/helpers/index.js +6 -0
- package/src/components/index.js +13 -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 +43 -0
- package/src/components/presentation/Icon.js +20 -0
- package/src/components/presentation/IconLabel.js +39 -0
- 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 +69 -0
- package/src/components/presentation/Tooltip.js +43 -0
- package/src/components/presentation/index.js +11 -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 +45 -0
- 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 +42 -0
- package/src/components/structure/index.js +8 -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 +32 -0
- package/src/components/text/VerticalText.js +29 -0
- package/src/components/text/index.js +2 -0
- package/src/helpers/debounce.js +9 -0
- package/src/helpers/index.js +3 -0
- package/src/helpers/options.js +65 -0
- package/src/helpers/random.js +5 -0
- package/src/index.css +15 -0
- package/src/index.js +3 -5
- 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/background.js +10 -7
- package/src/modifiers/border.js +40 -13
- package/src/modifiers/colorConverter.js +13 -0
- package/src/modifiers/default.js +9 -0
- package/src/modifiers/display.js +22 -0
- package/src/modifiers/flex.js +11 -8
- package/src/modifiers/flexWrapper.js +58 -14
- package/src/modifiers/fullColor.js +29 -0
- package/src/modifiers/grid.js +27 -0
- package/src/modifiers/logger.js +6 -0
- package/src/modifiers/margin.js +10 -7
- package/src/modifiers/overflow.js +23 -0
- package/src/modifiers/padding.js +10 -7
- package/src/modifiers/position.js +20 -9
- package/src/modifiers/responsiveConverter.js +19 -0
- package/src/modifiers/shadow.js +10 -7
- package/src/modifiers/size.js +18 -9
- package/src/modifiers/sizeConverter.js +12 -0
- package/src/modifiers/state.js +33 -0
- package/src/modifiers/text.js +14 -13
- package/src/modifiers/textConverter.js +12 -0
- package/src/modifiers/themeComponent.js +11 -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 +31 -33
- package/src/theme/default/base.js +29 -17
- package/src/theme/default/cyberpunkTheme.js +1 -0
- package/src/theme/default/darkTheme.js +2 -1
- package/src/theme/default/deepWoodsTheme.js +1 -0
- package/src/theme/default/forestTheme.js +1 -0
- package/src/theme/default/hackerTheme.js +40 -0
- package/src/theme/default/lightTheme.js +1 -0
- package/src/theme/default/midnightTheme.js +1 -0
- package/src/theme/default/msdosTheme.js +40 -0
- package/src/theme/default/oceanTheme.js +1 -0
- package/src/theme/default/pastelTheme.js +1 -0
- package/src/theme/default/sunsetTheme.js +1 -0
- package/src/theme/default/themes.js +4 -0
- package/src/theme/helpers/colorScale.js +11 -0
- package/src/theme/helpers/contrastColor.js +20 -0
- package/src/theme/helpers/dynamicColor.js +32 -0
- package/src/theme/helpers/mergePreset.js +7 -0
- package/src/theme/helpers/relatedScales.js +34 -0
- package/src/theme/helpers/sizeScale.js +17 -4
- package/src/theme/helpers/textScale.js +15 -0
- package/dist/actions/Button.js +0 -1
- package/dist/actions/index.js +0 -1
- package/dist/form/Form.js +0 -1
- package/dist/form/FormGroup.js +0 -1
- package/dist/form/FormItem.js +0 -1
- package/dist/form/FormList.js +0 -1
- package/dist/form/FormWrapperComponent.js +0 -1
- package/dist/form/FormWrapperComponent.native.js +0 -1
- package/dist/form/useForm.js +0 -1
- package/dist/modifiers/fullColor.js.js +0 -1
- package/dist/presentation/Icon.js +0 -1
- package/dist/presentation/Tag.js +0 -1
- package/dist/presentation/index.js +0 -1
- package/dist/structure/Card.js +0 -1
- package/dist/structure/View.js +0 -1
- package/dist/structure/index.js +0 -1
- package/dist/text/Text.js +0 -1
- package/dist/text/index.js +0 -1
- package/dist/theme/default/base.native.js +0 -1
- package/dist/theme/default/base.web.js +0 -1
- package/src/actions/Button.js +0 -48
- package/src/actions/index.js +0 -1
- package/src/form/Form.js +0 -14
- package/src/form/FormItem.js +0 -34
- package/src/form/FormWrapperComponent.js +0 -8
- package/src/form/FormWrapperComponent.native.js +0 -5
- package/src/form/useForm.js +0 -65
- package/src/modifiers/fullColor.js.js +0 -30
- package/src/presentation/Icon.js +0 -14
- package/src/presentation/Tag.js +0 -32
- package/src/presentation/index.js +0 -2
- package/src/structure/Card.js +0 -36
- package/src/structure/View.js +0 -34
- package/src/structure/index.js +0 -2
- package/src/text/Text.js +0 -20
- package/src/text/index.js +0 -1
- package/src/theme/default/base.native.js +0 -58
- package/src/theme/default/base.web.js +0 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
export function AbsSwitch({
|
|
4
|
+
value = false,
|
|
5
|
+
onValueChange = () => {},
|
|
6
|
+
disabled = false,
|
|
7
|
+
trackColor = { false: '#767577', true: '#81b0ff' },
|
|
8
|
+
thumbColor,
|
|
9
|
+
height = 32,
|
|
10
|
+
style,
|
|
11
|
+
...rest
|
|
12
|
+
}) {
|
|
13
|
+
const isOn = !!value
|
|
14
|
+
|
|
15
|
+
const handleToggle = useCallback(() => {
|
|
16
|
+
if (disabled) return
|
|
17
|
+
onValueChange(!isOn)
|
|
18
|
+
}, [disabled, isOn, onValueChange])
|
|
19
|
+
|
|
20
|
+
const onKeyDown = useCallback(
|
|
21
|
+
(e) => {
|
|
22
|
+
if (disabled) return
|
|
23
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
24
|
+
e.preventDefault()
|
|
25
|
+
onValueChange(!isOn)
|
|
26
|
+
}
|
|
27
|
+
if (e.key === 'ArrowLeft' && isOn) onValueChange(false)
|
|
28
|
+
if (e.key === 'ArrowRight' && !isOn) onValueChange(true)
|
|
29
|
+
},
|
|
30
|
+
[disabled, isOn, onValueChange]
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
const trackOff = (trackColor && trackColor.false) || '#76757750'
|
|
34
|
+
const trackOn = (trackColor && trackColor.true) || '#81b0ff'
|
|
35
|
+
const currentTrack = isOn ? trackOn : trackOff
|
|
36
|
+
|
|
37
|
+
const defaultThumb = '#ffffff'
|
|
38
|
+
const currentThumb = thumbColor || defaultThumb
|
|
39
|
+
|
|
40
|
+
const width = 1.7 * height
|
|
41
|
+
const padding = 2
|
|
42
|
+
const thumbSize = height - padding * 2
|
|
43
|
+
const translateX = isOn ? width - thumbSize - padding * 2 : 0
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
role="switch"
|
|
49
|
+
aria-checked={isOn}
|
|
50
|
+
aria-disabled={disabled}
|
|
51
|
+
onClick={handleToggle}
|
|
52
|
+
onKeyDown={onKeyDown}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
style={{
|
|
55
|
+
WebkitTapHighlightColor: 'transparent',
|
|
56
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
57
|
+
background: 'transparent',
|
|
58
|
+
border: 'none',
|
|
59
|
+
padding: 0,
|
|
60
|
+
margin: 0,
|
|
61
|
+
outline: 'none',
|
|
62
|
+
display: 'inline-flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
...style,
|
|
65
|
+
}}
|
|
66
|
+
{...rest}
|
|
67
|
+
>
|
|
68
|
+
<span
|
|
69
|
+
aria-hidden
|
|
70
|
+
style={{
|
|
71
|
+
position: 'relative',
|
|
72
|
+
width,
|
|
73
|
+
height,
|
|
74
|
+
borderRadius: height / 2,
|
|
75
|
+
backgroundColor: currentTrack,
|
|
76
|
+
transition: 'background-color 150ms ease',
|
|
77
|
+
_opacity: disabled ? 0.6 : 1,
|
|
78
|
+
display: 'inline-block',
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<span
|
|
82
|
+
style={{
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
top: padding,
|
|
85
|
+
left: padding + translateX,
|
|
86
|
+
width: thumbSize,
|
|
87
|
+
height: thumbSize,
|
|
88
|
+
borderRadius: thumbSize / 2,
|
|
89
|
+
backgroundColor: currentThumb,
|
|
90
|
+
boxShadow: '0 1px 2px rgba(0,0,0,0.2), 0 1px 1px rgba(0,0,0,0.1)',
|
|
91
|
+
transition: 'left 150ms ease, background-color 150ms ease',
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</span>
|
|
95
|
+
</button>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Switch as RNSwitch } from 'react-native'
|
|
2
|
+
|
|
3
|
+
export function AbsSwitch({ height, style, ...props }) {
|
|
4
|
+
const baseHeight = 31
|
|
5
|
+
let transform = undefined
|
|
6
|
+
if (!!height) {
|
|
7
|
+
const scale = height / baseHeight
|
|
8
|
+
transform = [{ scaleX: scale }, { scaleY: scale }]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return <RNSwitch style={{ transform, ...style }} {...props} />
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function AbsTable({ children, style, ...props }) {
|
|
2
|
+
return (
|
|
3
|
+
<table
|
|
4
|
+
{...props}
|
|
5
|
+
style={{
|
|
6
|
+
...style,
|
|
7
|
+
borderCollapse: 'separate',
|
|
8
|
+
borderSpacing: 0,
|
|
9
|
+
// orderCollapse: 'collapse',
|
|
10
|
+
// whiteSpace: 'nowrap',
|
|
11
|
+
width: '100%',
|
|
12
|
+
}}
|
|
13
|
+
>
|
|
14
|
+
<tbody>{children}</tbody>
|
|
15
|
+
</table>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function AbsTableRow({ ...props }) {
|
|
20
|
+
return <tr {...props} />
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function AbsTableHeader({ ...props }) {
|
|
24
|
+
return <th {...props} />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function AbsTableCol({ ...props }) {
|
|
28
|
+
return <td {...props} />
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { View } from 'react-native'
|
|
2
|
+
|
|
3
|
+
export function AbsTable({ children, ...props }) {
|
|
4
|
+
return <View {...props}>{children}</View>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function AbsTableRow({ style, ...props }) {
|
|
8
|
+
return <View {...props} style={[style, { flexDirection: 'row', flex: 1 }]} />
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function AbsTableHeader({ style, ...props }) {
|
|
12
|
+
if (!style.width && !style.minWidth && !style.flex) style.flex = 1
|
|
13
|
+
return <View {...props} style={[style]} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function AbsTableCol({ style, ...props }) {
|
|
17
|
+
if (!style.width && !style.minWidth && !style.flex) style.flex = 1
|
|
18
|
+
return <View {...props} style={style} />
|
|
19
|
+
}
|
package/src/abstractions/Text.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
export function AbsText(props) {
|
|
2
|
-
|
|
1
|
+
export function AbsText({ numberOfLines, style, ...props }) {
|
|
2
|
+
style = style || {}
|
|
3
|
+
|
|
4
|
+
const limitLinesStyle = !!numberOfLines
|
|
5
|
+
? {
|
|
6
|
+
display: '-webkit-box',
|
|
7
|
+
WebkitLineClamp: numberOfLines,
|
|
8
|
+
WebkitBoxOrient: 'vertical',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
}
|
|
11
|
+
: {}
|
|
12
|
+
|
|
13
|
+
return <span {...props} style={{ ...limitLinesStyle, ...style }} />
|
|
3
14
|
}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const { Platform, TouchableOpacity: RNTouchableOpacity } = require('react-native')
|
|
7
|
-
AbsTouchableOpacity = (props) => <RNTouchableOpacity {...props} />
|
|
8
|
-
} catch {
|
|
9
|
-
AbsTouchableOpacity = (props) => <button {...props} />
|
|
1
|
+
export function AbsTouchableOpacity({ link, onPress, onClick, ...props }) {
|
|
2
|
+
const Component = link ? 'a' : 'button'
|
|
3
|
+
return <Component onClick={onClick || onPress} {...props} />
|
|
10
4
|
}
|
|
11
|
-
|
|
12
|
-
export { AbsTouchableOpacity }
|
package/src/abstractions/View.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function AbsView(props) {
|
|
2
|
-
return <div {...props} />
|
|
1
|
+
export function AbsView({ onPress, onClick, ...props }) {
|
|
2
|
+
return <div onClick={onClick || onPress} {...props} />
|
|
3
3
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getElementSize(ref, callback) {
|
|
2
|
+
if (!ref.current) return
|
|
3
|
+
|
|
4
|
+
const el = ref.current
|
|
5
|
+
const rect = el.getBoundingClientRect()
|
|
6
|
+
|
|
7
|
+
callback({
|
|
8
|
+
width: el.offsetWidth,
|
|
9
|
+
height: el.offsetHeight,
|
|
10
|
+
x: rect.x + window.scrollX,
|
|
11
|
+
y: rect.y + window.scrollY,
|
|
12
|
+
})
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UIManager, findNodeHandle } from 'react-native'
|
|
2
|
+
|
|
3
|
+
export function getElementSize(ref, callback) {
|
|
4
|
+
if (!ref.current) return
|
|
5
|
+
|
|
6
|
+
const handle = findNodeHandle(ref.current)
|
|
7
|
+
if (handle) {
|
|
8
|
+
UIManager.measure(handle, (x, y, width, height) => {
|
|
9
|
+
callback({ width, height, x, y })
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export function useWindowWidth() {
|
|
4
|
+
const [width, setWidth] = React.useState(window.innerWidth)
|
|
5
|
+
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const handleResize = () => setWidth(window.innerWidth)
|
|
8
|
+
window.addEventListener('resize', handleResize)
|
|
9
|
+
return () => window.removeEventListener('resize', handleResize)
|
|
10
|
+
}, [])
|
|
11
|
+
|
|
12
|
+
return width
|
|
13
|
+
}
|
|
@@ -0,0 +1,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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTouchableOpacity } from '../../abstractions/TouchableOpacity'
|
|
4
|
+
import { IconLabel } from '../presentation/IconLabel'
|
|
5
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
6
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
7
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
8
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
9
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
10
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
11
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
12
|
+
import { useFullColorModifier } from '../../modifiers/fullColor'
|
|
13
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
14
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
15
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
16
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
17
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
18
|
+
import { useStateModifier } from '../../modifiers/state'
|
|
19
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
20
|
+
|
|
21
|
+
const DEFAULT_PROPS = ([{ sizeCode }]) => ({
|
|
22
|
+
paddingH: sizeCode,
|
|
23
|
+
paddingV: 2,
|
|
24
|
+
height: sizeCode,
|
|
25
|
+
br: sizeCode,
|
|
26
|
+
border: 1,
|
|
27
|
+
center: true,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export function Button(rootProps) {
|
|
31
|
+
const [{ loading, fontColor, sizeCode }, formattedProps] = pipe(
|
|
32
|
+
useColorConverter('primary'),
|
|
33
|
+
useSizeConverter('elementHeights', 'md'),
|
|
34
|
+
useThemeComponentModifier('Button'),
|
|
35
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
36
|
+
useFullColorModifier,
|
|
37
|
+
useDisplayModifier,
|
|
38
|
+
useStateModifier,
|
|
39
|
+
useSizeModifier,
|
|
40
|
+
usePositionModifier,
|
|
41
|
+
usePaddingModifier,
|
|
42
|
+
useMarginModifier,
|
|
43
|
+
useFlexModifier,
|
|
44
|
+
useFlexWrapperModifier,
|
|
45
|
+
useBackgroundModifier,
|
|
46
|
+
useBorderModifier
|
|
47
|
+
)([{}, rootProps])
|
|
48
|
+
|
|
49
|
+
const { label, icon, textProps, iconProps, gap, invert, size, ...props } = formattedProps
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<AbsTouchableOpacity className="neko-button neko-wave-click-effect" type="button" {...props}>
|
|
53
|
+
<IconLabel
|
|
54
|
+
center
|
|
55
|
+
color={fontColor}
|
|
56
|
+
size={sizeCode}
|
|
57
|
+
label={label}
|
|
58
|
+
icon={icon}
|
|
59
|
+
gap={gap}
|
|
60
|
+
invert={invert}
|
|
61
|
+
textProps={{ strong: true, ...textProps }}
|
|
62
|
+
iconProps={iconProps}
|
|
63
|
+
loading={loading}
|
|
64
|
+
/>
|
|
65
|
+
</AbsTouchableOpacity>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { pipe, is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTouchableOpacity } from '../../abstractions/TouchableOpacity'
|
|
4
|
+
import { LoadingView } from '../state/LoadingView'
|
|
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'
|
|
10
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
11
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
12
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
13
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
14
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
15
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
16
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
17
|
+
import { useStateModifier } from '../../modifiers/state'
|
|
18
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
19
|
+
|
|
20
|
+
export function Link({ label, children, href, target, ...rootProps }) {
|
|
21
|
+
const [{ loading, color: color }, props] = pipe(
|
|
22
|
+
useThemeComponentModifier('Link'),
|
|
23
|
+
useBackgroundModifier,
|
|
24
|
+
useColorConverter('primary'),
|
|
25
|
+
useAnimationModifier,
|
|
26
|
+
useSizeModifier, //
|
|
27
|
+
useFlexWrapperModifier,
|
|
28
|
+
useDisplayModifier,
|
|
29
|
+
useStateModifier,
|
|
30
|
+
useBorderModifier,
|
|
31
|
+
usePositionModifier,
|
|
32
|
+
usePaddingModifier,
|
|
33
|
+
useMarginModifier,
|
|
34
|
+
useFlexModifier
|
|
35
|
+
)([{}, rootProps])
|
|
36
|
+
|
|
37
|
+
if (!!label || is(String, children)) {
|
|
38
|
+
children = (
|
|
39
|
+
<Text color={color} {...props}>
|
|
40
|
+
{label || children}
|
|
41
|
+
</Text>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
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>
|
|
51
|
+
)
|
|
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
|
+
}
|