@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,43 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { useBackgroundModifier } from '../../modifiers/background'
|
|
4
|
+
import { useBorderModifier } from '../../modifiers/border'
|
|
5
|
+
import { useDisplayModifier } from '../../modifiers/display'
|
|
6
|
+
import { useFlexModifier } from '../../modifiers/flex'
|
|
7
|
+
import { useFlexWrapperModifier } from '../../modifiers/flexWrapper'
|
|
8
|
+
import { useFormState } from './Form'
|
|
9
|
+
import { useMarginModifier } from '../../modifiers/margin'
|
|
10
|
+
import { usePaddingModifier } from '../../modifiers/padding'
|
|
11
|
+
import { usePositionModifier } from '../../modifiers/position'
|
|
12
|
+
import { useShadowModifier } from '../../modifiers/shadow'
|
|
13
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
14
|
+
|
|
15
|
+
export function FormWrapperComponent({ children, form, ...rootProps }) {
|
|
16
|
+
const formState = useFormState()
|
|
17
|
+
const [_, props] = pipe(
|
|
18
|
+
useDisplayModifier, //
|
|
19
|
+
// useStateModifier,
|
|
20
|
+
useSizeModifier, //
|
|
21
|
+
usePositionModifier,
|
|
22
|
+
usePaddingModifier,
|
|
23
|
+
useMarginModifier,
|
|
24
|
+
useFlexWrapperModifier,
|
|
25
|
+
useFlexModifier,
|
|
26
|
+
useBackgroundModifier,
|
|
27
|
+
useBorderModifier,
|
|
28
|
+
useShadowModifier
|
|
29
|
+
)([{}, rootProps])
|
|
30
|
+
|
|
31
|
+
const handleSubmit = (e) => {
|
|
32
|
+
e.preventDefault()
|
|
33
|
+
if (formState?.loading || formState?.disabled) return
|
|
34
|
+
form.handleSubmit()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<form onSubmit={handleSubmit} {...props}>
|
|
39
|
+
{children}
|
|
40
|
+
<input type="submit" style={{ display: 'none' }} />
|
|
41
|
+
</form>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Button } from '../actions/Button'
|
|
2
|
+
import { useFormInstance, useFormState } from './Form'
|
|
3
|
+
|
|
4
|
+
export function SubmitButton({ form, disabled, ...props }) {
|
|
5
|
+
const formState = useFormState()
|
|
6
|
+
const contextForm = useFormInstance()
|
|
7
|
+
form = form || contextForm
|
|
8
|
+
disabled = formState?.disabled || disabled
|
|
9
|
+
|
|
10
|
+
const handleSubmit = () => {
|
|
11
|
+
if (!form) {
|
|
12
|
+
console.error('No form provided to useWatch. Pass it as params or wrap it inside a <Form> component.')
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
form.handleSubmit()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return <Button {...props} disabled={disabled} onPress={handleSubmit} />
|
|
20
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { assocPath, path } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export function useNewForm({ initialValues = {}, validate, onSubmit } = {}) {
|
|
5
|
+
const valuesRef = React.useRef({ ...initialValues })
|
|
6
|
+
const errorsRef = React.useRef({})
|
|
7
|
+
const listenersRef = React.useRef({})
|
|
8
|
+
|
|
9
|
+
const formApi = React.useMemo(() => {
|
|
10
|
+
const notify = (name) => {
|
|
11
|
+
const key = Array.isArray(name) ? name.join('.') : name
|
|
12
|
+
if (listenersRef.current[key]) {
|
|
13
|
+
listenersRef.current[key].forEach((cb) => cb(path(name, valuesRef.current)))
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const setFieldValue = (name, value) => {
|
|
18
|
+
valuesRef.current = assocPath(name, value, valuesRef.current)
|
|
19
|
+
notify(name)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const getFieldValue = (name) => path(name, valuesRef.current)
|
|
23
|
+
|
|
24
|
+
const getError = (name) => path(name, errorsRef.current)
|
|
25
|
+
|
|
26
|
+
const setError = (name, error) => {
|
|
27
|
+
errorsRef.current = assocPath(name, error, errorsRef.current)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const registerListener = (name, cb) => {
|
|
31
|
+
const key = Array.isArray(name) ? name.join('.') : name
|
|
32
|
+
if (!listenersRef.current[key]) {
|
|
33
|
+
listenersRef.current[key] = []
|
|
34
|
+
}
|
|
35
|
+
listenersRef.current[key].push(cb)
|
|
36
|
+
return () => {
|
|
37
|
+
listenersRef.current[key] = listenersRef.current[key].filter((fn) => fn !== cb)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const validateForm = () => {
|
|
42
|
+
if (!validate) return true
|
|
43
|
+
const newErrors = validate(valuesRef.current) || {}
|
|
44
|
+
errorsRef.current = newErrors
|
|
45
|
+
return Object.keys(newErrors).length === 0
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleSubmit = () => {
|
|
49
|
+
const isValid = validateForm()
|
|
50
|
+
if (!isValid) return
|
|
51
|
+
console.log('SUBMIT')
|
|
52
|
+
onSubmit(valuesRef.current)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
setFieldValue,
|
|
57
|
+
getFieldValue,
|
|
58
|
+
getError,
|
|
59
|
+
setError,
|
|
60
|
+
registerListener,
|
|
61
|
+
handleSubmit,
|
|
62
|
+
valuesRef,
|
|
63
|
+
}
|
|
64
|
+
}, [validate, onSubmit])
|
|
65
|
+
|
|
66
|
+
return formApi
|
|
67
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useFormInstance } from './Form'
|
|
3
|
+
|
|
4
|
+
export function useWatch(name, { form } = {}) {
|
|
5
|
+
const contextForm = useFormInstance()
|
|
6
|
+
form = form || contextForm
|
|
7
|
+
const [value, setValue] = React.useState(() => form?.getFieldValue(name))
|
|
8
|
+
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (!form) {
|
|
11
|
+
console.error('No form provided to useWatch. Pass it as params or wrap it inside a <Form> component.')
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setValue(form.getFieldValue(name))
|
|
16
|
+
|
|
17
|
+
const unsubscribe = form.registerListener(name, (newValue) => {
|
|
18
|
+
setValue(newValue)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return unsubscribe
|
|
22
|
+
}, [form, name])
|
|
23
|
+
|
|
24
|
+
return value
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useWatchAll(form) {
|
|
28
|
+
const contextForm = useFormInstance()
|
|
29
|
+
form = form || contextForm
|
|
30
|
+
const [values, setValues] = React.useState(() => form?.valuesRef.current || {})
|
|
31
|
+
const watchedFieldsRef = React.useRef(new Set())
|
|
32
|
+
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (!form) return
|
|
35
|
+
|
|
36
|
+
setValues({ ...form.valuesRef.current })
|
|
37
|
+
|
|
38
|
+
const checkForNewFields = () => {
|
|
39
|
+
const currentFields = Object.keys(form.valuesRef.current)
|
|
40
|
+
const unsubscribers = []
|
|
41
|
+
|
|
42
|
+
currentFields.forEach((field) => {
|
|
43
|
+
if (!watchedFieldsRef.current.has(field)) {
|
|
44
|
+
watchedFieldsRef.current.add(field)
|
|
45
|
+
const unsub = form.registerListener(field, () => {
|
|
46
|
+
setValues({ ...form.valuesRef.current })
|
|
47
|
+
})
|
|
48
|
+
unsubscribers.push(unsub)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return unsubscribers
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const unsubscribers = checkForNewFields()
|
|
56
|
+
|
|
57
|
+
const interval = setInterval(() => {
|
|
58
|
+
const newUnsubs = checkForNewFields()
|
|
59
|
+
unsubscribers.push(...newUnsubs)
|
|
60
|
+
}, 100)
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
clearInterval(interval)
|
|
64
|
+
unsubscribers.forEach((unsub) => unsub())
|
|
65
|
+
watchedFieldsRef.current.clear()
|
|
66
|
+
}
|
|
67
|
+
}, [form])
|
|
68
|
+
|
|
69
|
+
return values
|
|
70
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { View } from '../structure/View'
|
|
4
|
+
|
|
5
|
+
export function LazyRender({
|
|
6
|
+
children,
|
|
7
|
+
delay = 0,
|
|
8
|
+
whenVisible = false,
|
|
9
|
+
destroyOffScreen = false,
|
|
10
|
+
minHeight: initMinHeight,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const ref = React.useRef(null)
|
|
14
|
+
const [open, setOpen] = React.useState(!whenVisible && !delay)
|
|
15
|
+
const [minHeight, setMinHeight] = React.useState(initMinHeight)
|
|
16
|
+
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (!whenVisible) return
|
|
19
|
+
|
|
20
|
+
const observer = new IntersectionObserver(
|
|
21
|
+
([entry]) => {
|
|
22
|
+
setOpen((open) => {
|
|
23
|
+
if (entry.isIntersecting) return true
|
|
24
|
+
return destroyOffScreen ? false : open
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
{ threshold: 0 }
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if (ref.current) observer.observe(ref.current)
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
if (ref.current) observer.unobserve(ref.current)
|
|
34
|
+
}
|
|
35
|
+
}, [whenVisible, destroyOffScreen])
|
|
36
|
+
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (delay > 0 && !whenVisible) {
|
|
39
|
+
const timer = setTimeout(() => setOpen(true), delay)
|
|
40
|
+
return () => clearTimeout(timer)
|
|
41
|
+
}
|
|
42
|
+
}, [])
|
|
43
|
+
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (ref.current && open) {
|
|
46
|
+
setMinHeight(ref.current.offsetHeight)
|
|
47
|
+
}
|
|
48
|
+
}, [open])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View className="neko-lazy-render" {...props} minHeight={minHeight} ref={ref}>
|
|
52
|
+
{open ? children : null}
|
|
53
|
+
</View>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { View } from '../structure/View'
|
|
5
|
+
|
|
6
|
+
export function LazyRender({
|
|
7
|
+
children,
|
|
8
|
+
delay = 0,
|
|
9
|
+
whenVisible = false,
|
|
10
|
+
destroyOffScreen = false,
|
|
11
|
+
minHeight: initMinHeight,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
const ref = React.useRef(null)
|
|
15
|
+
const [open, setOpen] = React.useState(!whenVisible && !delay)
|
|
16
|
+
const [minHeight, setMinHeight] = React.useState(initMinHeight)
|
|
17
|
+
const windowHeight = Dimensions.get('window').height
|
|
18
|
+
|
|
19
|
+
const checkVisibility = React.useCallback(() => {
|
|
20
|
+
if (!ref.current) return
|
|
21
|
+
ref.current.measureInWindow((x, y, width, height) => {
|
|
22
|
+
const isVisible = y + height > 0 && y < windowHeight
|
|
23
|
+
setOpen((prev) => {
|
|
24
|
+
if (isVisible) return true
|
|
25
|
+
return destroyOffScreen ? false : prev
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
}, [windowHeight, destroyOffScreen])
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (whenVisible) {
|
|
32
|
+
checkVisibility()
|
|
33
|
+
const interval = setInterval(checkVisibility, 100)
|
|
34
|
+
return () => clearInterval(interval)
|
|
35
|
+
}
|
|
36
|
+
}, [whenVisible, checkVisibility])
|
|
37
|
+
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (delay > 0 && !whenVisible) {
|
|
40
|
+
const timer = setTimeout(() => setOpen(true), delay)
|
|
41
|
+
return () => clearTimeout(timer)
|
|
42
|
+
}
|
|
43
|
+
}, [])
|
|
44
|
+
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (ref.current && open) {
|
|
47
|
+
ref.current.measure((x, y, width, height) => {
|
|
48
|
+
setMinHeight(height)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}, [open])
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View className="neko-lazy-render" {...props} minHeight={minHeight} ref={ref}>
|
|
55
|
+
{open ? children : null}
|
|
56
|
+
</View>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { usePortal } from './PortalHandler'
|
|
4
|
+
|
|
5
|
+
let idCounter = 0
|
|
6
|
+
|
|
7
|
+
export function Portal({ children }) {
|
|
8
|
+
const keyRef = React.useRef(++idCounter)
|
|
9
|
+
const { mount, update, unmount } = usePortal()
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
mount(keyRef.current, children)
|
|
13
|
+
return () => unmount(keyRef.current)
|
|
14
|
+
}, [])
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
update(keyRef.current, children)
|
|
18
|
+
}, [children])
|
|
19
|
+
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
const PortalContext = React.createContext(null)
|
|
4
|
+
|
|
5
|
+
export const usePortal = () => React.useContext(PortalContext) || {}
|
|
6
|
+
|
|
7
|
+
export function PortalHandler({ children }) {
|
|
8
|
+
const [portals, setPortals] = React.useState([])
|
|
9
|
+
|
|
10
|
+
const mount = React.useCallback((key, element) => {
|
|
11
|
+
setPortals((prev) => [...prev, { key, element }])
|
|
12
|
+
}, [])
|
|
13
|
+
|
|
14
|
+
const update = React.useCallback((key, element) => {
|
|
15
|
+
setPortals((prev) => prev.map((p) => (p.key === key ? { ...p, element } : p)))
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
const unmount = React.useCallback((key) => {
|
|
19
|
+
setPortals((prev) => prev.filter((p) => p.key !== key))
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
22
|
+
const value = React.useMemo(() => ({ mount, update, unmount }), [mount, update, unmount])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<PortalContext.Provider value={value}>
|
|
26
|
+
{children}
|
|
27
|
+
{portals.map((p) => (
|
|
28
|
+
<React.Fragment key={p.key}>{p.element}</React.Fragment>
|
|
29
|
+
))}
|
|
30
|
+
</PortalContext.Provider>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useResponsiveValue } from '../../responsive/responsiveHooks'
|
|
2
|
+
|
|
3
|
+
export function ResponsiveRender(props) {
|
|
4
|
+
const value = useResponsiveValue(props) || props.df
|
|
5
|
+
return typeof value === 'function' ? value() : value
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function HideOn({ children, ...props }) {
|
|
9
|
+
const hide = useResponsiveValue(props)
|
|
10
|
+
if (!!hide) return false
|
|
11
|
+
return children
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ShowOn({ children, ...props }) {
|
|
15
|
+
const show = useResponsiveValue(props)
|
|
16
|
+
if (!show) return false
|
|
17
|
+
return children
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { pipe, is } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { AbsView } from '../../abstractions/View'
|
|
4
|
+
import { View } from '../structure/View'
|
|
5
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
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 { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
11
|
+
import { useSizeModifier } from '../../modifiers/size'
|
|
12
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
13
|
+
|
|
14
|
+
const DEFAULT_PROPS = ([{ size, sizeCode }, { line }]) => ({
|
|
15
|
+
height: !!line ? 2 * size : size,
|
|
16
|
+
br: sizeCode,
|
|
17
|
+
center: true,
|
|
18
|
+
fullW: true,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export function Separator(rootProps) {
|
|
22
|
+
const [{ color }, formattedProps] = pipe(
|
|
23
|
+
useColorConverter('divider'),
|
|
24
|
+
useSizeConverter('spaces', 'md'),
|
|
25
|
+
useThemeComponentModifier('Separator'),
|
|
26
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
27
|
+
useSizeModifier,
|
|
28
|
+
useMarginModifier,
|
|
29
|
+
useFlexModifier,
|
|
30
|
+
useFlexWrapperModifier
|
|
31
|
+
)([{}, rootProps])
|
|
32
|
+
|
|
33
|
+
const { line, lineProps, ...props } = formattedProps
|
|
34
|
+
const lineHeight = is(Number, line) ? line : 1
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<AbsView className="neko-separator" {...props}>
|
|
38
|
+
{!!line && (
|
|
39
|
+
<View bg={color} br={lineHeight} height={lineHeight} fullW className="neko-separator-line" {...lineProps} />
|
|
40
|
+
)}
|
|
41
|
+
</AbsView>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const Divider = Separator
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { View } from '../structure/View'
|
|
4
|
+
import { formatTransform } from '../../abstractions/helpers/transformStyle'
|
|
5
|
+
import { getElementSize } from '../../abstractions/helpers/componentSize'
|
|
6
|
+
|
|
7
|
+
export function VerticalView({ children, invert, ...props }) {
|
|
8
|
+
const wrapperRef = React.useRef(null)
|
|
9
|
+
const [size, setSize] = React.useState({})
|
|
10
|
+
|
|
11
|
+
React.useLayoutEffect(() => {
|
|
12
|
+
getElementSize(wrapperRef, setSize)
|
|
13
|
+
}, [])
|
|
14
|
+
|
|
15
|
+
const { height, width } = size
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<View width="100%" height="100%" {...props} relative ref={wrapperRef}>
|
|
19
|
+
<View
|
|
20
|
+
style={{
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
width: height,
|
|
23
|
+
height: width,
|
|
24
|
+
transform: formatTransform([{ rotate: !!invert ? '90deg' : '-90deg' }]),
|
|
25
|
+
left: width / 2 - height / 2,
|
|
26
|
+
top: '50%',
|
|
27
|
+
marginTop: -width / 2,
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</View>
|
|
32
|
+
</View>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './actions'
|
|
2
|
+
export * from './animations'
|
|
3
|
+
export * from './form'
|
|
4
|
+
export * from './presentation'
|
|
5
|
+
export * from './structure'
|
|
6
|
+
export * from './text'
|
|
7
|
+
export * from './helpers'
|
|
8
|
+
export * from './inputs'
|
|
9
|
+
export * from './state'
|
|
10
|
+
export * from './layout'
|
|
11
|
+
export * from './table'
|
|
12
|
+
export * from './feedback'
|
|
13
|
+
export * from './calendar'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { AbsHiddenInput } from '../../abstractions/HiddenInput'
|
|
5
|
+
import { ContentLabel } from '../presentation/ContentLabel'
|
|
6
|
+
import { Link } from '../actions/Link'
|
|
7
|
+
import { Picker } from './Picker'
|
|
8
|
+
import { View } from '../structure/View'
|
|
9
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
10
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
11
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
12
|
+
|
|
13
|
+
export function Checkbox({ value, onChange, disabled, initialValue, ...rootProps }) {
|
|
14
|
+
const [{ size, sizeCode, color }, props] = pipe(
|
|
15
|
+
useColorConverter('primary'),
|
|
16
|
+
useSizeConverter('elementHeights', 'md'),
|
|
17
|
+
useThemeComponentModifier('Checkbox') //
|
|
18
|
+
)([{}, rootProps])
|
|
19
|
+
|
|
20
|
+
const [localValue, setLocalValue] = React.useState(initialValue)
|
|
21
|
+
value = value === undefined ? localValue : value
|
|
22
|
+
|
|
23
|
+
const toggle = () => {
|
|
24
|
+
if (!!disabled) return
|
|
25
|
+
setLocalValue(!value)
|
|
26
|
+
onChange?.(!value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Link onPress={toggle} className="neko-checkbox" disabled={disabled}>
|
|
31
|
+
<AbsHiddenInput checked={value} onChange={toggle} type="checkbox" disabled={disabled} />
|
|
32
|
+
<ContentLabel
|
|
33
|
+
size={sizeCode}
|
|
34
|
+
gap={8}
|
|
35
|
+
content={
|
|
36
|
+
<View height={size * 0.65} ratio={1} border={2} padding={2} borderColor={color} br={3} center>
|
|
37
|
+
{!!value && <View bg={color} br={2} flex fullW fullH />}
|
|
38
|
+
</View>
|
|
39
|
+
}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
</Link>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function CheckboxGroup({ checkboxProps, ...props }) {
|
|
47
|
+
return (
|
|
48
|
+
<Picker
|
|
49
|
+
{...props}
|
|
50
|
+
multiple
|
|
51
|
+
renderOption={({ option, selected, onChange, labelKey, ...props }) => (
|
|
52
|
+
<Checkbox label={option[labelKey]} value={selected} onChange={onChange} {...props} {...checkboxProps} />
|
|
53
|
+
)}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { pipe, is } from 'ramda'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../presentation/Icon'
|
|
5
|
+
import { Loading } from '../state/Loading'
|
|
6
|
+
import { Text } from '../text/Text'
|
|
7
|
+
import { View } from '../structure/View'
|
|
8
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
9
|
+
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
10
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
11
|
+
|
|
12
|
+
const DEFAULT_PROPS = {
|
|
13
|
+
fullW: '100%', //
|
|
14
|
+
paddingH: 'sm',
|
|
15
|
+
bg: 'overlayBG',
|
|
16
|
+
border: true,
|
|
17
|
+
br: 'md',
|
|
18
|
+
row: true,
|
|
19
|
+
gap: 'sm',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function InputWrapper({ prefix, suffix, prefixIcon, suffixIcon, loading, error, children, ...rootProps }) {
|
|
23
|
+
const [hover, setHover] = React.useState(false)
|
|
24
|
+
const inputRef = React.useRef()
|
|
25
|
+
const [{ size, sizeCode, onChange }, props] = pipe(
|
|
26
|
+
useSizeConverter('elementHeights', 'md'),
|
|
27
|
+
useThemeComponentModifier('InputWrapper'),
|
|
28
|
+
useDefaultModifier(DEFAULT_PROPS)
|
|
29
|
+
)([{}, rootProps])
|
|
30
|
+
|
|
31
|
+
const handlePress = () => {
|
|
32
|
+
inputRef?.current?.focus?.()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!!prefix && is(String, prefix)) prefix = <Text>{prefix}</Text>
|
|
36
|
+
if (!!suffix && is(String, suffix)) suffix = <Text>{suffix}</Text>
|
|
37
|
+
if (!prefix && !!prefixIcon) prefix = <Icon name={prefixIcon} size={sizeCode} />
|
|
38
|
+
if (!suffix && !!suffixIcon) suffix = <Icon name={suffixIcon} size={sizeCode} />
|
|
39
|
+
if (!prefix && !!error) suffix = <Icon name="close-circle-fill" size={sizeCode} red />
|
|
40
|
+
if (!!loading) suffix = <Loading size={sizeCode} />
|
|
41
|
+
|
|
42
|
+
let borderColor = !!hover ? 'primary_op40' : 'divider'
|
|
43
|
+
if (!!error) borderColor = 'red_op40'
|
|
44
|
+
|
|
45
|
+
const child = React.Children.only(children)
|
|
46
|
+
const childWithProps = React.cloneElement(child, {
|
|
47
|
+
...child.props,
|
|
48
|
+
ref: inputRef,
|
|
49
|
+
onChange: child.props.onChange || onChange,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View
|
|
54
|
+
className="neko-input-wrapper"
|
|
55
|
+
height={size}
|
|
56
|
+
onPress={handlePress}
|
|
57
|
+
borderColor={borderColor}
|
|
58
|
+
onMouseEnter={() => setHover(true)}
|
|
59
|
+
onMouseLeave={() => setHover(false)}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{!!prefix && (
|
|
63
|
+
<View paddingV={5} fullHeight center>
|
|
64
|
+
{prefix}
|
|
65
|
+
</View>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<View flex fullH>
|
|
69
|
+
{childWithProps}
|
|
70
|
+
</View>
|
|
71
|
+
|
|
72
|
+
{!!suffix && (
|
|
73
|
+
<View paddingV={5} fullHeight center>
|
|
74
|
+
{suffix}
|
|
75
|
+
</View>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
79
|
+
}
|