@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,45 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
4
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
5
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
6
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
7
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
8
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
9
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
10
|
+
import { useOverflowModifier } from '../../modifiers/overflow'
|
|
11
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
12
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
13
|
+
import { useShadowModifier } from '../../modifiers/shadow'
|
|
14
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
15
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
16
|
+
|
|
17
|
+
const DEFAULT_PROPS = {
|
|
18
|
+
padding: 'md', //
|
|
19
|
+
br: 'xl',
|
|
20
|
+
bg: 'overlayBG',
|
|
21
|
+
hiddenOverflow: true,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Card({ children, ...rootProps }) {
|
|
25
|
+
const [_, props] = pipe(
|
|
26
|
+
useThemeComponentModifier('Card'),
|
|
27
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
28
|
+
useSizeModifier, //
|
|
29
|
+
usePositionModifier,
|
|
30
|
+
useOverflowModifier,
|
|
31
|
+
usePaddingModifier,
|
|
32
|
+
useMarginModifier,
|
|
33
|
+
useFlexWrapperModifier,
|
|
34
|
+
useFlexModifier,
|
|
35
|
+
useBackgroundModifier,
|
|
36
|
+
useBorderModifier,
|
|
37
|
+
useShadowModifier
|
|
38
|
+
)([{}, rootProps])
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<AbsView className="neko-card" {...props}>
|
|
42
|
+
{children}
|
|
43
|
+
</AbsView>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { View } from './View'
|
|
4
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
5
|
+
import { useResponsiveConverter } from '../../modifiers/responsiveConverter'
|
|
6
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
7
|
+
|
|
8
|
+
const DEFAULT_PROPS = {}
|
|
9
|
+
|
|
10
|
+
export function Col({ children, ...rootProps }) {
|
|
11
|
+
const [_, props] = pipe(
|
|
12
|
+
useThemeComponentModifier('Col'), //
|
|
13
|
+
useResponsiveConverter([]),
|
|
14
|
+
useDefaultModifier(DEFAULT_PROPS)
|
|
15
|
+
)([{}, rootProps])
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<View className="neko-col" {...props}>
|
|
19
|
+
{children}
|
|
20
|
+
</View>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { AbsView } from '../../abstractions/View'
|
|
5
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
6
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
7
|
+
import { useGridModifier } from '../../modifiers/grid'
|
|
8
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
9
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
10
|
+
import { useResponsiveConverter } from '../../modifiers/responsiveConverter'
|
|
11
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
12
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
13
|
+
|
|
14
|
+
export function Row({ children, ...rootProps }) {
|
|
15
|
+
const [{ childPaddingProps }, { colSpan, ...props }] = pipe(
|
|
16
|
+
useThemeComponentModifier('Row'),
|
|
17
|
+
useResponsiveConverter([]),
|
|
18
|
+
useGridModifier,
|
|
19
|
+
useSizeModifier, //
|
|
20
|
+
usePositionModifier,
|
|
21
|
+
useFlexWrapperModifier,
|
|
22
|
+
useFlexModifier,
|
|
23
|
+
useMarginModifier
|
|
24
|
+
)([{}, rootProps])
|
|
25
|
+
|
|
26
|
+
// Memoiza os children clonados para evitar recriação se childPaddingProps não mudar
|
|
27
|
+
const clonedChildren = React.useMemo(
|
|
28
|
+
() =>
|
|
29
|
+
React.Children.map(children, (child) =>
|
|
30
|
+
React.isValidElement(child) ? React.cloneElement(child, { parentSpan: colSpan, ...childPaddingProps }) : child
|
|
31
|
+
),
|
|
32
|
+
[children, childPaddingProps]
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<AbsView className="neko-row" {...props}>
|
|
37
|
+
{clonedChildren}
|
|
38
|
+
</AbsView>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Grid = Row
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsSafeAreaView } from '../../abstractions/SafeAreaView'
|
|
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 SafeAreaView({ children, ...rootProps }) {
|
|
20
|
+
const [_, props] = pipe(
|
|
21
|
+
useThemeComponentModifier('SafeAreaView'),
|
|
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
|
+
<AbsSafeAreaView className="neko-safe-area-view" {...props}>
|
|
39
|
+
{children}
|
|
40
|
+
</AbsSafeAreaView>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
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 View({ children, ...rootProps }) {
|
|
20
|
+
const [_, props] = pipe(
|
|
21
|
+
useThemeComponentModifier('View'),
|
|
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
|
+
<AbsView className="neko-view" {...props}>
|
|
39
|
+
{children}
|
|
40
|
+
</AbsView>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { toPairs, dissoc } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { OverlayWrapper } from './OverlayWrapper'
|
|
5
|
+
import { Text } from '../../text/Text'
|
|
6
|
+
import { genRandonId } from '../../../helpers/random'
|
|
7
|
+
|
|
8
|
+
const OverlayContext = React.createContext(null)
|
|
9
|
+
|
|
10
|
+
export const useOverlay = () => React.useContext(OverlayContext)
|
|
11
|
+
|
|
12
|
+
export const useRegisterOverlay = (opts = {}) => {
|
|
13
|
+
const { unmountOnClose } = opts
|
|
14
|
+
const timeout = React.useRef(null)
|
|
15
|
+
const { overlays, setOverlays } = useOverlay()
|
|
16
|
+
const randomId = React.useMemo(() => genRandonId(), [])
|
|
17
|
+
const overlay = overlays[randomId] || {}
|
|
18
|
+
const mergeOverlay = (value) => setOverlays((data) => ({ ...data, [randomId]: { ...overlay, ...value } }))
|
|
19
|
+
const closeOverlay = () => mergeOverlay({ open: false })
|
|
20
|
+
const removeOverlay = () => setOverlays((data) => dissoc(randomId, data))
|
|
21
|
+
const stopDelayedClosing = () => !!timeout?.current && clearTimeout(timeout.current)
|
|
22
|
+
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
return () => removeOverlay()
|
|
25
|
+
}, [])
|
|
26
|
+
|
|
27
|
+
const onOpen = ({ content, triggerRect, placement, options = {} }) => {
|
|
28
|
+
stopDelayedClosing()
|
|
29
|
+
mergeOverlay({ open: true, content, triggerRect, placement, ...options })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const onClose = () => {
|
|
33
|
+
stopDelayedClosing()
|
|
34
|
+
timeout.current = setTimeout(() => {
|
|
35
|
+
!!unmountOnClose ? removeOverlay() : closeOverlay()
|
|
36
|
+
}, 250)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const onFastClose = () => {
|
|
40
|
+
stopDelayedClosing()
|
|
41
|
+
!!unmountOnClose ? removeOverlay() : closeOverlay()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return { onOpen, onClose, onFastClose, stopDelayedClosing }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function OverlayHandler({ children }) {
|
|
48
|
+
const [overlays, setOverlays] = React.useState({})
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<OverlayContext.Provider value={{ overlays, setOverlays }}>
|
|
52
|
+
{children}
|
|
53
|
+
|
|
54
|
+
{toPairs(overlays).map(([key, overlay]) => {
|
|
55
|
+
const handleClickOutside = () => setTimeout(() => setOverlays((data) => dissoc(key, data)), 100)
|
|
56
|
+
return (
|
|
57
|
+
<OverlayWrapper
|
|
58
|
+
key={key}
|
|
59
|
+
triggerRect={overlay.triggerRect}
|
|
60
|
+
placement={overlay.placement}
|
|
61
|
+
onClickOutside={overlay.dismissOnClickOutside ? handleClickOutside : null}
|
|
62
|
+
display={!overlay.open && 'none'}
|
|
63
|
+
>
|
|
64
|
+
{overlay.content}
|
|
65
|
+
</OverlayWrapper>
|
|
66
|
+
)
|
|
67
|
+
})}
|
|
68
|
+
</OverlayContext.Provider>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from '../View'
|
|
3
|
+
import { calculatePosition } from './calculatePosition'
|
|
4
|
+
import { smartPlacement } from './smartPlacement' // você cria esse helper
|
|
5
|
+
|
|
6
|
+
export function OverlayWrapper({ children, triggerRect, placement, onClickOutside, ...props }) {
|
|
7
|
+
const overlayRef = React.useRef(null)
|
|
8
|
+
const [pos, setPos] = React.useState({ x: -9999, y: -9999 })
|
|
9
|
+
|
|
10
|
+
React.useLayoutEffect(() => {
|
|
11
|
+
if (overlayRef.current && triggerRect) {
|
|
12
|
+
const rect = overlayRef.current.getBoundingClientRect()
|
|
13
|
+
const popoverRect = { width: rect.width, height: rect.height }
|
|
14
|
+
|
|
15
|
+
const safePlacement = smartPlacement(triggerRect, popoverRect, placement)
|
|
16
|
+
setPos(calculatePosition(triggerRect, popoverRect, safePlacement))
|
|
17
|
+
}
|
|
18
|
+
}, [triggerRect, placement, children])
|
|
19
|
+
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (onClickOutside) {
|
|
22
|
+
const handleClickOutside = (event) => {
|
|
23
|
+
if (overlayRef.current && !overlayRef.current.contains(event.target)) {
|
|
24
|
+
onClickOutside()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
document.addEventListener('mousedown', handleClickOutside, true)
|
|
29
|
+
}, 10)
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
clearTimeout(timer)
|
|
33
|
+
document.removeEventListener('mousedown', handleClickOutside, true)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [onClickOutside])
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View
|
|
40
|
+
ref={overlayRef}
|
|
41
|
+
className="neko-overlay-wrapper"
|
|
42
|
+
absolute
|
|
43
|
+
top={pos.y}
|
|
44
|
+
left={pos.x}
|
|
45
|
+
zIndex={9999}
|
|
46
|
+
pointerEvents="none"
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</View>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function calculatePosition(triggerRect, popoverRect, placement, gap = 2) {
|
|
2
|
+
const { left, right, top, bottom, width, height } = triggerRect
|
|
3
|
+
const pw = popoverRect?.width || 0
|
|
4
|
+
const ph = popoverRect?.height || 0
|
|
5
|
+
|
|
6
|
+
const positions = {
|
|
7
|
+
// Top
|
|
8
|
+
top: { x: left + width / 2 - pw / 2, y: top - ph - gap },
|
|
9
|
+
topLeft: { x: left, y: top - ph - gap },
|
|
10
|
+
topRight: { x: right - pw, y: top - ph - gap },
|
|
11
|
+
|
|
12
|
+
// Bottom
|
|
13
|
+
bottom: { x: left + width / 2 - pw / 2, y: bottom + gap },
|
|
14
|
+
bottomLeft: { x: left, y: bottom + gap },
|
|
15
|
+
bottomRight: { x: right - pw, y: bottom + gap },
|
|
16
|
+
|
|
17
|
+
// Left
|
|
18
|
+
left: { x: left - pw - gap, y: top + height / 2 - ph / 2 },
|
|
19
|
+
leftTop: { x: left - pw - gap, y: top },
|
|
20
|
+
leftBottom: { x: left - pw - gap, y: bottom - ph },
|
|
21
|
+
|
|
22
|
+
// Right
|
|
23
|
+
right: { x: right + gap, y: top + height / 2 - ph / 2 },
|
|
24
|
+
rightTop: { x: right + gap, y: top },
|
|
25
|
+
rightBottom: { x: right + gap, y: bottom - ph },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return positions[placement] || positions.bottom
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function smartPlacement(triggerRect, popoverRect, placement) {
|
|
2
|
+
const scrollX = window.scrollX || window.pageXOffset
|
|
3
|
+
const scrollY = window.scrollY || window.pageYOffset
|
|
4
|
+
const screenWidth = window.innerWidth
|
|
5
|
+
const screenHeight = window.innerHeight
|
|
6
|
+
|
|
7
|
+
const viewportRect = {
|
|
8
|
+
left: triggerRect.left - scrollX,
|
|
9
|
+
right: triggerRect.right - scrollX,
|
|
10
|
+
top: triggerRect.top - scrollY,
|
|
11
|
+
bottom: triggerRect.bottom - scrollY,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const fitsRight = viewportRect.right + popoverRect.width <= screenWidth
|
|
15
|
+
const fitsLeft = viewportRect.left - popoverRect.width >= 0
|
|
16
|
+
const fitsBottom = viewportRect.bottom + popoverRect.height <= screenHeight
|
|
17
|
+
const fitsTop = viewportRect.top - popoverRect.height >= 0
|
|
18
|
+
|
|
19
|
+
if (placement.startsWith('right') && !fitsRight && fitsLeft) return placement.replace('right', 'left')
|
|
20
|
+
if (placement.endsWith('Right') && !fitsLeft && fitsRight) return placement.replace('Right', 'Left')
|
|
21
|
+
|
|
22
|
+
if (placement.startsWith('left') && !fitsLeft && fitsRight) return placement.replace('left', 'right')
|
|
23
|
+
if (placement.endsWith('Left') && !fitsRight && fitsLeft) return placement.replace('Left', 'Right')
|
|
24
|
+
|
|
25
|
+
if (placement.startsWith('bottom') && !fitsBottom && fitsTop) return placement.replace('bottom', 'top')
|
|
26
|
+
if (placement.endsWith('Bottom') && !fitsTop && fitsBottom) return placement.replace('Bottom', 'Top')
|
|
27
|
+
|
|
28
|
+
if (placement.startsWith('top') && !fitsTop && fitsBottom) return placement.replace('top', 'bottom')
|
|
29
|
+
if (placement.endsWith('Top') && !fitsBottom && fitsTop) return placement.replace('Top', 'Bottom')
|
|
30
|
+
|
|
31
|
+
return placement
|
|
32
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { PopoverContent } from './PopoverContent'
|
|
4
|
+
import { useRegisterOverlay } from '../overlay/OverlayHandler'
|
|
5
|
+
|
|
6
|
+
export function Popover({
|
|
7
|
+
renderContent,
|
|
8
|
+
content,
|
|
9
|
+
trigger = 'hover',
|
|
10
|
+
placement = 'bottom',
|
|
11
|
+
unmountOnClose,
|
|
12
|
+
children,
|
|
13
|
+
parentWidth,
|
|
14
|
+
parentMinWidth,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
const ref = React.useRef(null)
|
|
18
|
+
const { onOpen, onClose, onFastClose, stopDelayedClosing } = useRegisterOverlay({ unmountOnClose })
|
|
19
|
+
|
|
20
|
+
const click = trigger === 'click'
|
|
21
|
+
const hover = trigger === 'hover'
|
|
22
|
+
const focus = trigger === 'focus'
|
|
23
|
+
|
|
24
|
+
renderContent = renderContent || (() => content)
|
|
25
|
+
|
|
26
|
+
const show = (e) => {
|
|
27
|
+
if (e && e.stopPropagation) e.stopPropagation()
|
|
28
|
+
const rect = ref.current.getBoundingClientRect()
|
|
29
|
+
const scrollX = window.scrollX || window.pageXOffset
|
|
30
|
+
const scrollY = window.scrollY || window.pageYOffset
|
|
31
|
+
|
|
32
|
+
const triggerRect = {
|
|
33
|
+
left: rect.left + scrollX,
|
|
34
|
+
right: rect.right + scrollX,
|
|
35
|
+
top: rect.top + scrollY,
|
|
36
|
+
bottom: rect.bottom + scrollY,
|
|
37
|
+
width: rect.width,
|
|
38
|
+
height: rect.height,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onOpen({
|
|
42
|
+
content: (
|
|
43
|
+
<PopoverContent
|
|
44
|
+
placement={placement}
|
|
45
|
+
width={parentWidth ? rect.width : undefined}
|
|
46
|
+
minWidth={parentMinWidth ? rect.width : undefined}
|
|
47
|
+
{...props}
|
|
48
|
+
onMouseEnter={hover ? stopDelayedClosing : undefined}
|
|
49
|
+
onMouseLeave={hover ? onClose : undefined}
|
|
50
|
+
>
|
|
51
|
+
{renderContent({ onClose: onFastClose })}
|
|
52
|
+
</PopoverContent>
|
|
53
|
+
),
|
|
54
|
+
triggerRect,
|
|
55
|
+
placement,
|
|
56
|
+
options: { dismissOnClickOutside: !!click },
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
React.useEffect(() => () => onClose(), [])
|
|
61
|
+
|
|
62
|
+
const child = React.Children.only(children)
|
|
63
|
+
let childProps = { ref, onClick: show }
|
|
64
|
+
|
|
65
|
+
if (hover) childProps = { ref, onMouseEnter: show, onMouseLeave: onClose }
|
|
66
|
+
if (focus) childProps = { ref, onFocus: show, onBlur: onClose }
|
|
67
|
+
|
|
68
|
+
return React.cloneElement(child, childProps)
|
|
69
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Modal, TouchableWithoutFeedback } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { PopoverContent } from './PopoverContent'
|
|
5
|
+
import { View } from '../View'
|
|
6
|
+
import { calculatePosition } from '../overlay/calculatePosition'
|
|
7
|
+
|
|
8
|
+
export function Popover({ content, placement = 'bottom', children, ...props }) {
|
|
9
|
+
const ref = React.useRef(null)
|
|
10
|
+
const [visible, setVisible] = React.useState(false)
|
|
11
|
+
const [triggerRect, setTriggerRect] = React.useState(null)
|
|
12
|
+
const [position, setPosition] = React.useState(null)
|
|
13
|
+
|
|
14
|
+
const show = () => {
|
|
15
|
+
if (ref.current) {
|
|
16
|
+
ref.current.measureInWindow((x, y, width, height) => {
|
|
17
|
+
setTriggerRect({
|
|
18
|
+
left: x,
|
|
19
|
+
top: y,
|
|
20
|
+
right: x + width,
|
|
21
|
+
bottom: y + height,
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
})
|
|
25
|
+
setVisible(true)
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const hide = () => {
|
|
31
|
+
setVisible(false)
|
|
32
|
+
setTriggerRect(null)
|
|
33
|
+
setPosition(null)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<View ref={ref}>
|
|
39
|
+
{React.cloneElement(React.Children.only(children), {
|
|
40
|
+
onPress: show,
|
|
41
|
+
})}
|
|
42
|
+
</View>
|
|
43
|
+
|
|
44
|
+
{visible && (
|
|
45
|
+
<Modal transparent visible={visible} animationType="fade" onRequestClose={hide}>
|
|
46
|
+
<View fullW flex fullH bg="bg_op50">
|
|
47
|
+
<TouchableWithoutFeedback onPress={hide}>
|
|
48
|
+
<View style={{ flex: 1 }}>
|
|
49
|
+
{triggerRect && (
|
|
50
|
+
<View
|
|
51
|
+
style={{
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
top: position?.y ?? -9999,
|
|
54
|
+
left: position?.x ?? -9999,
|
|
55
|
+
}}
|
|
56
|
+
onLayout={(e) => {
|
|
57
|
+
const { width, height } = e.nativeEvent.layout
|
|
58
|
+
const popoverRect = { width, height }
|
|
59
|
+
const pos = calculatePosition(triggerRect, popoverRect, placement, 8)
|
|
60
|
+
setPosition(pos)
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<PopoverContent placement={placement} {...props}>
|
|
64
|
+
{content}
|
|
65
|
+
</PopoverContent>
|
|
66
|
+
</View>
|
|
67
|
+
)}
|
|
68
|
+
</View>
|
|
69
|
+
</TouchableWithoutFeedback>
|
|
70
|
+
</View>
|
|
71
|
+
</Modal>
|
|
72
|
+
)}
|
|
73
|
+
</>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Card } from '../Card'
|
|
2
|
+
|
|
3
|
+
export function PopoverContent({ children, placement = 'bottom', ...props }) {
|
|
4
|
+
return (
|
|
5
|
+
<Card
|
|
6
|
+
shadow
|
|
7
|
+
padding="sm"
|
|
8
|
+
br="sm"
|
|
9
|
+
className="neko-popover-content"
|
|
10
|
+
bg="overlayBG"
|
|
11
|
+
border
|
|
12
|
+
borderColor="divider_op40"
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</Card>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { Table } from '..'
|
|
4
|
+
import { TableCol } from './TableCol'
|
|
5
|
+
import { TableHeader } from './TableHeader'
|
|
6
|
+
import { TableHeaderRow } from './TableHeaderRow'
|
|
7
|
+
import { TableRow } from './TableRow'
|
|
8
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
9
|
+
|
|
10
|
+
function RowItem({ record, columns, size, grid }) {
|
|
11
|
+
return (
|
|
12
|
+
<TableRow>
|
|
13
|
+
{columns.map(({ render, field, key, label, ...column }, index) => {
|
|
14
|
+
render = render || ((v) => v)
|
|
15
|
+
const value = record[field]
|
|
16
|
+
|
|
17
|
+
const colProps = { ...column, size }
|
|
18
|
+
if (!column.borderR && columns.length - 1 > index && grid) colProps.borderR = true
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<TableCol key={key} {...colProps}>
|
|
22
|
+
{render(value, record)}
|
|
23
|
+
</TableCol>
|
|
24
|
+
)
|
|
25
|
+
})}
|
|
26
|
+
</TableRow>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function DataTable({ data, columns, rowKey = 'key', stickyHeader, grid, ...props }) {
|
|
31
|
+
const [{ sizeCode }, _] = pipe(
|
|
32
|
+
useSizeConverter('padding', 'md') //
|
|
33
|
+
)([{}, props])
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Table {...props}>
|
|
37
|
+
<TableHeaderRow sticky={stickyHeader}>
|
|
38
|
+
{columns.map(({ key, ...column }, index) => {
|
|
39
|
+
const headerProps = { ...column, size: sizeCode }
|
|
40
|
+
if (!column.borderR && columns.length - 1 > index && grid) headerProps.borderR = true
|
|
41
|
+
|
|
42
|
+
return <TableHeader key={column.key} {...headerProps} />
|
|
43
|
+
})}
|
|
44
|
+
</TableHeaderRow>
|
|
45
|
+
|
|
46
|
+
{data.map((record, index) => (
|
|
47
|
+
<RowItem
|
|
48
|
+
key={record[rowKey] || record?.id || index}
|
|
49
|
+
columns={columns}
|
|
50
|
+
record={record}
|
|
51
|
+
size={sizeCode}
|
|
52
|
+
grid={grid}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
</Table>
|
|
56
|
+
)
|
|
57
|
+
}
|