@neko-os/ui 0.2.3 → 0.4.0
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/DynamicStyleTag.js +18 -2
- package/dist/DynamicStyleTag.native.js +3 -1
- package/dist/NekoUI.js +39 -1
- package/dist/abstractions/ActivityIndicator.js +19 -1
- package/dist/abstractions/ActivityIndicator.native.js +43 -1
- package/dist/abstractions/ActivityIndicator.web.js +43 -1
- package/dist/abstractions/AnimatedView.js +3 -1
- package/dist/abstractions/AnimatedView.native.js +5 -1
- package/dist/abstractions/AnimatedView.web.js +3 -1
- package/dist/abstractions/BlurView.js +43 -1
- package/dist/abstractions/BlurView.native.js +39 -1
- package/dist/abstractions/BlurView.web.js +39 -1
- package/dist/abstractions/DraggableSlideView.js +3 -1
- package/dist/abstractions/DraggableSlideView.native.js +62 -1
- package/dist/abstractions/FlatList.js +3 -1
- package/dist/abstractions/FlatList.native.js +37 -1
- package/dist/abstractions/FlatList.web.js +3 -1
- package/dist/abstractions/GradientView.js +5 -1
- package/dist/abstractions/GradientView.native.js +32 -1
- package/dist/abstractions/HiddenInput.js +3 -1
- package/dist/abstractions/HiddenInput.native.js +3 -1
- package/dist/abstractions/Icon.js +10 -1
- package/dist/abstractions/Icon.native.js +13 -1
- package/dist/abstractions/Icon.web.js +11 -1
- package/dist/abstractions/Image.js +12 -1
- package/dist/abstractions/Image.native.js +7 -1
- package/dist/abstractions/Image.web.js +7 -1
- package/dist/abstractions/ImageBackground.js +17 -1
- package/dist/abstractions/ImageBackground.native.js +27 -1
- package/dist/abstractions/ImageBackground.web.js +7 -1
- package/dist/abstractions/KeyboardAvoidingView.js +3 -1
- package/dist/abstractions/KeyboardAvoidingView.native.js +3 -1
- package/dist/abstractions/Platform.js +1 -1
- package/dist/abstractions/Platform.native.js +3 -1
- package/dist/abstractions/Platform.web.js +3 -1
- package/dist/abstractions/Pressable.js +4 -1
- package/dist/abstractions/Pressable.native.js +3 -1
- package/dist/abstractions/Pressable.web.js +3 -1
- package/dist/abstractions/SafeAreaView.js +3 -1
- package/dist/abstractions/SafeAreaView.native.js +3 -1
- package/dist/abstractions/ScrollView.js +3 -1
- package/dist/abstractions/ScrollView.native.js +5 -1
- package/dist/abstractions/ScrollView.web.js +3 -1
- package/dist/abstractions/StaticList.js +51 -1
- package/dist/abstractions/Switch.js +97 -1
- package/dist/abstractions/Switch.native.js +12 -1
- package/dist/abstractions/Table.js +29 -1
- package/dist/abstractions/Table.native.js +19 -1
- package/dist/abstractions/Text.js +14 -1
- package/dist/abstractions/Text.native.js +3 -1
- package/dist/abstractions/Text.web.js +18 -1
- package/dist/abstractions/TextInput.js +12 -1
- package/dist/abstractions/TextInput.native.js +5 -1
- package/dist/abstractions/TextInput.web.js +5 -1
- package/dist/abstractions/TouchableOpacity.js +4 -1
- package/dist/abstractions/TouchableOpacity.native.js +9 -1
- package/dist/abstractions/View.js +3 -1
- package/dist/abstractions/View.native.js +3 -1
- package/dist/abstractions/View.web.js +3 -1
- package/dist/abstractions/helpers/componentSize.js +13 -1
- package/dist/abstractions/helpers/componentSize.native.js +12 -1
- package/dist/abstractions/helpers/storage.js +32 -1
- package/dist/abstractions/helpers/storage.native.js +34 -1
- package/dist/abstractions/helpers/transformStyle.js +8 -1
- package/dist/abstractions/helpers/transformStyle.native.js +3 -1
- package/dist/abstractions/helpers/useSafeAreaInsets.js +3 -1
- package/dist/abstractions/helpers/useSafeAreaInsets.native.js +3 -1
- package/dist/abstractions/helpers/windowWidth.js +13 -1
- package/dist/abstractions/helpers/windowWidth.native.js +6 -1
- package/dist/abstractions/helpers/windowWidth.web.js +6 -1
- package/dist/components/actions/ActionsDrawer.js +81 -1
- package/dist/components/actions/Breadcrumb.js +47 -1
- package/dist/components/actions/Button.js +82 -1
- package/dist/components/actions/Dropdown.js +91 -1
- package/dist/components/actions/FloatingButton.js +87 -1
- package/dist/components/actions/FloatingMenu.js +39 -1
- package/dist/components/actions/Link.js +66 -1
- package/dist/components/actions/Pressable.js +38 -1
- package/dist/components/actions/index.js +9 -1
- package/dist/components/actions/menu/HorizontalMenu.js +98 -1
- package/dist/components/actions/menu/Menu.js +7 -1
- package/dist/components/actions/menu/SubmenuWrapper.js +16 -1
- package/dist/components/actions/menu/VerticalMenu.js +133 -1
- package/dist/components/animations/AnimatedTopBar.js +10 -1
- package/dist/components/animations/AnimatedTopBar.native.js +34 -1
- package/dist/components/animations/AnimatedTopBar.web.js +1 -1
- package/dist/components/animations/AnimatedView.js +45 -1
- package/dist/components/animations/DraggableSlideView.js +42 -1
- package/dist/components/animations/ParallaxHeader.js +9 -1
- package/dist/components/animations/ParallaxHeader.native.js +32 -1
- package/dist/components/animations/ParallaxHeader.web.js +32 -1
- package/dist/components/animations/ReanimatedScrollHandler.js +8 -1
- package/dist/components/animations/ReanimatedScrollHandler.native.js +24 -1
- package/dist/components/animations/ReanimatedScrollHandler.web.js +1 -1
- package/dist/components/animations/ReanimatedView.js +40 -1
- package/dist/components/animations/index.js +5 -1
- package/dist/components/calendar/CalendarNav.js +67 -1
- package/dist/components/calendar/WeekDaysBar.js +18 -1
- package/dist/components/calendar/_helpers/calendarDays.js +16 -1
- package/dist/components/calendar/_helpers/dateDisabled.js +24 -1
- package/dist/components/feedback/alerter.js +31 -1
- package/dist/components/feedback/confirmer.js +70 -1
- package/dist/components/feedback/index.js +3 -1
- package/dist/components/feedback/notifications/Notification.js +37 -1
- package/dist/components/feedback/notifications/NotificationsHandler.js +65 -1
- package/dist/components/filter/DateFilter.js +72 -0
- package/dist/components/filter/FilterGroup.js +17 -0
- package/dist/components/filter/FilterHandler.js +54 -0
- package/dist/components/filter/FilterItem.js +30 -0
- package/dist/components/filter/PopoverFilterItem.js +84 -0
- package/dist/components/filter/SearchInput.js +49 -0
- package/dist/components/filter/index.js +6 -0
- package/dist/components/form/Form.js +31 -1
- package/dist/components/form/FormGroup.js +21 -1
- package/dist/components/form/FormItem.js +118 -1
- package/dist/components/form/FormList.js +143 -1
- package/dist/components/form/FormWrapperComponent.js +52 -1
- package/dist/components/form/FormWrapperComponent.native.js +5 -1
- package/dist/components/form/SubmitButton.js +22 -1
- package/dist/components/form/index.js +9 -1
- package/dist/components/form/useNewForm.js +211 -1
- package/dist/components/form/useWatch.js +70 -1
- package/dist/components/form/validation/defaultMessages.js +20 -1
- package/dist/components/form/validation/index.js +5 -1
- package/dist/components/form/validation/normalizeRules.js +22 -1
- package/dist/components/form/validation/shouldValidateOn.js +21 -1
- package/dist/components/form/validation/validateRules.js +83 -1
- package/dist/components/form/validation/validators.js +82 -1
- package/dist/components/helpers/ConditionalLazyRender.js +6 -1
- package/dist/components/helpers/LazyAction.js +22 -1
- package/dist/components/helpers/LazyRender.js +55 -1
- package/dist/components/helpers/LazyRender.native.js +58 -1
- package/dist/components/helpers/Portal.js +21 -1
- package/dist/components/helpers/PortalHandler.js +32 -1
- package/dist/components/helpers/Responsive.js +18 -1
- package/dist/components/helpers/Separator.js +49 -1
- package/dist/components/helpers/VerticalView.js +34 -1
- package/dist/components/helpers/index.js +8 -1
- package/dist/components/index.js +20 -1
- package/dist/components/inputs/BooleanSelect.js +14 -0
- package/dist/components/inputs/Checkbox.js +56 -1
- package/dist/components/inputs/DateInput.js +123 -1
- package/dist/components/inputs/DateRangeInput.js +41 -0
- package/dist/components/inputs/Editable.js +129 -0
- package/dist/components/inputs/EnabledSelect.js +14 -0
- package/dist/components/inputs/InputWrapper.js +93 -1
- package/dist/components/inputs/LinkInput.js +17 -1
- package/dist/components/inputs/MaskInput.js +67 -1
- package/dist/components/inputs/NumberInput.js +111 -1
- package/dist/components/inputs/NumberRangeInput.js +41 -0
- package/dist/components/inputs/PasswordInput.js +24 -0
- package/dist/components/inputs/Picker.js +169 -1
- package/dist/components/inputs/Radio.js +55 -1
- package/dist/components/inputs/RateInput.js +62 -1
- package/dist/components/inputs/SegmentedPicker.js +62 -1
- package/dist/components/inputs/Select.js +219 -1
- package/dist/components/inputs/Switch.js +60 -1
- package/dist/components/inputs/TextArea.js +5 -0
- package/dist/components/inputs/TextInput.js +32 -1
- package/dist/components/inputs/UploadInput.js +140 -0
- package/dist/components/inputs/_DateInput.native.js +89 -1
- package/dist/components/inputs/datePicker/DatePicker.js +24 -1
- package/dist/components/inputs/datePicker/DayPicker.js +64 -1
- package/dist/components/inputs/datePicker/MonthPicker.js +62 -1
- package/dist/components/inputs/datePicker/QuarterPicker.js +65 -1
- package/dist/components/inputs/datePicker/WeekPicker.js +74 -1
- package/dist/components/inputs/datePicker/YearPicker.js +70 -1
- package/dist/components/inputs/index.js +23 -1
- package/dist/components/inputs/upload/Upload.js +99 -0
- package/dist/components/inputs/upload/Upload.native.js +154 -0
- package/dist/components/inputs/upload/useUploadState.js +143 -0
- package/dist/components/layout/Layout.js +40 -1
- package/dist/components/layout/LayoutContent.js +42 -1
- package/dist/components/layout/LayoutHeader.js +70 -1
- package/dist/components/layout/LayoutSider.js +64 -1
- package/dist/components/layout/index.js +4 -1
- package/dist/components/list/FlatList.js +91 -1
- package/dist/components/list/ScrollView.js +58 -1
- package/dist/components/list/index.js +2 -1
- package/dist/components/modals/bottomDrawer/index.js +3 -1
- package/dist/components/modals/bottomDrawer/index.native.js +5 -1
- package/dist/components/modals/bottomDrawer/index.web.js +5 -1
- package/dist/components/modals/bottomDrawer/native/BottomDrawer.js +239 -1
- package/dist/components/modals/bottomDrawer/native/DrawerContext.js +17 -1
- package/dist/components/modals/bottomDrawer/native/DrawerHandle.js +12 -1
- package/dist/components/modals/bottomDrawer/native/DrawerScrollView.js +5 -1
- package/dist/components/modals/bottomDrawer/native/createDrawerScrollComponent.js +139 -1
- package/dist/components/modals/bottomDrawer/native/utils.js +65 -1
- package/dist/components/modals/bottomDrawer/web/BottomDrawer.js +5 -1
- package/dist/components/modals/drawer/Drawer.js +5 -1
- package/dist/components/modals/drawer/Drawer.native.js +3 -1
- package/dist/components/modals/drawer/Drawer.web.js +3 -1
- package/dist/components/modals/drawer/index.js +1 -1
- package/dist/components/modals/index.js +4 -1
- package/dist/components/modals/modal/Modal.js +84 -1
- package/dist/components/modals/modal/Modal.native.js +83 -1
- package/dist/components/modals/modal/ModalBackdrop.js +58 -1
- package/dist/components/modals/modal/ModalContent.js +28 -1
- package/dist/components/modals/modal/ModalFooter.js +31 -1
- package/dist/components/modals/modal/ModalHeader.js +50 -1
- package/dist/components/modals/modal/handler/ModalsHandler.js +61 -1
- package/dist/components/modals/modal/index.js +6 -1
- package/dist/components/modals/router/ModalRoute.js +15 -1
- package/dist/components/modals/router/ModalsRouter.js +120 -1
- package/dist/components/modals/router/ModalsRouterContext.js +16 -1
- package/dist/components/modals/router/index.js +6 -1
- package/dist/components/modals/router/useAllModalsParams.js +6 -1
- package/dist/components/modals/router/useModalParams.js +6 -1
- package/dist/components/modals/router/useModalsNavigation.js +6 -1
- package/dist/components/modals/router/useUpdateModalContainer.js +6 -1
- package/dist/components/presentation/Avatar.js +79 -1
- package/dist/components/presentation/AvatarLabel.js +60 -1
- package/dist/components/presentation/AvatarsGroup.js +30 -0
- package/dist/components/presentation/Badge.js +91 -1
- package/dist/components/presentation/ContentLabel.js +43 -1
- package/dist/components/presentation/Icon.js +20 -1
- package/dist/components/presentation/IconLabel.js +40 -1
- package/dist/components/presentation/Image.js +33 -1
- package/dist/components/presentation/ImageBackground.js +38 -1
- package/dist/components/presentation/LabelValue.js +51 -1
- package/dist/components/presentation/Progress.js +20 -0
- package/dist/components/presentation/Rate.js +58 -1
- package/dist/components/presentation/RateTag.js +35 -1
- package/dist/components/presentation/Result.js +60 -1
- package/dist/components/presentation/ResultBar.js +56 -1
- package/dist/components/presentation/Tag.js +69 -1
- package/dist/components/presentation/Tooltip.js +44 -1
- package/dist/components/presentation/index.js +16 -1
- package/dist/components/sections/Section.js +50 -1
- package/dist/components/sections/SectionItem.js +24 -1
- package/dist/components/sections/SectionItemDropdown.js +68 -1
- package/dist/components/sections/SectionItemLink.js +35 -1
- package/dist/components/sections/index.js +4 -1
- package/dist/components/state/Loading.js +20 -1
- package/dist/components/state/LoadingView.js +37 -1
- package/dist/components/state/StatePresenter.js +41 -1
- package/dist/components/state/index.js +3 -1
- package/dist/components/steps/ActiveStepContent.js +16 -0
- package/dist/components/steps/StepsHandler.js +53 -0
- package/dist/components/steps/StepsMenu.js +14 -0
- package/dist/components/steps/StepsNavigation.js +37 -0
- package/dist/components/steps/index.js +4 -0
- package/dist/components/structure/Accordion.js +69 -1
- package/dist/components/structure/AccordionGroup.js +35 -1
- package/dist/components/structure/Affix.js +34 -0
- package/dist/components/structure/Affix.native.js +3 -0
- package/dist/components/structure/BlurView.js +59 -1
- package/dist/components/structure/Card.js +46 -1
- package/dist/components/structure/Col.js +22 -1
- package/dist/components/structure/GradientView.js +42 -1
- package/dist/components/structure/KeyboardAvoidingView.js +52 -1
- package/dist/components/structure/Row.js +50 -1
- package/dist/components/structure/SafeAreaView.js +42 -1
- package/dist/components/structure/Segment.js +51 -1
- package/dist/components/structure/TopBar.js +57 -1
- package/dist/components/structure/View.js +44 -1
- package/dist/components/structure/index.js +14 -1
- package/dist/components/structure/overlay/OverlayHandler.js +83 -1
- package/dist/components/structure/overlay/OverlayHandler.native.js +6 -1
- package/dist/components/structure/overlay/OverlayWrapper.js +52 -1
- package/dist/components/structure/overlay/calculatePosition.js +29 -1
- package/dist/components/structure/overlay/smartPlacement.js +32 -1
- package/dist/components/structure/popover/Popover.js +135 -1
- package/dist/components/structure/popover/Popover.native.js +105 -1
- package/dist/components/structure/popover/PopoverContent.js +18 -1
- package/dist/components/structure/popover/Popover_BU.js +157 -1
- package/dist/components/table/DataTable.js +62 -1
- package/dist/components/table/Pagination.js +128 -1
- package/dist/components/table/Table.js +66 -1
- package/dist/components/table/TableCol.js +67 -1
- package/dist/components/table/TableHeader.js +69 -1
- package/dist/components/table/TableHeaderRow.js +31 -1
- package/dist/components/table/TableRow.js +30 -1
- package/dist/components/table/index.js +7 -1
- package/dist/components/tabs/ActiveTabContent.js +38 -1
- package/dist/components/tabs/TabsHandler.js +16 -1
- package/dist/components/tabs/TabsMenu.js +15 -1
- package/dist/components/tabs/index.js +3 -1
- package/dist/components/text/DateText.js +24 -1
- package/dist/components/text/Text.js +32 -1
- package/dist/components/text/VerticalText.js +29 -1
- package/dist/components/text/index.js +3 -1
- package/dist/components/theme/ThemePicker.js +48 -1
- package/dist/components/theme/ThemePickerDrawer.js +12 -1
- package/dist/components/theme/ThemeStatusBar.js +3 -1
- package/dist/components/theme/ThemeStatusBar.native.js +9 -1
- package/dist/components/theme/ThemeThumb.js +98 -1
- package/dist/components/theme/index.js +3 -1
- package/dist/helpers/debounce.js +9 -1
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/options.js +65 -1
- package/dist/helpers/random.js +5 -1
- package/dist/helpers/storage.js +76 -1
- package/dist/helpers/string.js +74 -1
- package/dist/i18n/I18n.js +96 -1
- package/dist/i18n/I18nProvider.js +40 -1
- package/dist/i18n/index.js +2 -1
- package/dist/index.js +8 -1
- package/dist/modifiers/_helpers.js +6 -1
- package/dist/modifiers/alignConverter.js +11 -1
- package/dist/modifiers/animation.js +18 -1
- package/dist/modifiers/animations/animatedEffects.js +64 -1
- package/dist/modifiers/animations/animatedEffects.native.js +55 -1
- package/dist/modifiers/animations/animatedEffects.web.js +55 -1
- package/dist/modifiers/animations/fadeEffect.js +46 -1
- package/dist/modifiers/animations/fadeEffect.native.js +33 -1
- package/dist/modifiers/animations/fadeEffect.web.js +3 -1
- package/dist/modifiers/animations/scaleEffect.js +46 -1
- package/dist/modifiers/animations/scaleEffect.native.js +33 -1
- package/dist/modifiers/animations/scrollEffect.web.js +3 -1
- package/dist/modifiers/animations/slideEffect.js +64 -1
- package/dist/modifiers/animations/slideEffect.native.js +53 -1
- package/dist/modifiers/animations/slideEffect.web.js +3 -1
- package/dist/modifiers/applyStyles.js +7 -1
- package/dist/modifiers/background.js +34 -1
- package/dist/modifiers/border.js +86 -1
- package/dist/modifiers/colorConverter.js +13 -1
- package/dist/modifiers/cursor.js +21 -1
- package/dist/modifiers/default.js +9 -1
- package/dist/modifiers/display.js +22 -1
- package/dist/modifiers/flex.js +20 -1
- package/dist/modifiers/flexWrapper.js +87 -1
- package/dist/modifiers/fullColor.js +32 -1
- package/dist/modifiers/grid.js +27 -1
- package/dist/modifiers/hover.js +28 -1
- package/dist/modifiers/logger.js +6 -1
- package/dist/modifiers/margin.js +25 -1
- package/dist/modifiers/overflow.js +28 -1
- package/dist/modifiers/padding.js +25 -1
- package/dist/modifiers/position.js +57 -1
- package/dist/modifiers/responsiveConverter.js +19 -1
- package/dist/modifiers/shadow.js +35 -1
- package/dist/modifiers/size.js +59 -1
- package/dist/modifiers/sizeConverter.js +12 -1
- package/dist/modifiers/state.js +33 -1
- package/dist/modifiers/text.js +62 -1
- package/dist/modifiers/textConverter.js +12 -1
- package/dist/modifiers/themeComponent.js +11 -1
- package/dist/responsive/ResponsiveHandler.js +28 -1
- package/dist/responsive/index.js +2 -1
- package/dist/responsive/responsiveHooks.js +67 -1
- package/dist/theme/ThemeHandler.js +81 -1
- package/dist/theme/default/base.js +95 -1
- package/dist/theme/default/blackTheme.js +47 -1
- package/dist/theme/default/cyberpunkTheme.js +36 -1
- package/dist/theme/default/darkTheme.js +35 -1
- package/dist/theme/default/hackerTheme.js +55 -1
- package/dist/theme/default/lightTheme.js +35 -1
- package/dist/theme/default/paperTheme.js +36 -1
- package/dist/theme/default/themes.js +15 -1
- package/dist/theme/format/colorsVariations.js +31 -1
- package/dist/theme/format/formatTheme.js +28 -1
- package/dist/theme/helpers/colorScale.js +12 -1
- package/dist/theme/helpers/contrastColor.js +18 -1
- package/dist/theme/helpers/dynamicColor.js +32 -1
- package/dist/theme/helpers/mergePreset.js +7 -1
- package/dist/theme/helpers/relatedScales.js +34 -1
- package/dist/theme/helpers/sizeScale.js +20 -1
- package/dist/theme/helpers/textScale.js +15 -1
- package/dist/theme/index.js +2 -1
- package/package.json +1 -3
- package/src/abstractions/Icon.js +1 -1
- package/src/abstractions/TextInput.js +10 -1
- package/src/abstractions/TouchableOpacity.native.js +8 -2
- package/src/components/actions/ActionsDrawer.js +1 -1
- package/src/components/actions/Button.js +3 -1
- package/src/components/actions/FloatingMenu.js +1 -1
- package/src/components/actions/menu/HorizontalMenu.js +2 -1
- package/src/components/actions/menu/VerticalMenu.js +2 -1
- package/src/components/filter/DateFilter.js +72 -0
- package/src/components/filter/FilterGroup.js +17 -0
- package/src/components/filter/FilterHandler.js +54 -0
- package/src/components/filter/FilterItem.js +30 -0
- package/src/components/filter/PopoverFilterItem.js +84 -0
- package/src/components/filter/SearchInput.js +49 -0
- package/src/components/filter/index.js +6 -0
- package/src/components/form/Form.js +9 -3
- package/src/components/form/FormItem.js +26 -1
- package/src/components/form/FormWrapperComponent.js +12 -3
- package/src/components/form/useNewForm.js +55 -4
- package/src/components/helpers/Separator.js +15 -11
- package/src/components/helpers/index.js +1 -0
- package/src/components/index.js +2 -0
- package/src/components/inputs/BooleanSelect.js +14 -0
- package/src/components/inputs/DateInput.js +3 -1
- package/src/components/inputs/DateRangeInput.js +41 -0
- package/src/components/inputs/Editable.js +129 -0
- package/src/components/inputs/EnabledSelect.js +14 -0
- package/src/components/inputs/InputWrapper.js +7 -4
- package/src/components/inputs/LinkInput.js +1 -1
- package/src/components/inputs/NumberInput.js +10 -5
- package/src/components/inputs/NumberRangeInput.js +41 -0
- package/src/components/inputs/PasswordInput.js +24 -0
- package/src/components/inputs/Picker.js +3 -3
- package/src/components/inputs/Select.js +61 -47
- package/src/components/inputs/TextArea.js +5 -0
- package/src/components/inputs/TextInput.js +14 -4
- package/src/components/inputs/UploadInput.js +140 -0
- package/src/components/inputs/index.js +9 -0
- package/src/components/inputs/upload/Upload.js +99 -0
- package/src/components/inputs/upload/Upload.native.js +154 -0
- package/src/components/inputs/upload/useUploadState.js +143 -0
- package/src/components/layout/LayoutHeader.js +1 -0
- package/src/components/presentation/AvatarLabel.js +1 -1
- package/src/components/presentation/AvatarsGroup.js +30 -0
- package/src/components/presentation/Badge.js +3 -2
- package/src/components/presentation/ContentLabel.js +1 -1
- package/src/components/presentation/IconLabel.js +1 -0
- package/src/components/presentation/Progress.js +20 -0
- package/src/components/presentation/index.js +2 -0
- package/src/components/sections/Section.js +1 -1
- package/src/components/sections/SectionItemLink.js +4 -2
- package/src/components/steps/ActiveStepContent.js +16 -0
- package/src/components/steps/StepsHandler.js +53 -0
- package/src/components/steps/StepsMenu.js +14 -0
- package/src/components/steps/StepsNavigation.js +37 -0
- package/src/components/steps/index.js +4 -0
- package/src/components/structure/Affix.js +34 -0
- package/src/components/structure/Affix.native.js +3 -0
- package/src/components/structure/Card.js +1 -0
- package/src/components/structure/TopBar.js +13 -1
- package/src/components/structure/index.js +1 -0
- package/src/components/structure/overlay/OverlayHandler.js +9 -1
- package/src/components/structure/popover/Popover.js +22 -5
- package/src/components/table/DataTable.js +7 -2
- package/src/components/table/Table.js +2 -1
- package/src/components/tabs/ActiveTabContent.js +4 -1
- package/src/components/text/DateText.js +15 -2
- package/src/modifiers/border.js +15 -9
- package/src/modifiers/size.js +8 -5
- package/src/theme/default/base.js +2 -0
- package/src/theme/default/hackerTheme.js +1 -10
- package/src/theme/default/paperTheme.js +1 -14
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
import { BottomDrawer } from '../../modals/bottomDrawer'
|
|
4
|
+
import { Icon } from '../../presentation/Icon'
|
|
5
|
+
import { Link } from '../../actions/Link'
|
|
6
|
+
import { Text } from '../../text/Text'
|
|
7
|
+
import { View } from '../../structure/View'
|
|
8
|
+
import { useUploadState } from './useUploadState'
|
|
9
|
+
|
|
10
|
+
let ImagePicker
|
|
11
|
+
try {
|
|
12
|
+
ImagePicker = require('expo-image-picker')
|
|
13
|
+
} catch {}
|
|
14
|
+
|
|
15
|
+
let DocumentPicker
|
|
16
|
+
try {
|
|
17
|
+
DocumentPicker = require('expo-document-picker')
|
|
18
|
+
} catch {}
|
|
19
|
+
|
|
20
|
+
function acceptsImages(accept) {
|
|
21
|
+
if (!accept) return true
|
|
22
|
+
return accept.includes('image/') || accept.includes('image/*')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function needsFilePicker(accept) {
|
|
26
|
+
if (!accept) return true
|
|
27
|
+
const parts = accept.split(',').map((s) => s.trim())
|
|
28
|
+
return parts.some((p) => !p.startsWith('image/'))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeImageResult(asset) {
|
|
32
|
+
return {
|
|
33
|
+
uri: asset.uri,
|
|
34
|
+
name: asset.fileName || asset.uri.split('/').pop(),
|
|
35
|
+
type: asset.mimeType || asset.type || 'image/jpeg',
|
|
36
|
+
size: asset.fileSize || asset.filesize,
|
|
37
|
+
width: asset.width,
|
|
38
|
+
height: asset.height,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeDocumentResult(doc) {
|
|
43
|
+
return {
|
|
44
|
+
uri: doc.uri,
|
|
45
|
+
name: doc.name,
|
|
46
|
+
type: doc.mimeType || doc.type,
|
|
47
|
+
size: doc.size,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getMediaTypes(accept) {
|
|
52
|
+
if (!accept) return undefined
|
|
53
|
+
if (accept.includes('video/') && !accept.includes('image/')) return ['videos']
|
|
54
|
+
if (accept.includes('image/') && !accept.includes('video/')) return ['images']
|
|
55
|
+
if (accept.includes('video/') && accept.includes('image/')) return ['images', 'videos']
|
|
56
|
+
return undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, ...props }) {
|
|
60
|
+
const { value, addFiles, remove } = useUploadState({ onUpload, onChange, multiple, maxCount, value: valueProp })
|
|
61
|
+
const [open, setOpen] = useState(false)
|
|
62
|
+
|
|
63
|
+
const handlePress = useCallback(() => {
|
|
64
|
+
if (disabled) return
|
|
65
|
+
setOpen(true)
|
|
66
|
+
}, [disabled])
|
|
67
|
+
|
|
68
|
+
const handleCamera = useCallback(async () => {
|
|
69
|
+
setOpen(false)
|
|
70
|
+
if (!ImagePicker) return
|
|
71
|
+
const permission = await ImagePicker.requestCameraPermissionsAsync()
|
|
72
|
+
if (!permission.granted) return
|
|
73
|
+
const result = await ImagePicker.launchCameraAsync({
|
|
74
|
+
allowsMultipleSelection: multiple,
|
|
75
|
+
selectionLimit: maxCount || 0,
|
|
76
|
+
mediaTypes: getMediaTypes(accept),
|
|
77
|
+
})
|
|
78
|
+
if (result.canceled) return
|
|
79
|
+
addFiles(result.assets.map(normalizeImageResult))
|
|
80
|
+
}, [multiple, maxCount, accept, addFiles])
|
|
81
|
+
|
|
82
|
+
const handleLibrary = useCallback(async () => {
|
|
83
|
+
setOpen(false)
|
|
84
|
+
if (!ImagePicker) return
|
|
85
|
+
const permission = await ImagePicker.requestMediaLibraryPermissionsAsync()
|
|
86
|
+
if (!permission.granted) return
|
|
87
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
88
|
+
allowsMultipleSelection: multiple,
|
|
89
|
+
selectionLimit: maxCount || 0,
|
|
90
|
+
mediaTypes: getMediaTypes(accept),
|
|
91
|
+
})
|
|
92
|
+
if (result.canceled) return
|
|
93
|
+
addFiles(result.assets.map(normalizeImageResult))
|
|
94
|
+
}, [multiple, maxCount, accept, addFiles])
|
|
95
|
+
|
|
96
|
+
const handleFiles = useCallback(async () => {
|
|
97
|
+
setOpen(false)
|
|
98
|
+
if (!DocumentPicker) return
|
|
99
|
+
const result = await DocumentPicker.getDocumentAsync({
|
|
100
|
+
multiple,
|
|
101
|
+
type: accept || '*/*',
|
|
102
|
+
})
|
|
103
|
+
if (result.canceled) return
|
|
104
|
+
addFiles(result.assets.map(normalizeDocumentResult))
|
|
105
|
+
}, [multiple, accept, addFiles])
|
|
106
|
+
|
|
107
|
+
const showCamera = acceptsImages(accept)
|
|
108
|
+
const showLibrary = acceptsImages(accept)
|
|
109
|
+
const showFiles = needsFilePicker(accept)
|
|
110
|
+
|
|
111
|
+
const isRenderFn = typeof children === 'function'
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
{isRenderFn ? (
|
|
116
|
+
<View {...props}>
|
|
117
|
+
{children({ value, remove, isDragging: false, open: handlePress })}
|
|
118
|
+
</View>
|
|
119
|
+
) : (
|
|
120
|
+
<Link onPress={handlePress} disabled={disabled} {...props}>
|
|
121
|
+
{children}
|
|
122
|
+
</Link>
|
|
123
|
+
)}
|
|
124
|
+
<BottomDrawer open={open} onClose={() => setOpen(false)} snapPoints={[200]}>
|
|
125
|
+
<View padding="md" gap="xs">
|
|
126
|
+
{showCamera && (
|
|
127
|
+
<Link onPress={handleCamera}>
|
|
128
|
+
<View row gap="md" padding="sm" centerV>
|
|
129
|
+
<Icon name="camera-line" />
|
|
130
|
+
<Text>Camera</Text>
|
|
131
|
+
</View>
|
|
132
|
+
</Link>
|
|
133
|
+
)}
|
|
134
|
+
{showLibrary && (
|
|
135
|
+
<Link onPress={handleLibrary}>
|
|
136
|
+
<View row gap="md" padding="sm" centerV>
|
|
137
|
+
<Icon name="image-line" />
|
|
138
|
+
<Text>Photo Library</Text>
|
|
139
|
+
</View>
|
|
140
|
+
</Link>
|
|
141
|
+
)}
|
|
142
|
+
{showFiles && (
|
|
143
|
+
<Link onPress={handleFiles}>
|
|
144
|
+
<View row gap="md" padding="sm" centerV>
|
|
145
|
+
<Icon name="file-line" />
|
|
146
|
+
<Text>Files</Text>
|
|
147
|
+
</View>
|
|
148
|
+
</Link>
|
|
149
|
+
)}
|
|
150
|
+
</View>
|
|
151
|
+
</BottomDrawer>
|
|
152
|
+
</>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { useState, useRef, useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
function toArray(val) {
|
|
4
|
+
if (!val) return []
|
|
5
|
+
return Array.isArray(val) ? val : [val]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useUploadState({ onUpload, onChange, multiple, maxCount, value: valueProp }) {
|
|
9
|
+
const [inFlight, setInFlight] = useState([])
|
|
10
|
+
const [committed, setCommitted] = useState(null)
|
|
11
|
+
const idRef = useRef(0)
|
|
12
|
+
const genRef = useRef(0)
|
|
13
|
+
|
|
14
|
+
const isControlled = valueProp !== undefined
|
|
15
|
+
const externalValue = isControlled ? valueProp : committed
|
|
16
|
+
const externalArray = toArray(externalValue)
|
|
17
|
+
|
|
18
|
+
const externalArrayRef = useRef(externalArray)
|
|
19
|
+
externalArrayRef.current = externalArray
|
|
20
|
+
const onChangeRef = useRef(onChange)
|
|
21
|
+
onChangeRef.current = onChange
|
|
22
|
+
const inFlightRef = useRef(inFlight)
|
|
23
|
+
inFlightRef.current = inFlight
|
|
24
|
+
|
|
25
|
+
const value = multiple
|
|
26
|
+
? [...externalArray, ...inFlight]
|
|
27
|
+
: (inFlight[0] || externalArray[0] || null)
|
|
28
|
+
|
|
29
|
+
const addFiles = useCallback(
|
|
30
|
+
(normalizedFiles) => {
|
|
31
|
+
if (!normalizedFiles?.length) return
|
|
32
|
+
|
|
33
|
+
if (!onUpload) {
|
|
34
|
+
if (!multiple) {
|
|
35
|
+
const entry = { ...normalizedFiles[0], _id: ++idRef.current }
|
|
36
|
+
if (!isControlled) setCommitted(entry)
|
|
37
|
+
onChangeRef.current?.(entry)
|
|
38
|
+
} else {
|
|
39
|
+
let files = normalizedFiles
|
|
40
|
+
if (maxCount) {
|
|
41
|
+
const available = maxCount - externalArrayRef.current.length
|
|
42
|
+
if (available <= 0) return
|
|
43
|
+
files = files.slice(0, available)
|
|
44
|
+
}
|
|
45
|
+
const entries = files.map((file) => ({ ...file, _id: ++idRef.current }))
|
|
46
|
+
if (!isControlled) {
|
|
47
|
+
setCommitted((prev) => {
|
|
48
|
+
const next = [...toArray(prev), ...entries]
|
|
49
|
+
onChangeRef.current?.(next)
|
|
50
|
+
return next
|
|
51
|
+
})
|
|
52
|
+
} else {
|
|
53
|
+
onChangeRef.current?.([...externalArrayRef.current, ...entries])
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!multiple) {
|
|
60
|
+
const gen = ++genRef.current
|
|
61
|
+
const file = normalizedFiles[0]
|
|
62
|
+
const _id = ++idRef.current
|
|
63
|
+
const entry = { ...file, _id, status: 'uploading' }
|
|
64
|
+
|
|
65
|
+
setInFlight([entry])
|
|
66
|
+
|
|
67
|
+
onUpload(file)
|
|
68
|
+
.then((result) => {
|
|
69
|
+
if (genRef.current !== gen) return
|
|
70
|
+
const done = { ...entry, ...result, status: 'done' }
|
|
71
|
+
setInFlight([])
|
|
72
|
+
if (!isControlled) setCommitted(done)
|
|
73
|
+
onChangeRef.current?.(done)
|
|
74
|
+
})
|
|
75
|
+
.catch((error) => {
|
|
76
|
+
if (genRef.current !== gen) return
|
|
77
|
+
setInFlight((prev) =>
|
|
78
|
+
prev.map((f) => (f._id === _id ? { ...f, status: 'error', error } : f))
|
|
79
|
+
)
|
|
80
|
+
})
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Multi mode
|
|
85
|
+
let files = normalizedFiles
|
|
86
|
+
if (maxCount) {
|
|
87
|
+
const available = maxCount - externalArrayRef.current.length - inFlightRef.current.length
|
|
88
|
+
if (available <= 0) return
|
|
89
|
+
files = files.slice(0, available)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const entries = files.map((file) => ({
|
|
93
|
+
...file,
|
|
94
|
+
_id: ++idRef.current,
|
|
95
|
+
status: 'uploading',
|
|
96
|
+
}))
|
|
97
|
+
|
|
98
|
+
setInFlight((prev) => [...prev, ...entries])
|
|
99
|
+
|
|
100
|
+
entries.forEach((entry, i) => {
|
|
101
|
+
onUpload(files[i])
|
|
102
|
+
.then((result) => {
|
|
103
|
+
const done = { ...entry, ...result, status: 'done' }
|
|
104
|
+
setInFlight((prev) => prev.filter((f) => f._id !== entry._id))
|
|
105
|
+
if (!isControlled) {
|
|
106
|
+
setCommitted((prev) => {
|
|
107
|
+
const next = [...toArray(prev), done]
|
|
108
|
+
onChangeRef.current?.(next)
|
|
109
|
+
return next
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
112
|
+
onChangeRef.current?.([...externalArrayRef.current, done])
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.catch((error) => {
|
|
116
|
+
setInFlight((prev) =>
|
|
117
|
+
prev.map((f) => (f._id === entry._id ? { ...f, status: 'error', error } : f))
|
|
118
|
+
)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
},
|
|
122
|
+
[onUpload, multiple, maxCount, isControlled]
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
const remove = useCallback(
|
|
126
|
+
(file) => {
|
|
127
|
+
if (!file) return
|
|
128
|
+
|
|
129
|
+
setInFlight((prev) => prev.filter((f) => f._id !== file._id))
|
|
130
|
+
|
|
131
|
+
const ext = externalArrayRef.current
|
|
132
|
+
if (ext.some((f) => f._id === file._id)) {
|
|
133
|
+
const next = ext.filter((f) => f._id !== file._id)
|
|
134
|
+
const val = multiple ? next : next[0] || null
|
|
135
|
+
if (!isControlled) setCommitted(val)
|
|
136
|
+
onChangeRef.current?.(val)
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
[multiple, isControlled]
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return { value, addFiles, remove }
|
|
143
|
+
}
|
|
@@ -44,8 +44,8 @@ export function AvatarLabel(rootProps) {
|
|
|
44
44
|
icon={icon}
|
|
45
45
|
src={src}
|
|
46
46
|
size={avatarSize || moveScale(sizeCode, moveAvatarSizeScale || -1)}
|
|
47
|
-
color={avatarColor || color}
|
|
48
47
|
dynamicColor={dynamicColor}
|
|
48
|
+
{...(!dynamicColor && { color: avatarColor || color })}
|
|
49
49
|
square={square}
|
|
50
50
|
marginH={2}
|
|
51
51
|
iconSize={iconSize}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Avatar } from './Avatar'
|
|
4
|
+
import { View } from '../structure/View'
|
|
5
|
+
import { useGetElementHeight } from '../../theme'
|
|
6
|
+
|
|
7
|
+
export function AvatarsGroup({ maxCount, size = 'md', overlap, children, ...props }) {
|
|
8
|
+
const getSize = useGetElementHeight()
|
|
9
|
+
const sizeValue = getSize(size)
|
|
10
|
+
overlap = overlap || Math.round(sizeValue * 0.6)
|
|
11
|
+
|
|
12
|
+
const items = React.Children.toArray(children).filter(React.isValidElement)
|
|
13
|
+
const visibleItems = maxCount ? items.slice(0, maxCount) : items
|
|
14
|
+
const overflowCount = maxCount ? items.length - maxCount : 0
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View row centerV>
|
|
18
|
+
{visibleItems.map((child, index) => (
|
|
19
|
+
<View key={child.key || index} style={index > 0 ? { marginLeft: -overlap } : undefined}>
|
|
20
|
+
{React.cloneElement(child, { size, border: 1, borderColor: 'overlayBG', ...props })}
|
|
21
|
+
</View>
|
|
22
|
+
))}
|
|
23
|
+
{overflowCount > 0 && (
|
|
24
|
+
<View style={{ marginLeft: -overlap }}>
|
|
25
|
+
<Avatar name={`+${overflowCount}`} size={size} color="text4" border borderColor="overlayBG" />
|
|
26
|
+
</View>
|
|
27
|
+
)}
|
|
28
|
+
</View>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -77,12 +77,13 @@ function Badge(rootProps) {
|
|
|
77
77
|
|
|
78
78
|
function BadgeWrapper({ children, dot, ...props }) {
|
|
79
79
|
if (!children) return <Badge dot={dot} {...props} />
|
|
80
|
-
|
|
80
|
+
const hasContent = props.value || props.label || props.icon || (dot && props.value === undefined)
|
|
81
|
+
if (!hasContent) return children
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
84
|
<View className="neko-badge-wrapper" relative>
|
|
84
85
|
{children}
|
|
85
|
-
<Badge
|
|
86
|
+
<Badge dot={dot} absolute top={dot ? -2 : -8} right={dot ? -5 : -12} {...props} />
|
|
86
87
|
</View>
|
|
87
88
|
)
|
|
88
89
|
}
|
|
@@ -32,7 +32,7 @@ export function ContentLabel(rootProps) {
|
|
|
32
32
|
return (
|
|
33
33
|
<View className="neko-content-label" row gap={gap || AUTO_GAP_SCALE[sizeCode] || 5} centerV {...props}>
|
|
34
34
|
{!invert && content}
|
|
35
|
-
{
|
|
35
|
+
{label != null && label != false && label !== '' && (
|
|
36
36
|
<Text color={color} size={sizeCode} strong={strong} {...textProps}>
|
|
37
37
|
{label}
|
|
38
38
|
</Text>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
3
|
+
import { View } from '../structure/View'
|
|
4
|
+
import { useColorConverter } from '../../modifiers/colorConverter'
|
|
5
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
6
|
+
|
|
7
|
+
export function Progress({ value, target = 100, bg = 'divider', height = 8, ...rootProps }) {
|
|
8
|
+
const [{ color }, props] = pipe(
|
|
9
|
+
useColorConverter('primary'),
|
|
10
|
+
useThemeComponentModifier('Progress') //
|
|
11
|
+
)([{}, rootProps])
|
|
12
|
+
|
|
13
|
+
const pct = Math.max(0, Math.min(100, ((value || 0) / target) * 100))
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<View className="neko-progress" fullW height={height} bg={bg} br={height} hiddenOverflow relative {...props}>
|
|
17
|
+
<View absolute top={0} bottom={0} left={0} bg={color} width={`${pct}%`} br={height} />
|
|
18
|
+
</View>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export * from './Tag'
|
|
2
2
|
export * from './Icon'
|
|
3
3
|
export * from './IconLabel'
|
|
4
|
+
export * from './Progress'
|
|
4
5
|
export * from './Result'
|
|
5
6
|
export * from './ResultBar'
|
|
6
7
|
export * from './Tooltip'
|
|
7
8
|
export * from './Badge'
|
|
8
9
|
export * from './Avatar'
|
|
9
10
|
export * from './AvatarLabel'
|
|
11
|
+
export * from './AvatarsGroup'
|
|
10
12
|
export * from './Image'
|
|
11
13
|
export * from './ImageBackground'
|
|
12
14
|
export * from './LabelValue'
|
|
@@ -8,9 +8,9 @@ import { useDefaultModifier } from '../../modifiers/default'
|
|
|
8
8
|
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
9
9
|
|
|
10
10
|
const DEFAULT_PROPS = {
|
|
11
|
-
marginH: 'md',
|
|
12
11
|
bg: 'overlayBG',
|
|
13
12
|
br: 'md',
|
|
13
|
+
border: 'overlayDivider',
|
|
14
14
|
titleProps: {
|
|
15
15
|
strong: true,
|
|
16
16
|
text4: true,
|
|
@@ -14,7 +14,7 @@ const DEFAULT_PROPS = {
|
|
|
14
14
|
icon: 'arrow-right-s-line',
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function SectionItemLink({ children, value, onPress, ...rootProps }) {
|
|
17
|
+
export function SectionItemLink({ children, value, onPress, loading, ...rootProps }) {
|
|
18
18
|
const [{ color }, formattedProps] = pipe(
|
|
19
19
|
useColorConverter(),
|
|
20
20
|
useThemeComponentModifier('SectionItemLink'), //
|
|
@@ -26,7 +26,9 @@ export function SectionItemLink({ children, value, onPress, ...rootProps }) {
|
|
|
26
26
|
return (
|
|
27
27
|
<Link className="neko-section-item-link" onPress={onPress}>
|
|
28
28
|
<SectionItem color={color} {...props}>
|
|
29
|
-
{children ||
|
|
29
|
+
{children || (
|
|
30
|
+
<IconLabel gap={2} invert color={color} loading={loading} {...iconLabelProps} label={value} icon={icon} />
|
|
31
|
+
)}
|
|
30
32
|
</SectionItem>
|
|
31
33
|
</Link>
|
|
32
34
|
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useSteps } from './StepsHandler'
|
|
4
|
+
|
|
5
|
+
export function ActiveStepContent() {
|
|
6
|
+
const { activeStep } = useSteps()
|
|
7
|
+
|
|
8
|
+
const Content = React.useMemo(
|
|
9
|
+
() => activeStep.render || activeStep.renderContent || activeStep.Content,
|
|
10
|
+
[activeStep.renderContent, activeStep.Content]
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if (!Content) return false
|
|
14
|
+
|
|
15
|
+
return <Content />
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
const StepsContext = React.createContext(null)
|
|
4
|
+
export const useSteps = () => React.useContext(StepsContext) || {}
|
|
5
|
+
|
|
6
|
+
export function StepsHandler({ children, items, onSubmit, onValidateStep, onStepChange, resetMaxIndexOnNavigate }) {
|
|
7
|
+
const [activeIndex, setActiveIndex] = React.useState(0)
|
|
8
|
+
const [maxIndexReleased, setMaxIndexReleased] = React.useState(0)
|
|
9
|
+
const [loading, setLoading] = React.useState(false)
|
|
10
|
+
const activeStep = items[activeIndex]
|
|
11
|
+
const isLastStep = activeIndex === items.length - 1
|
|
12
|
+
|
|
13
|
+
const moveToIndex = async (index) => {
|
|
14
|
+
const shouldValidate = index > activeIndex
|
|
15
|
+
if (shouldValidate) {
|
|
16
|
+
setLoading(true)
|
|
17
|
+
try {
|
|
18
|
+
let result = await Promise.resolve(onValidateStep?.())
|
|
19
|
+
if (result === false) return
|
|
20
|
+
result = await Promise.resolve(activeStep?.onValidate?.())
|
|
21
|
+
if (result === false) return
|
|
22
|
+
} catch {
|
|
23
|
+
return
|
|
24
|
+
} finally {
|
|
25
|
+
setLoading(false)
|
|
26
|
+
}
|
|
27
|
+
await Promise.resolve(onStepChange?.())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (index === items.length) onSubmit?.()
|
|
31
|
+
const nextStep = items[index]
|
|
32
|
+
if (!nextStep) return
|
|
33
|
+
setActiveIndex(index)
|
|
34
|
+
if (index > maxIndexReleased || !!resetMaxIndexOnNavigate) setMaxIndexReleased(index)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const moveToNextStep = () => moveToIndex(activeIndex + 1)
|
|
38
|
+
const moveToPrevStep = () => moveToIndex(activeIndex - 1)
|
|
39
|
+
|
|
40
|
+
const value = {
|
|
41
|
+
items,
|
|
42
|
+
moveToIndex,
|
|
43
|
+
activeIndex,
|
|
44
|
+
activeStep,
|
|
45
|
+
maxIndexReleased,
|
|
46
|
+
loading,
|
|
47
|
+
isLastStep,
|
|
48
|
+
moveToNextStep,
|
|
49
|
+
moveToPrevStep,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return <StepsContext.Provider value={value}>{children}</StepsContext.Provider>
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Menu } from '../actions'
|
|
2
|
+
import { useSteps } from './StepsHandler'
|
|
3
|
+
|
|
4
|
+
export function StepsMenu(props) {
|
|
5
|
+
const { activeIndex, items, moveToIndex, maxIndexReleased } = useSteps()
|
|
6
|
+
const formattedItems = items.map((item, index) => ({
|
|
7
|
+
...item,
|
|
8
|
+
disabled: maxIndexReleased < index,
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Menu items={formattedItems} activeIndex={activeIndex} onChangeIndex={(index) => moveToIndex(index)} {...props} />
|
|
13
|
+
)
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Button } from '../actions'
|
|
2
|
+
import { View } from '../structure'
|
|
3
|
+
import { useSteps } from './StepsHandler'
|
|
4
|
+
|
|
5
|
+
export function StepsReturnButton(props) {
|
|
6
|
+
const { activeIndex, moveToPrevStep } = useSteps()
|
|
7
|
+
if (activeIndex === 0) return null
|
|
8
|
+
|
|
9
|
+
return <Button label="Back" outline icon="arrow-left-line" onPress={moveToPrevStep} text4 {...props} />
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function StepsSubmitButton({ loading: propLoading, ...props }) {
|
|
13
|
+
const { isLastStep, moveToNextStep, loading } = useSteps()
|
|
14
|
+
const label = isLastStep ? 'Submit' : 'Next'
|
|
15
|
+
const icon = isLastStep ? 'checkbox-circle-line' : 'arrow-right-line'
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Button
|
|
19
|
+
label={label}
|
|
20
|
+
outline={!isLastStep}
|
|
21
|
+
icon={icon}
|
|
22
|
+
onPress={moveToNextStep}
|
|
23
|
+
loading={propLoading || loading}
|
|
24
|
+
invert
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function StepsNavigation({ submitProps, returnProps, ...props }) {
|
|
31
|
+
return (
|
|
32
|
+
<View row centerV toRight {...props} gap="sm">
|
|
33
|
+
<StepsReturnButton {...props} {...returnProps} />
|
|
34
|
+
<StepsSubmitButton {...props} {...submitProps} />
|
|
35
|
+
</View>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from './View'
|
|
3
|
+
|
|
4
|
+
export function Affix({ children, shadow, offsetTop, offsetBottom, ...props }) {
|
|
5
|
+
const [isFloating, setIsFloating] = React.useState(false)
|
|
6
|
+
const sentinelRef = React.useRef()
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const sentinel = sentinelRef.current
|
|
10
|
+
if (!sentinel) return
|
|
11
|
+
|
|
12
|
+
const observer = new IntersectionObserver(
|
|
13
|
+
([entry]) => setIsFloating(!entry.isIntersecting),
|
|
14
|
+
{ threshold: [1] }
|
|
15
|
+
)
|
|
16
|
+
observer.observe(sentinel)
|
|
17
|
+
return () => observer.disconnect()
|
|
18
|
+
}, [])
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div ref={sentinelRef} style={{ height: 0 }} />
|
|
23
|
+
<View
|
|
24
|
+
sticky
|
|
25
|
+
top={offsetBottom === undefined ? (offsetTop || 0) : undefined}
|
|
26
|
+
bottom={offsetBottom}
|
|
27
|
+
shadow={shadow && isFloating}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</View>
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
|
|
1
3
|
import { Text } from '../text'
|
|
2
4
|
import { View } from './View'
|
|
5
|
+
import { useDefaultModifier } from '../../modifiers/default'
|
|
3
6
|
import { useResponsiveConverter } from '../../modifiers/responsiveConverter'
|
|
7
|
+
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
4
8
|
import { useSafeAreaInsets } from '../../abstractions/helpers/useSafeAreaInsets'
|
|
5
9
|
|
|
10
|
+
const DEFAULT_PROPS = {
|
|
11
|
+
borderB: 'overlayDivider',
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
export function TopBar({ right, left, WrapperView, children, ...rootProps }) {
|
|
7
15
|
const { top: safeTop } = useSafeAreaInsets()
|
|
8
16
|
|
|
9
|
-
const [_, props] =
|
|
17
|
+
const [_, props] = pipe(
|
|
18
|
+
useThemeComponentModifier('TopBar'),
|
|
19
|
+
useDefaultModifier(DEFAULT_PROPS),
|
|
20
|
+
useResponsiveConverter([])
|
|
21
|
+
)([{}, rootProps])
|
|
10
22
|
let { useSafeArea = true, title, subtitle } = props
|
|
11
23
|
|
|
12
24
|
const hasContent = !!title || !!subtitle || !!children || !!right || !!left
|