@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,128 @@
|
|
|
1
|
+
import { range, is, pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { Button } from '../actions/Button'
|
|
5
|
+
import { View } from '../structure/View'
|
|
6
|
+
import { moveScale } from '../../theme/helpers/sizeScale'
|
|
7
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
8
|
+
|
|
9
|
+
function getPageIndexes(pages, value, maxVisible = 5) {
|
|
10
|
+
if (pages <= maxVisible) {
|
|
11
|
+
return Array.from({ length: pages }, (_, i) => ({
|
|
12
|
+
label: i + 1,
|
|
13
|
+
value: i + 1,
|
|
14
|
+
}))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const middle = Math.floor(maxVisible / 2)
|
|
18
|
+
let start = value - middle
|
|
19
|
+
let end = value + middle
|
|
20
|
+
|
|
21
|
+
if (start < 1) {
|
|
22
|
+
start = 1
|
|
23
|
+
end = maxVisible
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (end > pages) {
|
|
27
|
+
end = pages
|
|
28
|
+
start = pages - maxVisible + 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const range = Array.from({ length: end - start + 1 }, (_, i) => start + i)
|
|
32
|
+
|
|
33
|
+
const result = []
|
|
34
|
+
|
|
35
|
+
if (start > 1) {
|
|
36
|
+
if (start === 2) {
|
|
37
|
+
result.push({ label: 1, value: 1 })
|
|
38
|
+
} else {
|
|
39
|
+
result.push({ label: '...', value: start - 1 })
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result.push(...range.map((p) => ({ label: p, value: p })))
|
|
44
|
+
|
|
45
|
+
if (end < pages) {
|
|
46
|
+
if (end === pages - 1) {
|
|
47
|
+
result.push({ label: pages, value: pages })
|
|
48
|
+
} else {
|
|
49
|
+
result.push({ label: '...', value: end + 1 })
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Item({ active, ...props }) {
|
|
57
|
+
return (
|
|
58
|
+
<Button
|
|
59
|
+
size="sm"
|
|
60
|
+
ratio={1}
|
|
61
|
+
color={active ? 'primary' : 'transparent'}
|
|
62
|
+
textProps={{ color: !active && 'text3' }}
|
|
63
|
+
iconProps={{ color: !active && 'text3' }}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function Pagination({
|
|
70
|
+
total = 0,
|
|
71
|
+
itemsPerPage = 10,
|
|
72
|
+
pages,
|
|
73
|
+
maxVisible = 5,
|
|
74
|
+
value,
|
|
75
|
+
initialValue = 1,
|
|
76
|
+
onChange,
|
|
77
|
+
...rootProps
|
|
78
|
+
}) {
|
|
79
|
+
const [{ sizeCode }, props] = pipe(
|
|
80
|
+
useSizeConverter('padding', 'md') //
|
|
81
|
+
)([{}, rootProps])
|
|
82
|
+
const size = moveScale(sizeCode, -1)
|
|
83
|
+
|
|
84
|
+
pages = pages || Math.ceil(total / itemsPerPage)
|
|
85
|
+
|
|
86
|
+
const [localValue, setLocalValue] = React.useState(initialValue)
|
|
87
|
+
value = value || localValue || initialValue
|
|
88
|
+
const handleChange = (v) => {
|
|
89
|
+
setLocalValue(v)
|
|
90
|
+
onChange?.(v)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const pageIndexes = getPageIndexes(pages, value, maxVisible)
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<View className="neko-pagination" row gap="xxs" {...props}>
|
|
97
|
+
<Item
|
|
98
|
+
icon="arrow-left-s-line"
|
|
99
|
+
disabled={value === 1}
|
|
100
|
+
onPress={() => handleChange(value - 1)}
|
|
101
|
+
size={size}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
{pageIndexes.map((item) => {
|
|
106
|
+
return (
|
|
107
|
+
<Item
|
|
108
|
+
key={item.value}
|
|
109
|
+
active={value === item.value}
|
|
110
|
+
onPress={() => handleChange(item.value)}
|
|
111
|
+
label={item.label}
|
|
112
|
+
disabled={is(String, item.value)}
|
|
113
|
+
size={size}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
})}
|
|
118
|
+
|
|
119
|
+
<Item
|
|
120
|
+
icon="arrow-right-s-line"
|
|
121
|
+
disabled={value === pages}
|
|
122
|
+
onPress={() => handleChange(value + 1)}
|
|
123
|
+
size={size}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
</View>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { AbsTable } from '../../abstractions/Table'
|
|
5
|
+
import { AbsView } from '../../abstractions/View'
|
|
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 { useMarginModifier } from '../../modifiers/margin'
|
|
11
|
+
import { useOverflowModifier } from '../../modifiers/overflow'
|
|
12
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
13
|
+
import { useShadowModifier } from '../../modifiers/shadow'
|
|
14
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
15
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
16
|
+
|
|
17
|
+
const TableContext = React.createContext(null)
|
|
18
|
+
export const useTable = () => React.useContext(TableContext) || {}
|
|
19
|
+
|
|
20
|
+
const DEFAULT_PROPS = {
|
|
21
|
+
br: 'md', //
|
|
22
|
+
overflow: 'scroll',
|
|
23
|
+
width: '100%',
|
|
24
|
+
relative: true,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function Table({ children, ...rootProps }) {
|
|
28
|
+
const [_, props] = pipe(
|
|
29
|
+
useThemeComponentModifier('Table'),
|
|
30
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
31
|
+
useDisplayModifier,
|
|
32
|
+
useSizeModifier,
|
|
33
|
+
useOverflowModifier,
|
|
34
|
+
usePaddingModifier,
|
|
35
|
+
useMarginModifier,
|
|
36
|
+
useBackgroundModifier,
|
|
37
|
+
useBorderModifier,
|
|
38
|
+
useShadowModifier
|
|
39
|
+
)([{}, rootProps])
|
|
40
|
+
|
|
41
|
+
const scrollRef = React.useRef()
|
|
42
|
+
const [scrolledToMaxLeft, setScrolledToMaxLeft] = React.useState(true)
|
|
43
|
+
const [scrolledToMaxRight, setScrolledToMaxRight] = React.useState(false)
|
|
44
|
+
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const el = scrollRef.current
|
|
47
|
+
if (!el || !el.addEventListener) return
|
|
48
|
+
|
|
49
|
+
const onScroll = () => {
|
|
50
|
+
setScrolledToMaxLeft(el.scrollLeft === 0)
|
|
51
|
+
setScrolledToMaxRight(el.scrollLeft + el.clientWidth >= el.scrollWidth - 1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
el.addEventListener('scroll', onScroll)
|
|
55
|
+
return () => el.removeEventListener('scroll', onScroll)
|
|
56
|
+
}, [])
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<TableContext.Provider value={{ scrolledToMaxLeft, scrolledToMaxRight }}>
|
|
60
|
+
<AbsView {...props} className="neko-table-wrapper" ref={scrollRef}>
|
|
61
|
+
<AbsTable className="neko-table">{children}</AbsTable>
|
|
62
|
+
</AbsView>
|
|
63
|
+
</TableContext.Provider>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { pipe, is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTableCol } from '../../abstractions/Table'
|
|
4
|
+
import { Text } from '../text/Text'
|
|
5
|
+
import { View } from '../structure/View'
|
|
6
|
+
import { useAlignConverter } from '../../modifiers/alignConverter'
|
|
7
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
8
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
9
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
10
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
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 { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
17
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
18
|
+
import { useTable } from './Table'
|
|
19
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
20
|
+
|
|
21
|
+
const DEFAULT_PROPS =
|
|
22
|
+
({ scrolledToMaxLeft, scrolledToMaxRight }) =>
|
|
23
|
+
([{ sizeCode }, { sticky, left, right }]) => ({
|
|
24
|
+
bg: 'overlayBG',
|
|
25
|
+
paddingH: ['xxxs', 'xxs', 'xs'].includes(sizeCode) ? 'sm' : sizeCode,
|
|
26
|
+
paddingV: sizeCode,
|
|
27
|
+
borderB: true, //
|
|
28
|
+
margin: 0,
|
|
29
|
+
borderR: left !== undefined && !!sticky && !scrolledToMaxLeft,
|
|
30
|
+
borderL: right !== undefined && !!sticky && !scrolledToMaxRight,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export function TableCol({ label, children, strong, color, colSpan, rowSpan, ...rootProps }) {
|
|
34
|
+
const { scrolledToMaxLeft, scrolledToMaxRight } = useTable()
|
|
35
|
+
|
|
36
|
+
const [{ sizeCode, align }, { style, ...props }] = pipe(
|
|
37
|
+
useAlignConverter('left'),
|
|
38
|
+
useSizeConverter('padding', 'md'),
|
|
39
|
+
useThemeComponentModifier('TableCol'),
|
|
40
|
+
useDefaultModifier(DEFAULT_PROPS({ scrolledToMaxLeft, scrolledToMaxRight })),
|
|
41
|
+
useDisplayModifier,
|
|
42
|
+
usePositionModifier,
|
|
43
|
+
useSizeModifier,
|
|
44
|
+
useOverflowModifier,
|
|
45
|
+
usePaddingModifier,
|
|
46
|
+
useMarginModifier,
|
|
47
|
+
useBackgroundModifier,
|
|
48
|
+
useBorderModifier,
|
|
49
|
+
useShadowModifier
|
|
50
|
+
)([{}, rootProps])
|
|
51
|
+
|
|
52
|
+
if (!!label || is(String, children) || is(Number, children)) {
|
|
53
|
+
children = (
|
|
54
|
+
<Text strong={!!strong} color={color} size={sizeCode} align={align}>
|
|
55
|
+
{label || children}
|
|
56
|
+
</Text>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<AbsTableCol className="neko-table-col" style={style} colSpan={colSpan} rowSpan={rowSpan}>
|
|
62
|
+
<View className="neko-table-col-content" fullW fullH align={align} centerV {...props}>
|
|
63
|
+
{children}
|
|
64
|
+
</View>
|
|
65
|
+
</AbsTableCol>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { pipe, is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTableHeader } from '../../abstractions/Table'
|
|
4
|
+
import { Text } from '../text/Text'
|
|
5
|
+
import { View } from '../structure/View'
|
|
6
|
+
import { moveScale } from '../../theme/helpers/sizeScale'
|
|
7
|
+
import { useAlignConverter } from '../../modifiers/alignConverter'
|
|
8
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
9
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
10
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
11
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
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 { useShadowModifier } from '../../modifiers/shadow'
|
|
17
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
18
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
19
|
+
import { useTable } from './Table'
|
|
20
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
21
|
+
|
|
22
|
+
const DEFAULT_PROPS =
|
|
23
|
+
({ scrolledToMaxLeft, scrolledToMaxRight }) =>
|
|
24
|
+
([{ sizeCode }, { sticky, left, right }]) => ({
|
|
25
|
+
bg: 'overlayBG',
|
|
26
|
+
paddingH: ['xxxs', 'xxs', 'xs'].includes(sizeCode) ? 'sm' : sizeCode,
|
|
27
|
+
paddingV: moveScale(sizeCode, -1),
|
|
28
|
+
borderB: true,
|
|
29
|
+
margin: 0,
|
|
30
|
+
borderR: left !== undefined && !!sticky && !scrolledToMaxLeft,
|
|
31
|
+
borderL: right !== undefined && !!sticky && !scrolledToMaxRight,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export function TableHeader({ children, label, colSpan, rowSpan, ...rootProps }) {
|
|
35
|
+
const { scrolledToMaxLeft, scrolledToMaxRight } = useTable()
|
|
36
|
+
|
|
37
|
+
const [{ sizeCode, align }, { style, ...props }] = pipe(
|
|
38
|
+
useAlignConverter('left'),
|
|
39
|
+
useSizeConverter('padding', 'md'),
|
|
40
|
+
useThemeComponentModifier('TableHeader'),
|
|
41
|
+
useDefaultModifier(DEFAULT_PROPS({ scrolledToMaxLeft, scrolledToMaxRight })),
|
|
42
|
+
useDisplayModifier,
|
|
43
|
+
usePositionModifier,
|
|
44
|
+
useSizeModifier,
|
|
45
|
+
useOverflowModifier,
|
|
46
|
+
usePaddingModifier,
|
|
47
|
+
useMarginModifier,
|
|
48
|
+
useBackgroundModifier,
|
|
49
|
+
useBorderModifier,
|
|
50
|
+
useShadowModifier
|
|
51
|
+
)([{}, rootProps])
|
|
52
|
+
|
|
53
|
+
if (!!label || is(String, children)) {
|
|
54
|
+
console.log(sizeCode, moveScale(sizeCode, -1))
|
|
55
|
+
children = (
|
|
56
|
+
<Text strong text3 fullW block align={align} size={moveScale(sizeCode, -1)}>
|
|
57
|
+
{label || children}
|
|
58
|
+
</Text>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<AbsTableHeader className="neko-table-header" style={style} colSpan={colSpan} rowSpan={rowSpan}>
|
|
64
|
+
<View className="neko-table-header-content" fullW fullH align={align} centerV {...props}>
|
|
65
|
+
{children}
|
|
66
|
+
</View>
|
|
67
|
+
</AbsTableHeader>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTableRow } from '../../abstractions/Table'
|
|
4
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
5
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
6
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
7
|
+
import { useOverflowModifier } from '../../modifiers/overflow'
|
|
8
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
9
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
10
|
+
|
|
11
|
+
const DEFAULT_PROPS = {
|
|
12
|
+
top: 0,
|
|
13
|
+
zIndex: 40,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function TableHeaderRow({ children, ...rootProps }) {
|
|
17
|
+
const [_, props] = pipe(
|
|
18
|
+
useThemeComponentModifier('TableHeaderRow'),
|
|
19
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
20
|
+
useDisplayModifier,
|
|
21
|
+
usePositionModifier,
|
|
22
|
+
useOverflowModifier,
|
|
23
|
+
useBackgroundModifier
|
|
24
|
+
)([{}, rootProps])
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<AbsTableRow className="neko-table-header-row" {...props}>
|
|
28
|
+
{children}
|
|
29
|
+
</AbsTableRow>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsTableRow } from '../../abstractions/Table'
|
|
4
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
5
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
6
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
7
|
+
import { useOverflowModifier } from '../../modifiers/overflow'
|
|
8
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
9
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
10
|
+
|
|
11
|
+
const DEFAULT_PROPS = {
|
|
12
|
+
// bg: 'green',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function TableRow({ children, ...rootProps }) {
|
|
16
|
+
const [_, props] = pipe(
|
|
17
|
+
useThemeComponentModifier('TableRow'),
|
|
18
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
19
|
+
useDisplayModifier,
|
|
20
|
+
usePositionModifier,
|
|
21
|
+
useOverflowModifier,
|
|
22
|
+
useBackgroundModifier
|
|
23
|
+
)([{}, rootProps])
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<AbsTableRow className="neko-table-row" {...props}>
|
|
27
|
+
{children}
|
|
28
|
+
</AbsTableRow>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsText } from '../../abstractions/Text'
|
|
4
|
+
import { useAnimationModifier } from '../../modifiers/animation'
|
|
5
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
6
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
7
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
8
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
9
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
10
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
11
|
+
import { useTextConverter } from '../../modifiers/textConverter'
|
|
12
|
+
import { useTextModifier } from '../../modifiers/text'
|
|
13
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
14
|
+
|
|
15
|
+
export function Text({ children, label, ...rootProps }) {
|
|
16
|
+
const [_, props] = pipe(
|
|
17
|
+
useColorConverter('text'),
|
|
18
|
+
useTextConverter('p'),
|
|
19
|
+
useThemeComponentModifier('Text'),
|
|
20
|
+
useAnimationModifier,
|
|
21
|
+
useDisplayModifier,
|
|
22
|
+
useSizeModifier, //
|
|
23
|
+
usePaddingModifier,
|
|
24
|
+
useMarginModifier,
|
|
25
|
+
useFlexModifier,
|
|
26
|
+
useTextModifier
|
|
27
|
+
)([{}, rootProps])
|
|
28
|
+
|
|
29
|
+
return <AbsText {...props}>{children || label}</AbsText>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const Title = Text
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsText } from '../../abstractions/Text'
|
|
4
|
+
import { VerticalView } from '../helpers/VerticalView'
|
|
5
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
6
|
+
import { useTextConverter } from '../../modifiers/textConverter'
|
|
7
|
+
import { useTextModifier } from '../../modifiers/text'
|
|
8
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
9
|
+
|
|
10
|
+
export function VerticalText({ children, label, invert, ...rootProps }) {
|
|
11
|
+
const [_, { style, ...props }] = pipe(
|
|
12
|
+
useColorConverter('text'),
|
|
13
|
+
useTextConverter('p'),
|
|
14
|
+
useThemeComponentModifier('VerticalText'),
|
|
15
|
+
useTextModifier
|
|
16
|
+
)([{}, rootProps])
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<VerticalView invert={invert} {...props}>
|
|
20
|
+
<AbsText
|
|
21
|
+
style={{
|
|
22
|
+
...style,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{children || label}
|
|
26
|
+
</AbsText>
|
|
27
|
+
</VerticalView>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { is, propEq } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function formatOptions(options) {
|
|
5
|
+
if (!options?.length) return options
|
|
6
|
+
return options.map((option) => {
|
|
7
|
+
if (is(String, option) || is(Number, option)) {
|
|
8
|
+
return { label: option, value: option }
|
|
9
|
+
}
|
|
10
|
+
return option
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useOptions(optionsOrFetch, { limit } = {}) {
|
|
15
|
+
const isLazy = !is(Array, optionsOrFetch)
|
|
16
|
+
const [loading, setLoading] = React.useState(isLazy)
|
|
17
|
+
const [options, setOptions] = React.useState([])
|
|
18
|
+
const [page, setPage] = React.useState(1)
|
|
19
|
+
const [done, setDone] = React.useState(!isLazy)
|
|
20
|
+
|
|
21
|
+
const isFirstLoad = page === 1 && !options?.length && loading
|
|
22
|
+
const isRefetching = page === 1 && !!options.length && loading
|
|
23
|
+
const isFetchingMore = page > 1 && !!options.length && loading
|
|
24
|
+
|
|
25
|
+
const handleGetOptions = (page = 1) => {
|
|
26
|
+
setDone(false)
|
|
27
|
+
setPage(page)
|
|
28
|
+
setLoading(true)
|
|
29
|
+
optionsOrFetch(optionsOrFetch, page)
|
|
30
|
+
.then((result) => {
|
|
31
|
+
if (result?.length < limit) setDone(true)
|
|
32
|
+
let newOptions = []
|
|
33
|
+
if (page > 1) newOptions = options
|
|
34
|
+
setOptions([...newOptions, ...result])
|
|
35
|
+
})
|
|
36
|
+
.finally(() => setLoading(false))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const fetchMore = () => {
|
|
40
|
+
const newPage = (page || 1) + 1
|
|
41
|
+
handleGetOptions(newPage)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (isLazy) handleGetOptions()
|
|
46
|
+
}, [limit])
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
options: formatOptions(isLazy ? options : optionsOrFetch),
|
|
50
|
+
handleGetOptions,
|
|
51
|
+
fetchMore,
|
|
52
|
+
done,
|
|
53
|
+
page,
|
|
54
|
+
done,
|
|
55
|
+
limit,
|
|
56
|
+
loading,
|
|
57
|
+
isFirstLoad,
|
|
58
|
+
isRefetching,
|
|
59
|
+
isFetchingMore,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function findOptionByValue(options, value) {
|
|
64
|
+
return options.find(propEq('value', value))
|
|
65
|
+
}
|
package/src/index.css
CHANGED
|
@@ -25,6 +25,12 @@ body {
|
|
|
25
25
|
min-height: 100vh;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
a,
|
|
29
|
+
button {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
text-decoration: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
.neko-wave-click-effect {
|
|
29
35
|
position: relative;
|
|
30
36
|
padding: 10px 20px;
|
|
@@ -66,3 +72,12 @@ body {
|
|
|
66
72
|
transform: scale(1.3);
|
|
67
73
|
}
|
|
68
74
|
}
|
|
75
|
+
|
|
76
|
+
@keyframes spin {
|
|
77
|
+
0% {
|
|
78
|
+
transform: rotate(0deg);
|
|
79
|
+
}
|
|
80
|
+
100% {
|
|
81
|
+
transform: rotate(360deg);
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './actions'
|
|
4
|
-
export * from './presentation'
|
|
5
|
-
export * from './text'
|
|
1
|
+
export * from './helpers'
|
|
2
|
+
export * from './components'
|
|
6
3
|
export * from './theme'
|
|
4
|
+
export * from './responsive'
|
|
7
5
|
export * from './NekoUI'
|
|
8
6
|
|
|
9
7
|
export const version = 41
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function useAlignConverter(defaultValue) {
|
|
2
|
+
return ([values, props]) => {
|
|
3
|
+
let align = props.align
|
|
4
|
+
if (!align && props.center) align = 'center'
|
|
5
|
+
if (!align && props.toRight) align = 'right'
|
|
6
|
+
if (!align && props.toLeft) align = 'left'
|
|
7
|
+
if (!align) align = defaultValue
|
|
8
|
+
|
|
9
|
+
return [{ align }, { ...props, align }]
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { clearProps } from './_helpers'
|
|
2
|
+
|
|
3
|
+
export function useAnimationModifier([values, props]) {
|
|
4
|
+
let { transition, ...restProps } = props
|
|
5
|
+
|
|
6
|
+
const style = clearProps({ transition })
|
|
7
|
+
|
|
8
|
+
return [
|
|
9
|
+
values,
|
|
10
|
+
{
|
|
11
|
+
...restProps,
|
|
12
|
+
style: {
|
|
13
|
+
...props.style,
|
|
14
|
+
...style,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
}
|